Create aio.js
Browse files
aio.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import btoa from "btoa";
|
| 2 |
+
import axios from "axios";
|
| 3 |
+
import ParseHtml from "html-dom-parser";
|
| 4 |
+
|
| 5 |
+
const form = new URLSearchParams();
|
| 6 |
+
|
| 7 |
+
const TARGET = {
|
| 8 |
+
baseUrl: "https://allinonevideosdownloader.com",
|
| 9 |
+
headers: {
|
| 10 |
+
"authority": "allinonevideosdownloader.com",
|
| 11 |
+
"accept": "*/*",
|
| 12 |
+
"accept-language": "en-US,en;q=0.9,id;q=0.8",
|
| 13 |
+
"content-type": "application/x-www-form-urlencoded",
|
| 14 |
+
"cookie": "pll_language=en; _gcl_au=1.1.1929855334.1773448777",
|
| 15 |
+
"origin": "https://allinonevideosdownloader.com",
|
| 16 |
+
"referer": "https://allinonevideosdownloader.com/",
|
| 17 |
+
"sec-ch-ua": "\"Not-A.Brand\";v=\"99\", \"Chromium\";v=\"124\"",
|
| 18 |
+
"sec-ch-ua-mobile": "?1",
|
| 19 |
+
"sec-ch-ua-platform": "\"Android\"",
|
| 20 |
+
"sec-fetch-dest": "empty",
|
| 21 |
+
"sec-fetch-mode": "cors",
|
| 22 |
+
"sec-fetch-site": "same-origin",
|
| 23 |
+
"user-agent": "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Mobile Safari/537.36"
|
| 24 |
+
}
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
async function findToken() {
|
| 28 |
+
const res = await axios.get(TARGET.baseUrl, {
|
| 29 |
+
headers: TARGET.headers
|
| 30 |
+
});
|
| 31 |
+
|
| 32 |
+
const dom = ParseHtml(res.data);
|
| 33 |
+
function walk(nodes) {
|
| 34 |
+
for (const node of nodes) {
|
| 35 |
+
if (node?.attribs?.name === "token") return node.attribs;
|
| 36 |
+
if (node?.children?.length) {
|
| 37 |
+
const found = walk(node.children);
|
| 38 |
+
if (found) return found;
|
| 39 |
+
}
|
| 40 |
+
}
|
| 41 |
+
}
|
| 42 |
+
const token = walk(dom);
|
| 43 |
+
if (!token) throw new Error("token not found");
|
| 44 |
+
return token;
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
async function aiodl(url) {
|
| 49 |
+
if (!url) throw "missing url input";
|
| 50 |
+
|
| 51 |
+
const token = await findToken();
|
| 52 |
+
const form = new URLSearchParams();
|
| 53 |
+
form.append("url", url);
|
| 54 |
+
form.append("token", token.value);
|
| 55 |
+
form.append("hash", btoa(url) + (url.length + 1000) + btoa("aio-dl"));
|
| 56 |
+
|
| 57 |
+
const res = await axios.post(
|
| 58 |
+
`${TARGET.baseUrl}/wp-json/aio-dl/video-data/`,
|
| 59 |
+
form,
|
| 60 |
+
{ headers: TARGET.headers }
|
| 61 |
+
).catch(e => e.response);
|
| 62 |
+
|
| 63 |
+
if (!res.data?.medias)
|
| 64 |
+
throw res.data?.message || res.data?.error || "failed retrieve data";
|
| 65 |
+
return res.data;
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
aiodl("https://www.facebook.com/share/r/1CRyWDZJxP/").then(d => console.log(d)).catch(console.log)
|