Update index.js
Browse files
index.js
CHANGED
|
@@ -24,6 +24,52 @@ const post = async (url, form, headers = {}) => {
|
|
| 24 |
return response;
|
| 25 |
};
|
| 26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
//FBDL
|
| 29 |
async function fby2mate(url) {
|
|
@@ -321,10 +367,22 @@ const app = express()
|
|
| 321 |
if (!result) return res.json({ message: 'Error: can\'t download' });
|
| 322 |
res.redirect(await result.download());
|
| 323 |
} catch (e) {
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
|
| 327 |
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 328 |
.get('/tt', async (req, res) => {
|
| 329 |
try {
|
| 330 |
let { url } = req.query
|
|
@@ -332,14 +390,11 @@ const app = express()
|
|
| 332 |
if (!regex.test(url)) return res.json({ message: 'Invalid URL' });
|
| 333 |
let data = await fetch(`https://tikwm.com/api/?url=` + url)
|
| 334 |
data = await data.json()
|
| 335 |
-
console.log(data)
|
| 336 |
if (!data) return res.json({ message: 'API TO API KOID:v' });
|
| 337 |
-
return res.json(
|
| 338 |
-
result: await data
|
| 339 |
-
})
|
| 340 |
} catch (e) {
|
| 341 |
console.log(e);
|
| 342 |
-
res.json({ message: e });
|
| 343 |
}
|
| 344 |
})
|
| 345 |
.get('/pindl', async (req, res) => {
|
|
@@ -350,12 +405,10 @@ const app = express()
|
|
| 350 |
let data = await fetch(`https://pinterestdownloader.io/id/frontendService/DownloaderService?url=` + url)
|
| 351 |
data = await data.json()
|
| 352 |
if (!data) return res.json({ message: 'API TO API KOID:v' });
|
| 353 |
-
return res.json(
|
| 354 |
-
result: data
|
| 355 |
-
})
|
| 356 |
} catch (e) {
|
| 357 |
console.log(e);
|
| 358 |
-
res.json({ message: e });
|
| 359 |
}
|
| 360 |
})
|
| 361 |
.get('/fb', async (req, res) => {
|
|
@@ -364,13 +417,11 @@ const app = express()
|
|
| 364 |
let regex = /https?:\/\/(fb\.watch|(www\.|web\.|m\.)?facebook\.com)/;
|
| 365 |
if (!regex.test(url)) return res.json({ message: 'Invalid URL' });
|
| 366 |
let data = await fby2mate(url)
|
| 367 |
-
return res.json(
|
| 368 |
-
result:data
|
| 369 |
-
})
|
| 370 |
} catch (e) {
|
| 371 |
-
|
| 372 |
-
res.json({ message: e });
|
| 373 |
-
|
| 374 |
})
|
| 375 |
.get('/ytsearch', async (req, res) => {
|
| 376 |
try {
|
|
@@ -378,10 +429,10 @@ const app = express()
|
|
| 378 |
if (!q) return res.json({ message: 'Input parameter q' });
|
| 379 |
let data = await yts(q);
|
| 380 |
if (!data.all[0]) return res.json({ message: 'Not found' });
|
| 381 |
-
res.json(data.all);
|
| 382 |
} catch (e) {
|
| 383 |
console.log(e);
|
| 384 |
-
res.json({ message: e });
|
| 385 |
}
|
| 386 |
})
|
| 387 |
.get('/ytdl', async (req, res) => {
|
|
@@ -396,7 +447,7 @@ const app = express()
|
|
| 396 |
})
|
| 397 |
} catch (e) {
|
| 398 |
console.log(e);
|
| 399 |
-
res.json({ message: e });
|
| 400 |
}
|
| 401 |
})
|
| 402 |
.listen(7860, () => console.log('App running on port 7860'));
|
|
|
|
| 24 |
return response;
|
| 25 |
};
|
| 26 |
|
| 27 |
+
//INDOWN
|
| 28 |
+
async function igdl(url) {
|
| 29 |
+
let res = await axios("https://indown.io/")
|
| 30 |
+
let _$ = cheerio.load(res.data)
|
| 31 |
+
let referer = _$("input[name=referer]").val()
|
| 32 |
+
let locale = _$("input[name=locale]").val()
|
| 33 |
+
let _token = _$("input[name=_token]").val()
|
| 34 |
+
let {
|
| 35 |
+
data
|
| 36 |
+
} = await axios.post(
|
| 37 |
+
"https://indown.io/download",
|
| 38 |
+
new URLSearchParams({
|
| 39 |
+
link: url,
|
| 40 |
+
referer,
|
| 41 |
+
locale,
|
| 42 |
+
_token,
|
| 43 |
+
}),
|
| 44 |
+
{
|
| 45 |
+
headers: {
|
| 46 |
+
cookie: res.headers["set-cookie"].join(" "),
|
| 47 |
+
},
|
| 48 |
+
}
|
| 49 |
+
)
|
| 50 |
+
let $ = cheerio.load(data)
|
| 51 |
+
let result = []
|
| 52 |
+
let __$ = cheerio.load($("#result").html())
|
| 53 |
+
__$("video").each(function () {
|
| 54 |
+
let $$ = $(this)
|
| 55 |
+
result.push({
|
| 56 |
+
author: creator,
|
| 57 |
+
type: "video",
|
| 58 |
+
thumbnail: $$.attr("poster"),
|
| 59 |
+
url: $$.find("source").attr("src"),
|
| 60 |
+
})
|
| 61 |
+
})
|
| 62 |
+
__$("img").each(function () {
|
| 63 |
+
let $$ = $(this)
|
| 64 |
+
result.push({
|
| 65 |
+
author: creator,
|
| 66 |
+
type: "image",
|
| 67 |
+
url: $$.attr("src"),
|
| 68 |
+
})
|
| 69 |
+
})
|
| 70 |
+
|
| 71 |
+
return result
|
| 72 |
+
}
|
| 73 |
|
| 74 |
//FBDL
|
| 75 |
async function fby2mate(url) {
|
|
|
|
| 367 |
if (!result) return res.json({ message: 'Error: can\'t download' });
|
| 368 |
res.redirect(await result.download());
|
| 369 |
} catch (e) {
|
| 370 |
+
console.log(e);
|
| 371 |
+
return res.json({ message: e });
|
| 372 |
+
}
|
| 373 |
})
|
| 374 |
+
.get('/ig', async (req,res) => {
|
| 375 |
+
try {
|
| 376 |
+
let {url} = req.query
|
| 377 |
+
let regex = /https?:\/\/(www\.)?instagram\.com\/(p|reel|tv)/;
|
| 378 |
+
if (!regex.test(url)) return res.json({ message: 'Invalid URL' });
|
| 379 |
+
let data = await igdl(url)
|
| 380 |
+
return res.json(data)
|
| 381 |
+
} catch (e) {
|
| 382 |
+
console.log(e);
|
| 383 |
+
return res.json({ message: e });
|
| 384 |
+
}
|
| 385 |
+
})
|
| 386 |
.get('/tt', async (req, res) => {
|
| 387 |
try {
|
| 388 |
let { url } = req.query
|
|
|
|
| 390 |
if (!regex.test(url)) return res.json({ message: 'Invalid URL' });
|
| 391 |
let data = await fetch(`https://tikwm.com/api/?url=` + url)
|
| 392 |
data = await data.json()
|
|
|
|
| 393 |
if (!data) return res.json({ message: 'API TO API KOID:v' });
|
| 394 |
+
return res.json(data)
|
|
|
|
|
|
|
| 395 |
} catch (e) {
|
| 396 |
console.log(e);
|
| 397 |
+
return res.json({ message: e });
|
| 398 |
}
|
| 399 |
})
|
| 400 |
.get('/pindl', async (req, res) => {
|
|
|
|
| 405 |
let data = await fetch(`https://pinterestdownloader.io/id/frontendService/DownloaderService?url=` + url)
|
| 406 |
data = await data.json()
|
| 407 |
if (!data) return res.json({ message: 'API TO API KOID:v' });
|
| 408 |
+
return res.json(data)
|
|
|
|
|
|
|
| 409 |
} catch (e) {
|
| 410 |
console.log(e);
|
| 411 |
+
return res.json({ message: e });
|
| 412 |
}
|
| 413 |
})
|
| 414 |
.get('/fb', async (req, res) => {
|
|
|
|
| 417 |
let regex = /https?:\/\/(fb\.watch|(www\.|web\.|m\.)?facebook\.com)/;
|
| 418 |
if (!regex.test(url)) return res.json({ message: 'Invalid URL' });
|
| 419 |
let data = await fby2mate(url)
|
| 420 |
+
return res.json(data)
|
|
|
|
|
|
|
| 421 |
} catch (e) {
|
| 422 |
+
console.log(e);
|
| 423 |
+
return res.json({ message: e });
|
| 424 |
+
}
|
| 425 |
})
|
| 426 |
.get('/ytsearch', async (req, res) => {
|
| 427 |
try {
|
|
|
|
| 429 |
if (!q) return res.json({ message: 'Input parameter q' });
|
| 430 |
let data = await yts(q);
|
| 431 |
if (!data.all[0]) return res.json({ message: 'Not found' });
|
| 432 |
+
return res.json(data.all);
|
| 433 |
} catch (e) {
|
| 434 |
console.log(e);
|
| 435 |
+
return res.json({ message: e });
|
| 436 |
}
|
| 437 |
})
|
| 438 |
.get('/ytdl', async (req, res) => {
|
|
|
|
| 447 |
})
|
| 448 |
} catch (e) {
|
| 449 |
console.log(e);
|
| 450 |
+
return res.json({ message: e });
|
| 451 |
}
|
| 452 |
})
|
| 453 |
.listen(7860, () => console.log('App running on port 7860'));
|