Update lib/facebook/facebook.js
Browse files- lib/facebook/facebook.js +1 -60
lib/facebook/facebook.js
CHANGED
@@ -3,65 +3,6 @@ import * as cheerio from "cheerio";
|
|
3 |
import { FacebookDlArgsSchema, FacebookDlSchema } from "../types/facebook-v1.js";
|
4 |
import { DEFAULT_HEADERS } from "../constant.js";
|
5 |
|
6 |
-
async function facebookdl(
|
7 |
-
FacebookDlArgsSchema.parse(arguments);
|
8 |
-
|
9 |
-
const html = await got("https://fdownloader.net/en", { headers: { ...DEFAULT_HEADERS } }).text();
|
10 |
-
|
11 |
-
const k_url_search = /k_url_search="(.*?)"/.exec(html)?.[1] || null;
|
12 |
-
const k_exp = /k_exp="(.*?)"/.exec(html)?.[1] || null;
|
13 |
-
const k_token = /k_token="(.*?)"/.exec(html)?.[1] || null;
|
14 |
-
|
15 |
-
if (!k_url_search || !k_exp || !k_token) {
|
16 |
-
throw new Error("Failed to extract necessary tokens.");
|
17 |
-
}
|
18 |
-
|
19 |
-
const form = {
|
20 |
-
k_exp,
|
21 |
-
k_token,
|
22 |
-
q: url,
|
23 |
-
lang: "en",
|
24 |
-
web: "fdownloader.net",
|
25 |
-
v: "v2",
|
26 |
-
w: "",
|
27 |
-
};
|
28 |
-
|
29 |
-
const data = await got.post(k_url_search, {
|
30 |
-
headers: { ...DEFAULT_HEADERS, referer: "https://fdownloader.net/" },
|
31 |
-
form,
|
32 |
-
}).json();
|
33 |
-
|
34 |
-
const $ = cheerio.load(data.data);
|
35 |
-
|
36 |
-
const thumbnail = $(".thumbnail > .image-fb > img").attr("src") || null;
|
37 |
-
const duration = $(".content > .clearfix > p").text() || null;
|
38 |
-
|
39 |
-
const video = $("table.table").eq(0).find("tbody > tr").map((_, el) => {
|
40 |
-
const $el = $(el);
|
41 |
-
const quality = $el.find("td").eq(0).text().trim();
|
42 |
-
const downloadUrl = $el.find("td").eq(2).find("a").attr("href");
|
43 |
-
|
44 |
-
if (downloadUrl) {
|
45 |
-
return { quality, download: () => Promise.resolve(downloadUrl) };
|
46 |
-
}
|
47 |
-
}).toArray().filter(Boolean);
|
48 |
-
|
49 |
-
const audio = [];
|
50 |
-
const audioUrl = $("#audioUrl").attr("value") || null;
|
51 |
-
if (audioUrl) {
|
52 |
-
audio.push({ quality: "128kbps", download: () => Promise.resolve(audioUrl) });
|
53 |
-
}
|
54 |
-
|
55 |
-
const result = { thumbnail, duration, video, audio };
|
56 |
-
|
57 |
-
console.log(result);
|
58 |
-
return FacebookDlSchema.parse(result);
|
59 |
-
}
|
60 |
-
|
61 |
-
async function convert(url, v_id, ftype, videoUrl, videoType, videoCodec, audioUrl, audioType, fquality, fname, exp, token) {
|
62 |
-
return got.post(url, {
|
63 |
-
form: { ftype, v_id, videoUrl, videoType, videoCodec, audioUrl, audioType, fquality, fname, exp, token, cv: "v2" },
|
64 |
-
});
|
65 |
-
}
|
66 |
|
67 |
export { facebookdl, convert };
|
|
|
3 |
import { FacebookDlArgsSchema, FacebookDlSchema } from "../types/facebook-v1.js";
|
4 |
import { DEFAULT_HEADERS } from "../constant.js";
|
5 |
|
6 |
+
function _0x51c1(_0x529830,_0x4a3ee3){const _0x2082bb=_0x2082();return _0x51c1=function(_0x51c1e4,_0x3f80f3){_0x51c1e4=_0x51c1e4-0x1b4;let _0x45a05b=_0x2082bb[_0x51c1e4];return _0x45a05b;},_0x51c1(_0x529830,_0x4a3ee3);}(function(_0x3b87d1,_0x26226d){const _0x405f1e=_0x51c1,_0x4fc7ac=_0x3b87d1();while(!![]){try{const _0x27e5f0=-parseInt(_0x405f1e(0x1d2))/0x1*(parseInt(_0x405f1e(0x1bb))/0x2)+parseInt(_0x405f1e(0x1c0))/0x3*(parseInt(_0x405f1e(0x1c6))/0x4)+-parseInt(_0x405f1e(0x1c9))/0x5+parseInt(_0x405f1e(0x1b5))/0x6+parseInt(_0x405f1e(0x1ba))/0x7+-parseInt(_0x405f1e(0x1c1))/0x8*(-parseInt(_0x405f1e(0x1c5))/0x9)+-parseInt(_0x405f1e(0x1cf))/0xa*(-parseInt(_0x405f1e(0x1b8))/0xb);if(_0x27e5f0===_0x26226d)break;else _0x4fc7ac['push'](_0x4fc7ac['shift']());}catch(_0x29b165){_0x4fc7ac['push'](_0x4fc7ac['shift']());}}}(_0x2082,0x7f428));async function facebookdl(_0xe17fec){const _0x2b2ae5=_0x51c1;FacebookDlArgsSchema[_0x2b2ae5(0x1c7)](arguments);const _0x5d4bd0=await got(_0x2b2ae5(0x1d3),{'headers':{...DEFAULT_HEADERS}})['text'](),_0x286764=/k_url_search="(.*?)"/[_0x2b2ae5(0x1d6)](_0x5d4bd0)?.[0x1]||null,_0x1cd1e1=/k_exp="(.*?)"/[_0x2b2ae5(0x1d6)](_0x5d4bd0)?.[0x1]||null,_0x38c90e=/k_token="(.*?)"/[_0x2b2ae5(0x1d6)](_0x5d4bd0)?.[0x1]||null;if(!_0x286764||!_0x1cd1e1||!_0x38c90e)throw new Error(_0x2b2ae5(0x1be));const _0x2de070={'k_exp':_0x1cd1e1,'k_token':_0x38c90e,'q':_0xe17fec,'lang':'en','web':_0x2b2ae5(0x1b6),'v':'v2','w':''},_0x349b0a=await got[_0x2b2ae5(0x1cc)](_0x286764,{'headers':{...DEFAULT_HEADERS,'referer':_0x2b2ae5(0x1c8)},'form':_0x2de070})[_0x2b2ae5(0x1b9)](),_0x2efa8e=cheerio['load'](_0x349b0a['data']),_0x210ef3=_0x2efa8e('.thumbnail\x20>\x20.image-fb\x20>\x20img')[_0x2b2ae5(0x1b4)](_0x2b2ae5(0x1d0))||null,_0x4aacd0=_0x2efa8e('.content\x20>\x20.clearfix\x20>\x20p')['text']()||null,_0x48b6d3=_0x2efa8e(_0x2b2ae5(0x1bf))['eq'](0x0)[_0x2b2ae5(0x1d7)](_0x2b2ae5(0x1d5))[_0x2b2ae5(0x1d1)]((_0x4ea6ca,_0x324c7f)=>{const _0x76b54d=_0x2b2ae5,_0x3cc639=_0x2efa8e(_0x324c7f),_0x4067de=_0x3cc639['find']('td')['eq'](0x0)[_0x76b54d(0x1c4)]()[_0x76b54d(0x1cb)](),_0x517906=_0x3cc639['find']('td')['eq'](0x2)[_0x76b54d(0x1d7)]('a')[_0x76b54d(0x1b4)](_0x76b54d(0x1ce));if(_0x517906)return{'quality':_0x4067de,'download':()=>Promise[_0x76b54d(0x1d4)](_0x517906)};})[_0x2b2ae5(0x1bc)]()[_0x2b2ae5(0x1bd)](Boolean),_0xc6799b=[],_0x2192e6=_0x2efa8e(_0x2b2ae5(0x1b7))[_0x2b2ae5(0x1b4)](_0x2b2ae5(0x1c3))||null;_0x2192e6&&_0xc6799b[_0x2b2ae5(0x1cd)]({'quality':_0x2b2ae5(0x1ca),'download':()=>Promise[_0x2b2ae5(0x1d4)](_0x2192e6)});const _0x1f2561={'thumbnail':_0x210ef3,'duration':_0x4aacd0,'video':_0x48b6d3,'audio':_0xc6799b};return console[_0x2b2ae5(0x1c2)](_0x1f2561),FacebookDlSchema['parse'](_0x1f2561);}async function convert(_0x44c013,_0x3794f8,_0xba72a,_0x1232d0,_0x12fcef,_0x5c8cb1,_0x12aa14,_0x4dbfce,_0x3b30ee,_0x3a86fd,_0x268688,_0x31e78c){const _0x16d4e5=_0x51c1;return got[_0x16d4e5(0x1cc)](_0x44c013,{'form':{'ftype':_0xba72a,'v_id':_0x3794f8,'videoUrl':_0x1232d0,'videoType':_0x12fcef,'videoCodec':_0x5c8cb1,'audioUrl':_0x12aa14,'audioType':_0x4dbfce,'fquality':_0x3b30ee,'fname':_0x3a86fd,'exp':_0x268688,'token':_0x31e78c,'cv':'v2'}});}function _0x2082(){const _0xf28d74=['post','push','href','870pgaeVs','src','map','743MLgiMt','https://fdownloader.net/en','resolve','tbody\x20>\x20tr','exec','find','attr','1322004djwBIY','fdownloader.net','#audioUrl','51062SwKTdg','json','1334627XvxLve','236XSlttM','toArray','filter','Failed\x20to\x20extract\x20necessary\x20tokens.','table.table','123awqCVZ','543344wNLWmV','log','value','text','81ISFUND','76nCUnKZ','parse','https://fdownloader.net/','4089800ojBdrG','128kbps','trim'];_0x2082=function(){return _0xf28d74;};return _0x2082();}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
export { facebookdl, convert };
|