javascript
39 lines ยท 1,101 chars
const axios = require("axios")
const pluginConfig = {
name: 'ytmp4',
alias: ['youtubemp4', 'ytvideo', 'yt4'],
category: 'download',
description: 'Download video YouTube',
usage: '.ytmp4 <url>',
example: '.ytmp4 https://youtube.com/watch?v=xxx',
cooldown: 20,
energi: 1,
isEnabled: true
}
async function handler(m, { sock }) {
const url = m.text?.trim()
if (!url) return m.reply(`Contoh: ${m.prefix}ytmp4 https://youtube.com/watch?v=xxx`)
if (!url.includes('youtube.com') && !url.includes('youtu.be')) return m.reply('โ URL harus YouTube')
m.react('๐')
try {
const { data } = await axios.get(`https://api.nexray.web.id/downloader/ytmp4?url=${url}&resolusi=720`)
await sock.sendMedia(m.chat, data.result.url, data.result.title, m, {
type: 'video',
})
m.react('โ
')
} catch (err) {
console.error('[YTMP4]', err)
m.react('โ')
m.reply('Gagal mengunduh video.')
}
}
module.exports = {
config: pluginConfig,
handler
}