const { yts, System, isPrivate, YtInfo, youtube, toAudio } = require('../lib/'); const { isUrl, getBuffer, extractUrlsFromText } = require('./client/'); System({ pattern: '(ytk|gan)', fromMe: isPrivate, type: 'download', desc: 'YouTube audio downloader (Voice Note style)' }, async (message, match) => { match = match || message.reply_message?.text; if (!match) return await message.reply('_Give a YouTube video *Url* or *Query*_'); const matchUrl = (await extractUrlsFromText(match))[0]; try { if (isUrl(matchUrl)) { // URL দিয়ে গান const { url } = await youtube(matchUrl); const { title } = await YtInfo(matchUrl); await message.reply(`🎶 *${title}* ...`) Gᴇɴᴇʀᴀᴛᴇᴅ ʙʏ 〆͎MR-Rabbit ; const audioBuffer = await toAudio(await getBuffer(url)); await message.send(audioBuffer, { mimetype: 'audio/mpeg', ptt: true }, "audio"); } else { // const { title, url } = (await yts(match))[0]; await message.reply(`🎶 Downloading *${title}* ...`); const audioBuffer = await toAudio(await getBuffer((await youtube(url)).url)); await message.send(audioBuffer, { mimetype: 'audio/mpeg', ptt: true }, "audio"); } } catch (err) { console.error(err); await message.reply('⚠️ EROR BY MR-RABBIT '); } });