const axios = require('axios');
// ─── ytplay ──────────────────────────────────────────────────
const ytplay = {
name: 'ytplay',
command: ['ytplay', 'play', 'song'],
category: 'Downloader',
desc: 'Search and download YouTube audio',
run: async ({ trashcore, m, args, xreply, prefix, chat }) => {
try {
const query = args.join(' ');
if (!query) {
return xreply(`Usage: ${prefix}ytplay Faded Alan Walker`);
}
await trashcore.sendMessage(chat, {
react: { text: '🔍', key: m.key }
});
const api = `https://api.drexapp.space/downloader/ytplay?q=${encodeURIComponent(query)}`;
const { data } = await axios.get(api);
if (!data.status || !data.result) {
return xreply('Song not found.');
}
const res = data.result;
const caption = `
*YOUTUBE PLAY RESULT*
*Title:* ${res.title}
*Channel:* ${res.channel}
*Duration:* ${res.duration}
*Views:* ${Number(res.views).toLocaleString()}
*Published:* ${res.published}
*Format:* ${res.format}
> Powered by DrexApp
`.trim();
await trashcore.sendMessage(
chat,
{
image: { url: res.thumbnail },
caption
},
{ quoted: m }
);
await trashcore.sendMessage(
chat,
{
audio: { url: res.download_url },
mimetype: 'audio/mpeg',
fileName: `${res.title}.mp3`
},
{ quoted: m }
);
await trashcore.sendMessage(chat, {
react: { text: '✅', key: m.key }
});
} catch (err) {
console.error(err);
xreply('Failed to fetch song.');
}
}
};
module.exports = ytplay;
Command: play
Note: YouTube music downloader with metadata now