Update index.js
Browse files
index.js
CHANGED
|
@@ -10,6 +10,7 @@ const cp = require('child_process')
|
|
| 10 |
const os = require('os')
|
| 11 |
const cheerio = require('cheerio')
|
| 12 |
const cloudscraper = require('cloudscraper')
|
|
|
|
| 13 |
const { File } = require('megajs')
|
| 14 |
const { BingChat } = require("bing-chat-cjs-rnz");
|
| 15 |
let fetch;
|
|
@@ -32,6 +33,14 @@ const post = async (url, form, headers = {}) => {
|
|
| 32 |
return response;
|
| 33 |
};
|
| 34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
//RANDOM
|
| 36 |
function generateRandomUserAgent() {
|
| 37 |
const androidVersions = ['4.0.3', '4.1.1', '4.2.2', '4.3', '4.4', '5.0.2', '5.1', '6.0', '7.0', '8.0', '9.0', '10.0', '11.0', '12.0', '13.0'];
|
|
@@ -77,6 +86,24 @@ async function bingChat(text) {
|
|
| 77 |
const res = await api.sendMessage(text, { variant: 'Precise' })
|
| 78 |
return res?.text
|
| 79 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
|
| 81 |
// MEDIAFIRE DL
|
| 82 |
async function mediafire(url) {
|
|
@@ -462,54 +489,60 @@ app.all('/', async (req, res) => {
|
|
| 462 |
{
|
| 463 |
"title": "BING AI",
|
| 464 |
"method": "GET",
|
| 465 |
-
"example":
|
| 466 |
},
|
| 467 |
{
|
| 468 |
"title": "Facebook Downloader",
|
| 469 |
"method": "GET",
|
| 470 |
-
"example":
|
| 471 |
},
|
| 472 |
{
|
| 473 |
"title": "Instagram Downloader",
|
| 474 |
"method": "GET",
|
| 475 |
-
"example":
|
| 476 |
},
|
| 477 |
{
|
| 478 |
"title": "Mediafire Downloader",
|
| 479 |
"method": "GET",
|
| 480 |
-
"example":
|
| 481 |
},
|
| 482 |
{
|
| 483 |
"title": "Mega Downloader",
|
| 484 |
"method": "GET",
|
| 485 |
-
"example":
|
| 486 |
},
|
| 487 |
{
|
| 488 |
"title": "Pinterest Downloader",
|
| 489 |
"method": "GET",
|
| 490 |
-
"example":
|
| 491 |
},
|
| 492 |
{
|
| 493 |
"title": "Tiktok Downloader",
|
| 494 |
"method": "GET",
|
| 495 |
-
"example":
|
| 496 |
},
|
| 497 |
{
|
| 498 |
"title": "Twitter/X Downloader",
|
| 499 |
"method": "GET",
|
| 500 |
-
"example":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 501 |
},
|
| 502 |
{
|
| 503 |
"title": "Youtube Downloader",
|
| 504 |
"method": "GET",
|
| 505 |
-
"example":
|
| 506 |
},
|
| 507 |
{
|
| 508 |
"title": "Youtube Search",
|
| 509 |
"method": "GET",
|
| 510 |
-
"example":
|
| 511 |
}
|
| 512 |
]
|
|
|
|
| 513 |
});
|
| 514 |
});
|
| 515 |
|
|
@@ -621,6 +654,31 @@ app.get('/bing', async (req, res) => {
|
|
| 621 |
console.log(e);
|
| 622 |
return res.json({ message: e.message });
|
| 623 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 624 |
})
|
| 625 |
app.get('/ytsearch', async (req, res) => {
|
| 626 |
try {
|
|
|
|
| 10 |
const os = require('os')
|
| 11 |
const cheerio = require('cheerio')
|
| 12 |
const cloudscraper = require('cloudscraper')
|
| 13 |
+
const { acr } = require("acrcloud");
|
| 14 |
const { File } = require('megajs')
|
| 15 |
const { BingChat } = require("bing-chat-cjs-rnz");
|
| 16 |
let fetch;
|
|
|
|
| 33 |
return response;
|
| 34 |
};
|
| 35 |
|
| 36 |
+
// isURL
|
| 37 |
+
function isUrl(url) {
|
| 38 |
+
let regex = new RegExp(/(https?:\/\/)?(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,9}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/, 'gi');
|
| 39 |
+
if (!regex.test(url)) return false;
|
| 40 |
+
return url?.match(regex);
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
|
| 44 |
//RANDOM
|
| 45 |
function generateRandomUserAgent() {
|
| 46 |
const androidVersions = ['4.0.3', '4.1.1', '4.2.2', '4.3', '4.4', '5.0.2', '5.1', '6.0', '7.0', '8.0', '9.0', '10.0', '11.0', '12.0', '13.0'];
|
|
|
|
| 86 |
const res = await api.sendMessage(text, { variant: 'Precise' })
|
| 87 |
return res?.text
|
| 88 |
}
|
| 89 |
+
|
| 90 |
+
async function acrCloud(buffer) {
|
| 91 |
+
let { mime } = await (await import('file-type')).fileTypeFromBuffer(buffer);
|
| 92 |
+
if (/audio|video/.test(mime)) {
|
| 93 |
+
const wow = new acr({
|
| 94 |
+
host: "identify-ap-southeast-1.acrcloud.com",
|
| 95 |
+
access_key: "b1cc283b4fb72483ebb6ea9c53512331",
|
| 96 |
+
access_secret: "xyqJGTZRTrUotaraHEjji00WBClx7RpWozywdANq"
|
| 97 |
+
});
|
| 98 |
+
let { status, metadata } = await wow.identify(buffer);
|
| 99 |
+
if (status.code !== 0) throw new Error(status.msg);
|
| 100 |
+
//console.log(metadata.music[0])
|
| 101 |
+
return metadata.music[0];
|
| 102 |
+
} else {
|
| 103 |
+
throw new Error('Error: only audio/video files are supported');
|
| 104 |
+
}
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
|
| 108 |
// MEDIAFIRE DL
|
| 109 |
async function mediafire(url) {
|
|
|
|
| 489 |
{
|
| 490 |
"title": "BING AI",
|
| 491 |
"method": "GET",
|
| 492 |
+
"example": "${host}/bing?q="
|
| 493 |
},
|
| 494 |
{
|
| 495 |
"title": "Facebook Downloader",
|
| 496 |
"method": "GET",
|
| 497 |
+
"example": "${host}/fb?url="
|
| 498 |
},
|
| 499 |
{
|
| 500 |
"title": "Instagram Downloader",
|
| 501 |
"method": "GET",
|
| 502 |
+
"example": "${host}/ig?url="
|
| 503 |
},
|
| 504 |
{
|
| 505 |
"title": "Mediafire Downloader",
|
| 506 |
"method": "GET",
|
| 507 |
+
"example": "${host}/mediafire?url="
|
| 508 |
},
|
| 509 |
{
|
| 510 |
"title": "Mega Downloader",
|
| 511 |
"method": "GET",
|
| 512 |
+
"example": "${host}/mega?url="+ "${encodeURIComponent('url')}"
|
| 513 |
},
|
| 514 |
{
|
| 515 |
"title": "Pinterest Downloader",
|
| 516 |
"method": "GET",
|
| 517 |
+
"example": "${host}/pindl?url="
|
| 518 |
},
|
| 519 |
{
|
| 520 |
"title": "Tiktok Downloader",
|
| 521 |
"method": "GET",
|
| 522 |
+
"example": "${host}/tt?url="
|
| 523 |
},
|
| 524 |
{
|
| 525 |
"title": "Twitter/X Downloader",
|
| 526 |
"method": "GET",
|
| 527 |
+
"example": "${host}/twitter?url="
|
| 528 |
+
},
|
| 529 |
+
{
|
| 530 |
+
"title": "Whatmusic Search",
|
| 531 |
+
"method": "GET",
|
| 532 |
+
"example": "${host}/whatmusic?url="
|
| 533 |
},
|
| 534 |
{
|
| 535 |
"title": "Youtube Downloader",
|
| 536 |
"method": "GET",
|
| 537 |
+
"example": "${host}/ytdl?url="
|
| 538 |
},
|
| 539 |
{
|
| 540 |
"title": "Youtube Search",
|
| 541 |
"method": "GET",
|
| 542 |
+
"example": "${host}/ytsearch?q="
|
| 543 |
}
|
| 544 |
]
|
| 545 |
+
|
| 546 |
});
|
| 547 |
});
|
| 548 |
|
|
|
|
| 654 |
console.log(e);
|
| 655 |
return res.json({ message: e.message });
|
| 656 |
}
|
| 657 |
+
})
|
| 658 |
+
app.get('/whatmusic', async (req, res) => {
|
| 659 |
+
try {
|
| 660 |
+
let { url } = req.query
|
| 661 |
+
async function downloadBuffer(url) {
|
| 662 |
+
try {
|
| 663 |
+
const response = await axios({
|
| 664 |
+
method: 'get',
|
| 665 |
+
url: url,
|
| 666 |
+
responseType: 'arraybuffer'
|
| 667 |
+
});
|
| 668 |
+
return Buffer.from(response.data, 'binary');
|
| 669 |
+
} catch (error) {
|
| 670 |
+
throw new Error(`Failed to download the file: ${error.message}`);
|
| 671 |
+
}
|
| 672 |
+
}
|
| 673 |
+
if (!url) return res.json({ message: 'Input parameter url' });
|
| 674 |
+
if (!isUrl(url)) return res.json({ message: 'Invalit Input Link' })
|
| 675 |
+
let data = await acrCloud(await downloadBuffer(isUrl(url)[0]))
|
| 676 |
+
if (!data) return res.json({ error: 'Error:v'})
|
| 677 |
+
return res.json(data);
|
| 678 |
+
} catch (e) {
|
| 679 |
+
console.log(e);
|
| 680 |
+
return res.json({ message: e.message });
|
| 681 |
+
}
|
| 682 |
})
|
| 683 |
app.get('/ytsearch', async (req, res) => {
|
| 684 |
try {
|