Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const { Converter } = new(require('@neoxr/wb'))
- exports.run = {
- usage: ['ytmp3', 'ytmp4'],
- hidden: ['yta', 'ytv'],
- use: 'link',
- category: 'downloader',
- async: async (m, {
- client,
- args,
- isPrefix,
- command,
- users,
- env,
- Func,
- Scraper
- }) => {
- try {
- if (/yt?(a|mp3)/i.test(command)) {
- if (!args || !args[0]) return client.reply(m.chat, Func.example(isPrefix, command, 'https://youtu.be/zaRFmdtLhQ8'), m)
- if (!/^(?:https?:\/\/)?(?:www\.|m\.|music\.)?youtu\.?be(?:\.com)?\/?.*(?:watch|embed)?(?:.*v=|v\/|\/)([\w\-_]+)\&?/.test(args[0])) return client.reply(m.chat, global.status.invalid, m)
- client.sendReact(m.chat, 'π', m.key)
- const json = await Scraper.youtube(args[0])
- if (!json.status) return client.reply(m.chat, Func.jsonFormat(json), m)
- let caption = `δΉ *Y T - P L A Y*\n\n`
- caption += ` β¦ *Title* : ${json.title}\n`
- caption += ` β¦ *Size* : ${json.data.size}\n`
- caption += ` β¦ *Duration* : ${json.duration}\n`
- caption += ` β¦ *Bitrate* : ${json.data.quality}\n\n`
- caption += global.footer
- const chSize = Func.sizeLimit(json.data.size, users.premium ? env.max_upload : env.max_upload_free)
- const isOver = users.premium ? `π File size (${json.data.size}) exceeds the maximum limit.` : `β οΈ File size (${json.data.size}), you can only download files with a maximum size of ${env.max_upload_free} MB and for premium users a maximum of ${env.max_upload} MB.`
- if (chSize.oversize) return client.reply(m.chat, isOver, m)
- client.sendMessageModify(m.chat, caption, m, {
- largeThumb: true,
- thumbnail: await Func.fetchBuffer(json.thumbnail)
- }).then(async () => {
- const buffer = await Converter.toAudio(json.data.buffer, 'mp3')
- client.sendFile(m.chat, buffer, json.data.filename, '', m, {
- document: true,
- APIC: await Func.fetchBuffer(json.thumbnail)
- })
- })
- } else if (/yt?(v|mp4)/i.test(command)) {
- if (!args || !args[0]) return client.reply(m.chat, Func.example(isPrefix, command, 'https://youtu.be/zaRFmdtLhQ8'), m)
- if (!/^(?:https?:\/\/)?(?:www\.|m\.|music\.)?youtu\.?be(?:\.com)?\/?.*(?:watch|embed)?(?:.*v=|v\/|\/)([\w\-_]+)\&?/.test(args[0])) return client.reply(m.chat, global.status.invalid, m)
- client.sendReact(m.chat, 'π', m.key)
- const json = await Scraper.youtube(args[0], 'video')
- if (!json.status) return client.reply(m.chat, Func.jsonFormat(json), m)
- let caption = `δΉ *Y T - M P 4*\n\n`
- caption += ` β¦ *Title* : ${json.title}\n`
- caption += ` β¦ *Size* : ${json.data.size}\n`
- caption += ` β¦ *Duration* : ${json.duration}\n`
- caption += ` β¦ *Quality* : ${json.data.quality}\n\n`
- caption += global.footer
- const chSize = Func.sizeLimit(json.data.size, users.premium ? env.max_upload : env.max_upload_free)
- const isOver = users.premium ? `π File size (${json.data.size}) exceeds the maximum limit.` : `β οΈ File size (${json.data.size}), you can only download files with a maximum size of ${env.max_upload_free} MB and for premium users a maximum of ${env.max_upload} MB.`
- if (chSize.oversize) return client.reply(m.chat, isOver, m)
- let isSize = (json.data.size).replace(/MB/g, '').trim()
- if (isSize > 99) return client.sendMessageModify(m.chat, caption, m, {
- largeThumb: true,
- thumbnail: await Func.fetchBuffer(json.thumbnail)
- }).then(async () => {
- await client.sendFile(m.chat, json.data.buffer, json.data.filename, caption, m, {
- document: true
- })
- })
- client.sendFile(m.chat, json.data.buffer, json.data.filename, caption, m)
- }
- } catch (e) {
- return client.reply(m.chat, Func.jsonFormat(e), m)
- }
- },
- error: false,
- limit: true,
- cache: true,
- location: __filename
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement