|
const axios = require("axios"); |
|
const { cmd } = require("../command"); |
|
|
|
cmd({ |
|
pattern: "fbdl", |
|
alias: ["facebook", "fb"], |
|
react: 'โฐ', |
|
desc: "Download videos from Facebook.", |
|
category: "download", |
|
use: ".fbdl <Facebook video URL>", |
|
filename: __filename |
|
}, async (conn, mek, m, { from, reply, args }) => { |
|
try { |
|
|
|
const fbUrl = args[0]; |
|
if (!fbUrl || !fbUrl.includes("facebook.com")) { |
|
return reply('*๐โัฮฑสั ๐ษผเนฮฝฮนษั ๐ fbา ๐ฮนษัเน เนษผ ษผััโ ๐ษผโ..*'); |
|
} |
|
|
|
|
|
await conn.sendMessage(from, { react: { text: 'โณ', key: m.key } }); |
|
|
|
|
|
const apiUrl = `https://apis.davidcyriltech.my.id/facebook2?url=${encodeURIComponent(fbUrl)}`; |
|
|
|
|
|
const response = await axios.get(apiUrl); |
|
|
|
|
|
if (!response.data || !response.data.status || !response.data.video) { |
|
return reply('โ Unable to fetch the video. Please check the URL and try again.'); |
|
} |
|
|
|
|
|
const { title, thumbnail, downloads } = response.data.video; |
|
|
|
|
|
const downloadLink = downloads.find(d => d.quality === "HD")?.downloadUrl || downloads[0].downloadUrl; |
|
|
|
|
|
|
|
|
|
|
|
const videoResponse = await axios.get(downloadLink, { responseType: 'arraybuffer' }); |
|
if (!videoResponse.data) { |
|
return reply('โ Failed to download the video. Please try again later.'); |
|
} |
|
|
|
|
|
const videoBuffer = Buffer.from(videoResponse.data, 'binary'); |
|
|
|
|
|
await conn.sendMessage(from, { |
|
video: videoBuffer, |
|
caption: `*๐ซ๐ษญฤซฤซ ๐ฦ ๐๐๐๐๐๐๐๐๐๐*\n\n` + |
|
`๐ *TITLE*: ${title}\n` + |
|
`๐ *QUALITY*: ${downloads.find(d => d.quality === "HD") ? "HD" : "SD"}\n\n` + |
|
`> *ยฉ แดแดแดกแดสแดแด
สส แดสษช*`, |
|
contextInfo: { |
|
mentionedJid: [m.sender], |
|
forwardingScore: 999, |
|
isForwarded: true, |
|
forwardedNewsletterMessageInfo: { |
|
newsletterJid: '120363318387454868@newsletter', |
|
newsletterName: 'ใ ๐ษญฤซฤซ ๐ฦ ๐
๐ ๐๐ ใ', |
|
serverMessageId: 143 |
|
} |
|
} |
|
}, { quoted: mek }); |
|
|
|
|
|
await conn.sendMessage(from, { react: { text: 'โ
', key: m.key } }); |
|
} catch (error) { |
|
console.error('Error downloading video:', error); |
|
reply('โ Unable to download the video. Please try again later.'); |
|
|
|
|
|
await conn.sendMessage(from, { react: { text: 'โ', key: m.key } }); |
|
} |
|
}); |
|
|
|
|
|
|