const axios = require("axios"); const cheerio = require("cheerio"); const dipto = require("tinyurl") module.exports = { config: { name: "fb", version: "1.2", author: "NTKhang", countDown: 5, role: 0, shortDescription: { vi: "Tải video từ facebook", en: "Download video from facebook" }, longDescription: { vi: "Tải video/story từ facebook (công khai)", en: "Download video/story from facebook (public)" }, category: "?????", guide: { en: " {pn} <url video/story>: tải video từ facebook" } }, langs: { vi: { missingUrl: "Vui lòng nhập url video/story facebook (công khai) bạn muốn tải về", error: "Đã xảy ra lỗi khi tải video", downloading: "Đang tiến hành tải video cho bạn", tooLarge: "Rất tiếc không thể tải video cho bạn vì dung lượng lớn hơn 83MB" }, en: { missingUrl: "⚠ Please enter the facebook video/story (public) url you want to download", error: "❌ An error occurred while downloading the video", downloading: "? Downloading video for you", tooLarge: "? Sorry, we can't download the video for you because the size is larger than 83MB" } }, onStart: async function ({ args, message, getLang }) { if (!args[0]) return message.reply(getLang("missingUrl")); const response = await fbDownloader(args[0]); if (response.success === false) return message.reply(getLang("error")); let success = false; const msgSend = message.reply(getLang("downloading")); for (const item of response.download) { const res = await axios({ url: item.url, responseType: 'stream' }); if (res.headers['content-length'] > 87031808) continue; res.data.path = global.utils.randomString(10) + '.mp4'; const dip = await dipto.shorten(item.url); message.reply({ body: `=== [ ${item.quality} ] ===nnDownload Link:n${dip}`, attachment: res.data }, async () => message.unsend((await msgSend).messageID)); success = true; break; } if (!success) { message.unsend((await msgSend).messageID); return message.reply(getLang("tooLarge")); } } }; async function fbDownloader(url) { try { const response1 = await axios({ method: 'POST', url: 'https://snapsave.app/action.php?lang=en', headers: { "accept": "*/*", "accept-language": "vi,en-US;q=0.9,en;q=0.8", "content-type": "multipart/form-data", "sec-ch-ua": ""Chromium";v="110", "Not A(Brand";v="24", "Microsoft Edge";v="110"", "sec-ch-ua-mobile": "?0", "sec-ch-ua-platform": ""Windows"", "sec-fetch-dest": "empty", "sec-fetch-mode": "cors", "sec-fetch-site": "same-origin", "Referer": "https://snapsave.app/vn", "Referrer-Policy": "strict-origin-when-cross-origin" }, data: { url } }); let html; const evalCode = response1.data.replace('return decodeURIComponent', 'html = decodeURIComponent'); eval(evalCode); html = html.split('innerHTML = "')[1].split('";n')[0].replace(/\"/g, '"'); const $ = cheerio.load(html); const download = []; const tbody = $('table').find('tbody'); const trs = tbody.find('tr'); trs.each(function (i, elem) { const trElement = $(elem); const tds = trElement.children(); const quality = $(tds[0]).text().trim(); const url = $(tds[2]).children('a').attr('href'); if (url != undefined) { download.push({ quality, url }); } }); return { success: true, video_length: $("div.clearfix > p").text().trim(), download }; } catch (err) { return { success: false }; } }