File size: 25,872 Bytes
8c38b3e 7f6be0b 0f4da65 06c148c 450f783 0940a53 6e83753 e388521 a83d66e 7f6be0b ea98ff4 78bfdd6 1ccb9cc 5604b18 6e83753 5604b18 7f6be0b 5604b18 dfd3b4a 8c38b3e e5b6783 9198234 8c38b3e 7f6be0b 8c38b3e d6fe02a 3622ac0 7f6be0b d6fe02a 22bc910 7f6be0b 22bc910 7f6be0b 22bc910 e16dfa7 7f6be0b 2b8555d 7f6be0b 2b8555d 7f6be0b 2b8555d 7f6be0b e16dfa7 1e3e538 7f6be0b 1e3e538 00fa158 d6fe02a 7f6be0b d6fe02a 64a5388 7f6be0b 64a5388 6c34e60 7f6be0b 6c34e60 18cd92f 450f783 7f6be0b 450f783 7f6be0b 450f783 601b94a 1ccb9cc 601b94a 1ccb9cc 160d2b5 0d916db 8c38b3e 9198234 7f6be0b 8c38b3e 7f6be0b 8c38b3e 9198234 8c38b3e 7f6be0b 22bc910 7f6be0b 8c38b3e 7f6be0b 8c38b3e 7f6be0b 8c38b3e 9198234 044bf4f ac7b6ab 7f6be0b ac7b6ab 7f6be0b ac7b6ab 7f6be0b b4a8dd2 7f6be0b ac7b6ab 044bf4f 7f6be0b b4a8dd2 35c1109 a679f78 57fcac4 35c1109 85d4f6b 7f1a662 d6fe02a 7f1a662 0940a53 7f1a662 8227301 7f1a662 7f6be0b 7f1a662 7f6be0b 7f1a662 7f6be0b 7f1a662 7f6be0b 798405b 7f6be0b 85d4f6b 7f6be0b d6fe02a 7f6be0b 044bf4f 85d4f6b 7f6be0b 85d4f6b 7f6be0b 85d4f6b 9f5c833 85d4f6b 7f6be0b 85d4f6b 7f6be0b 85d4f6b 7f6be0b 85d4f6b 7f6be0b 85d4f6b 7f6be0b 2ce3791 7f6be0b 2ce3791 7f6be0b e01a88d 7f6be0b 85d4f6b 7f6be0b 85d4f6b ca43b93 07c0ae2 ca43b93 07c0ae2 ca43b93 85d4f6b 7f6be0b 85d4f6b 0ba6e87 601b94a 0ba6e87 601b94a 0ba6e87 85d4f6b 7f6be0b 85d4f6b 7f6be0b 85d4f6b 7f6be0b 85d4f6b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 |
const yts = require('yt-search');
const morgan = require('morgan');
const express = require('express');
const ytdl = require('ytdl-core');
const { Writable, pipeline } = require('stream');
const util = require('util');
const axios = require('axios');
const FormData = require('form-data')
const cp = require('child_process')
const os = require('os')
const cheerio = require('cheerio')
const cloudscraper = require('cloudscraper')
const acrcloud = require("acrcloud");
const { File } = require('megajs')
const { BingChat } = require("bing-chat-cjs-rnz");
const path = require("path")
const fs = require("fs")
const ytdlp = require('yt-dlp-exec');
let fetch;
(async () => {
fetch = (await import('node-fetch')).default;
})();
// Regex untuk mengidentifikasi URL YouTube dan Mega
const ytIdRegex = /(?:https?:\/\/)?(?:www\.|music\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=|shorts\/|user\/\S+\/\S+\/)|youtu\.be\/)([\w-]{11})/;
// Fungsi untuk melakukan HTTP POST request
const post = async (url, form, headers = {}) => {
const response = await fetch(url, {
method: 'post',
body: new URLSearchParams(form),
headers
});
return response;
};
// isURL
function isUrl(url) {
let regex = new RegExp(/(https?:\/\/)?(www\.)?[-a-zA-Z0-9@:%.+~#=]{1,256}\.[a-zA-Z0-9()]{1,9}\b([-a-zA-Z0-9()@:%+.~#?&//=]*)/, 'gi');
if (!regex.test(url)) return false;
return url?.match(regex);
}
//RANDOM
function generateRandomUserAgent() {
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'];
const deviceModels = ['M2004J19C', 'S2020X3', 'Xiaomi4S', 'RedmiNote9', 'SamsungS21', 'GooglePixel5', 'iPhone13,4', 'SM-A526B', 'SM-G991B', 'SM-G998B', 'iPhone13,2', 'iPhone13,3', 'iPhone13,1', 'SM-G996B', 'SM-G970F'];
const buildVersions = ['RP1A.200720.011', 'RP1A.210505.003', 'RP1A.210812.016', 'QKQ1.200114.002', 'RQ2A.210505.003', 'RQ3A.211001.001', 'SD1A.210817.036', 'T825YDXU3CTK1', 'QKQ1.191014.012', 'QKQ1.190918.001', 'QKQ1.190626.002', 'QKQ1.190716.003', 'QKQ1.190626.002', 'QKQ1.190626.002', 'QKQ1.190626.002'];
const browsers = ['Chrome', 'Firefox', 'Safari', 'Edge', 'Opera'];
const getRandomElement = (arr) => arr[Math.floor(Math.random() * arr.length)];
const getRandomNumber = (max) => Math.floor(Math.random() * max) + 1;
const selectedModel = getRandomElement(deviceModels);
const selectedBuild = getRandomElement(buildVersions);
const selectedBrowser = getRandomElement(browsers);
const browserVersion = `${selectedBrowser}/${getRandomNumber(96)}.${getRandomNumber(999)}.${getRandomNumber(9999)}.${getRandomNumber(99)}`;
const userAgent = `Mozilla/5.0 (Linux; Android ${getRandomElement(androidVersions)}; ${selectedModel} Build/${selectedBuild}) AppleWebKit/537.36 (KHTML, like Gecko) ${browserVersion} Mobile Safari/537.36`;
return userAgent;
}
function generateRandomIP() {
return Array(4)
.fill(0)
.map(() => Math.floor(Math.random() * 256))
.join('.');
}
//BIMG
async function bimg(query) {
const { BingApi } = await import("bing-nodejs");
const bing = new BingApi({
cookie: process.env.BING_IMAGE_COOKIE
});
let data = await bing.createImage(query).then((res) => {
return res.urls; // string[]
});
// Filter out links that end with '.svg'
let filteredData = data.filter(i => !i.includes('.svg'));
return filteredData
}
async function bingChat(text) {
const api = new BingChat({
cookie: process.env.BING_IMAGE_COOKIE
})
const res = await api.sendMessage(text, { variant: 'Precise' })
return res?.text
}
async function acrCloud(buffer) {
let { mime } = await (await import('file-type')).fileTypeFromBuffer(buffer);
if (/audio|video/.test(mime)) {
const wow = new acrcloud({
host: "identify-ap-southeast-1.acrcloud.com",
access_key: "b1cc283b4fb72483ebb6ea9c53512331",
access_secret: "xyqJGTZRTrUotaraHEjji00WBClx7RpWozywdANq"
});
let { status, metadata } = await wow.identify(buffer);
if (status.code !== 0) throw new Error(status.msg);
//console.log(metadata.music[0])
return metadata.music[0];
} else {
throw new Error('Error: only audio/video files are supported');
}
}
// MEDIAFIRE DL
async function mediafire(url) {
return new Promise(async (resolve, reject) => {
var a, b;
if (!/https?:\/\/(www\.)?mediafire.com/.test(url)) return resolve();
try {
const data = await axios.get(url, {
headers: {
'User-Agent': generateRandomUserAgent(),
'X-Forwarded-For': generateRandomIP(),
}
});
if (!data) {
resolve();
} else {
const $ = cheerio.load(data.data);
const Url = ($('#downloadButton').attr('href') || '').trim();
const url2 = ($('#download_link > a.retry').attr('href') || '').trim();
const $intro = $('div.dl-info > div.intro');
const filename = $intro.find('div.filename').text().trim();
const filetype = $intro.find('div.filetype > span').eq(0).text().trim();
const ext = ((b = (a = /(.+?)\s*(?:\(|$)/.exec($intro.find('div.filetype > span').eq(1).text())) === null || a === void 0 ? void 0 : a[1]) === null || b === void 0 ? void 0 : b.trim()) || 'bin';
const $li = $('div.dl-info > ul.details > li');
const upload_date = $li.eq(1).find('span').text().trim();
const filesize = $li.eq(0).find('span').text().trim();
const filesizeB = formatSize(filesize);
const result = {
url: Url || url2,
url2,
filename,
filetype,
ext,
upload_date,
filesize,
filesizeB
};
resolve(result);
}
} catch (error) {
reject(error);
}
});
}
//SAVEIG
async function igdl(query) {
url_dl = [];
let headers = {
'Accept': '/',
'Accept-Language': 'en-US,en;q=0.9',
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'Referer': 'https://saveig.app/',
'Referrer-Policy': 'strict-origin-when-cross-origin',
'X-Requested-With': 'XMLHttpRequest'
}
let options = {
method: 'POST',
uri: 'https://saveig.app/api/ajaxSearch',
headers: headers,
formData: {
q: query
}
}
ch = cheerio.load(JSON.parse(await cloudscraper(options)).data);
ch('.download-items__btn').each(function(a,b) { url_dl.push(ch(b).find('a').attr('href'))})
return url_dl;
}
//FBDL
async function fby2mate(url) {
try {
let form = new FormData();
form.append('q', url);
form.append('vt', 'facebook');
let data = await fetch('https://y2mate.mx/api/ajaxSearch/facebook', {
method: 'POST',
body: form,
headers: {
'User-Agent': generateRandomUserAgent(),
'X-Forwarded-For': generateRandomIP(),
...form.getHeaders()
}
});
data = await data.json();
return data;
} catch (e) {
return e;
}
}
async function ytAPI(url) {
try {
// Fetch the video info
const info = await ytdlp.getInfo(url);
// Extract necessary information
const videoDetails = {
title: info.title,
url: url,
formats: info.formats.map(format => ({
format_id: format.format_id,
ext: format.ext,
resolution: format.resolution,
url: format.url
}))
};
// Filter MP4 and MP3 formats
const mp4Format = videoDetails.formats.find(format => format.ext === 'mp4');
const mp3Format = videoDetails.formats.find(format => format.ext === 'mp3');
const result = {
title: videoDetails.title,
url: videoDetails.url,
mp4Url: mp4Format ? mp4Format.url : null,
mp3Url: mp3Format ? mp3Format.url : null
};
return result;
} catch (error) {
console.error('Error fetching video info:', error);
throw error;
}
}
// Fungsi untuk mengkonversi video dari YouTube
const convert = async (url, v_id, ftype, fquality, fname, token, timeExpire) => {
let params = {
v_id,
ftype,
fquality,
fname,
token,
timeExpire,
client: 'yt5s.com'
};
// Mengirim permintaan konversi
let resServer = await (await post(url, params, { 'x-requested-key': 'de0cfuirtgf67a' })).json();
let server = resServer.c_server;
// Jika tidak ada server dan tipe file adalah mp3, kembalikan null
if (!server && ftype === 'mp3') return server || resServer.d_url || '';
// Mengambil data hasil konversi
let data = await (await post(`${server}/api/json/convert`, params)).json();
let result;
// Memeriksa status kode hasil konversi
if (data.statusCode === 200) result = data.result;
while (!result) {
let json = await (await post(`${server}/api/json/convert`, params)).json();
if (json.statusCode === 200) {
result = json.result;
break;
}
await new Promise(resolve => setTimeout(resolve, 2000));
}
return result;
};
// Fungsi untuk mendownload video dari YouTube
const youtubedl = async (url) => {
let html = await (await fetch('https://yt5s.com/en32', {headers: {
'User-Agent': generateRandomUserAgent(),
'X-Forwarded-For': generateRandomIP(),
}})).text();
let urlAjax = (html.match(/k_url_search="(.?)"/) || [])[1];
let urlConvert = (html.match(/k_url_convert="(.?)"/) || [])[1];
let json = await (await post(urlAjax, { q: url, vt: 'home' })).json();
let video = {}, audio = {};
if (!json?.links) throw json.mess;
Object.values(json.links.mp4).map(({ k, size }) => video[k] = {
quality: k,
fileSizeH: size,
fileSize: parseFloat(size) * (/MB$/.test(size) ? 1000 : 1),
download: convert.bind(null, urlConvert, json.vid, 'mp4', k, json.fn, json.token, parseInt(json.timeExpires))
});
Object.values(json.links.mp3).map(({ key, size }) => audio[key] = {
quality: key,
fileSizeH: size,
fileSize: parseFloat(size) * (/MB$/.test(size) ? 1000 : 1),
download: convert.bind(null, urlConvert, json.vid, 'mp3', key.replace(/kbps/i, ''), json.fn, json.token, parseInt(json.timeExpires))
});
return {
id: json.vid,
title: json.title,
thumbnail: `https://i.ytimg.com/vi/${json.vid}/0.jpg`,
video,
audio
};
};
//TWITTER API
async function twitterDL(url) {
try {
let form = new FormData();
form.append('q', url);
form.append('lang', 'en');
let response = await fetch('https://x2twitter.com/api/ajaxSearch', {
method: 'POST',
body: form,
headers: {
'User-Agent': generateRandomUserAgent(),
'X-Forwarded-For': generateRandomIP(),
...form.getHeaders()
}
});
let data = await response.json();
const $ = cheerio.load(data?.data);
let downloads = [];
$('.dl-action a').each((index, element) => {
const format = $(element).text().trim();
const url = $(element).attr('href');
if (url !== '#') {
downloads.push({ format, url });
}
});
// Jika tidak ada unduhan dari load pertama, coba load kedua
if (downloads.length === 0) {
$('a').each((index, element) => {
const href = $(element).attr('href');
if (href && href !== '/' && href !== '#') {
downloads.push(href);
}
});
}
return { downloads };
} catch (error) {
return error;
}
}
async function ytDEEL(url) {
const { v4: uuidv4 } = require('uuid');
const theme = encodeURIComponent('system');
const apiUrl = `https://gradio-blocks-youtube-downloader.hf.space/queue/join?__theme=${theme}`;
const mp3UploadId = uuidv4(); // Gunakan UUID yang berbeda untuk MP3
const mp4UploadId = Math.random().toString(36).substring(2); // Gunakan UUID yang berbeda untuk MP4
const mp3PostData = {
data: [url, false],
event_data: null,
fn_index: 0,
session_hash: mp3UploadId, // Gunakan mp3UploadId untuk MP3
trigger_id: 10
};
const mp4PostData = {
data: [url, true],
event_data: null,
fn_index: 0,
session_hash: mp4UploadId, // Gunakan mp4UploadId untuk MP4
trigger_id: 10
};
try {
// Kirim permintaan MP3
const mp3Response = await axios.post(apiUrl, mp3PostData, { headers: { 'Content-Type': 'application/json', 'Accept': '*/*' } });
const mp3EventId = mp3Response.data.event_id;
// Tunggu respons MP3
let mp3Url;
let mp3Completed = false;
const mp3StatusUrl = `https://gradio-blocks-youtube-downloader.hf.space/queue/data?session_hash=${mp3UploadId}`;
while (!mp3Completed) {
const statusResponse = await axios.get(mp3StatusUrl, { headers: { 'Accept': 'text/event-stream' }, responseType: 'text' });
const rawData = statusResponse.data.trim().split('\n').map(line => line.replace(/^data: /, ''));
for (const line of rawData) {
try {
const event = JSON.parse(line);
if (event.msg === 'process_completed') {
if (event.event_id === mp3EventId && !mp3Completed) {
mp3Url = event?.output?.data[1]?.value?.url;
mp3Completed = true;
}
}
} catch (e) {}
}
await new Promise(resolve => setTimeout(resolve, 5000));
}
// Kirim permintaan MP4
const mp4Response = await axios.post(apiUrl, mp4PostData, { headers: { 'Content-Type': 'application/json', 'Accept': '*/*' } });
const mp4EventId = mp4Response.data.event_id;
// Tunggu respons MP4
let mp4Url;
let mp4Completed = false;
const mp4StatusUrl = `https://gradio-blocks-youtube-downloader.hf.space/queue/data?session_hash=${mp4UploadId}`;
while (!mp4Completed) {
const statusResponse = await axios.get(mp4StatusUrl, { headers: { 'Accept': 'text/event-stream' }, responseType: 'text' });
const rawData = statusResponse.data.trim().split('\n').map(line => line.replace(/^data: /, ''));
for (const line of rawData) {
try {
const event = JSON.parse(line);
if (event.msg === 'process_completed') {
if (event.event_id === mp4EventId && !mp4Completed) {
mp4Url = event?.output?.data[0]?.value?.url;
mp4Completed = true;
}
}
} catch (e) {}
}
await new Promise(resolve => setTimeout(resolve, 5000));
}
const result = { mp3: mp3Url.replace(/\s/g, '%20'), mp4: mp4Url.replace(/\s/g, '%20') };
return result
} catch (error) {
throw error;
}
}
const app = express()
.set('json spaces', 4)
.use(morgan('dev'))
.use(express.json())
.all('/', async (req, res) => {
const v8 = require('v8'); // Menempatkan ini di dalam handler agar tidak dijalankan saat server dimulai
const status = {};
status['diskUsage'] = cp.execSync('du -sh').toString().split('M')[0] + ' MB';
const used = process.memoryUsage();
for (let x in used) status[x] = formatSize(used[x]);
const totalmem = os.totalmem();
const freemem = os.freemem();
status['memoryUsage'] = `${formatSize(totalmem - freemem)} / ${formatSize(totalmem)}`;
// Menambahkan statistik heap V8
const heapStats = v8.getHeapStatistics();
for (let x in heapStats) status[x] = formatSize(heapStats[x]);
// Menambahkan semua properti dan metode dari v8
for (let x in v8) {
if (typeof v8[x] !== 'function') {
status[x] = v8[x];
}
}
const host = 'https://' + req.get('host');
res.json({
creator: `@${process.env['SPACE_AUTHOR_NAME'] || 'ALOK FF'}`,
message: 'Hello World!',
uptime: new Date(process.uptime() * 1000).toUTCString().split(' ')[4],
status, // Menambahkan latency ke JSON
list: [
{
title: "BING AI",
method: "GET",
example: `${host}/bing?q=`
},
{
title: "Facebook Downloader",
method: "GET",
example: `${host}/fb?url=`
},
{
title: "Instagram Downloader",
method: "GET",
example: `${host}/ig?url=`
},
{
title: "Mediafire Downloader",
method: "GET",
example: `${host}/mediafire?url=`
},
{
title: "Mega Downloader",
method: "GET",
example: `${host}/mega?url=${encodeURIComponent('url')}`
},
{
title: "Pinterest Downloader",
method: "GET",
example: `${host}/pindl?url=`
},
{
title: "Tiktok Downloader",
method: "GET",
example: `${host}/tt?url=`
},
{
title: "Twitter/X Downloader",
method: "GET",
example: `${host}/twitter?url=`
},
{
title: "Whatmusic Search",
method: "GET",
example: `${host}/whatmusic?url=`
},
{
title: "Youtube Downloader",
method: "GET",
example: `${host}/ytdl?url=`
},
{
title: "Youtube Search",
method: "GET",
example: `${host}/ytsearch?q=`
}
]
})})
.get('/yt', async (req, res) => {
const host = 'https://' + req.get('host');
try {
let { url, type, quality, json } = req.query;
if (!ytIdRegex.test(url)) return res.json({ message: 'Invalid URL' });
if (!!json) {
let ytId = ytIdRegex.exec(url)?.[1];
if (!ytId) return res.json({ message: 'No video id found' });
let data = await yts({ videoId: ytId });
const downloadUrls = {
audio: `${host}/yt?url=${url}&type=audio&quality=128kbps`,
video: `${host}/yt?url=${url}&type=video&quality=`,
};
return res.json({
...data,
download: downloadUrls
});
}
if (!type || !/audio|video/i.test(type)) type = 'video';
let data = await youtubedl(url).catch(e => console.log(e));
if (!data) return res.json({ message: 'Error: link download not found' });
type = type.toLowerCase();
let result = quality ? Object.values(data[type]).find(x => x.quality == quality) : Object.values(data[type])[0];
if (quality && !result) return res.json({ message: `Invalid quality: ${quality}, available quality (${Object.keys(data[type]).join('/')})` });
if (!result) return res.json({ message: 'Error: can\'t download' });
res.redirect(await result.download());
} catch (e) {
console.log(e);
return res.json({ message: e.message });
}
})
.get('/ig', async (req,res) => {
try {
let {url} = req.query
let regex = /https?:\/\/(www\.)?instagram\.com\/(p|reel|tv)\/[a-zA-Z0-9_-]+\/?/;
if (!regex.test(url)) return res.json({ message: 'Invalid URL' });
let data = await igdl(url)
return res.json(data)
} catch (e) {
console.log(e);
return res.json({ message: e.message });
}
})
.get('/tt', async (req, res) => {
try {
let { url } = req.query
let regex = /https?:\/\/(www\.)?(tiktok\.com|vt\.tiktok\.com|v\.tiktok\.com|t\.tiktok\.com)/;
if (!regex.test(url)) return res.json({ message: 'Invalid URL' });
let data = await fetch(`https://tikwm.com/api/?url=${url}`, {
headers: {
'User-Agent': generateRandomUserAgent(),
'X-Forwarded-For': generateRandomIP(),
}
});
data = await data.json();
if (!data) return res.json({ message: 'API TO API KOID' });
return res.json(data);
} catch (e) {
console.log(e);
return res.json({ message: e.message });
}
})
.get('/pindl', async (req, res) => {
try {
let { url } = req.query
let regex = /https:\/\/pin\.it\/\w+|https:\/\/[a-z]{2}\.pinterest\.com\/pin\/\d+/;
if (!regex.test(url)) return res.json({ message: 'Invalid URL' });
let data = await fetch(`https://pinterestdownloader.io/id/frontendService/DownloaderService?url=${url}`, {
headers: {
'User-Agent': generateRandomUserAgent(),
'X-Forwarded-For': generateRandomIP(),
}
});
data = await data.json();
if (!data) return res.json({ message: 'API TO API KOID' });
return res.json(data);
} catch (e) {
console.log(e);
return res.json({ message: e.message });
}
})
.get('/fb', async (req, res) => {
try {
let {url} = req.query
let regex = /https?:\/\/(fb\.watch|(www\.|web\.|m\.)?facebook\.com)/;
if (!regex.test(url)) return res.json({ message: 'Invalid URL' });
let data = await fby2mate(url)
return res.json(data)
} catch (e) {
console.log(e);
return res.json({ message: e.message });
}
})
.get('/bimg', async (req, res) => {
try {
let q = req.query.q || req.query.query;
if (!q) return res.json({ message: 'Input parameter q' });
let data = await bimg(q)
return res.json({query: q, data: data})
} catch (e) {
console.log(e);
return res.json({ message: e.message });
}
})
.get('/bing', async (req, res) => {
try {
let q = req.query.q || req.query.query;
if (!q) return res.json({ message: 'Input parameter q' });
let data = await bingChat(q)
if (data.length === 0) {
async function gpt4o(prompt) {
let session_hash = Math.random().toString(36).substring(2);
try {
let resPrompt = await axios.post('https://kingnish-opengpt-4o.hf.space/run/predict?__theme=light', {
"data": [{
"text": prompt,
"files": []
}],
"event_data": null,
"fn_index": 3,
"trigger_id": 34,
"session_hash": session_hash
});
let res = await axios.post('https://kingnish-opengpt-4o.hf.space/queue/join?__theme=light', {
"data": [
null,
null,
"idefics2-8b-chatty",
"Top P Sampling",
0.5,
4096,
1,
0.9,
true
],
"event_data": null,
"fn_index": 5,
"trigger_id": 34,
"session_hash": session_hash
});
let event_ID = res.data.event_id;
let anu = await axios.get('https://kingnish-opengpt-4o.hf.space/queue/data?session_hash=' + session_hash);
const lines = anu.data.split('\n');
const processStartsLine = lines.find(line => line.includes('process_completed'));
if (processStartsLine) {
const processStartsData = JSON.parse(processStartsLine.replace('data: ', ''));
let ress = processStartsData.output.data;
let result = ress[0][0][1];
return result;
} else {
return 'error kang!';
}
} catch (error) {
console.error(error);
return 'error kang!';
}
}
data = await gpt4o(q)
//return res.json({message: 'Terkena Chaptcha BOT!!!'})
}
return res.json({result
})
} catch (e) {
console.log(e);
return res.json({ message: e.message });
}
})
.get('/whatmusic', async (req, res) => {
try {
let { url } = req.query
async function downloadBuffer(url) {
try {
const response = await axios({
method: 'get',
url: url,
responseType: 'arraybuffer'
});
return Buffer.from(response.data, 'binary');
} catch (error) {
throw new Error(`Failed to download the file: ${error.message}`);
}
}
if (!url) return res.json({ message: 'Input parameter url' });
if (!isUrl(url)) return res.json({ message: 'Invalit Input Link' })
let data = await acrCloud(await downloadBuffer(isUrl(url)[0]))
if (!data) return res.json({ error: 'Error'});
return res.json(data);
} catch (e) {
console.log(e);
return res.json({ message: e.message });
}
})
.get('/ytsearch', async (req, res) => {
try {
let q = req.query.q || req.query.query;
if (!q) return res.json({ message: 'Input parameter q' });
let aloka = await yts(q);
if (!aloka?.all[0]) return res.json({ message: 'Not found' });
return res.json(aloka?.all);
} catch (e) {
console.log(e);
return res.json({ message: e.message });
}
})
.get('/mediafire', async (req, res) => {
try {
let { url } = req.query
//console.log(url)
if (!/https?:\/\/(www\.)?mediafire\.com\/(file|download)/i.test(url)) {
return res.json({ message: 'Invalid URL' });
}
let data = await mediafire(url)
return res.json(data)
} catch (e) {
console.log(e);
return res.json({ message: e.message });
}
})
.get('/ytdl', async (req, res) => {
try {
let { url } = req.query;
if (!ytIdRegex.test(url)) return res.json({ message: 'Invalid URL' });
let data = await ytAPI(url)
let dataInfo = await ytdl.getVideoID(url)
dataInfo = await yts({videoId: dataInfo})
let response = {
info: dataInfo ? dataInfo : {},
dl: data ? data : null,
};
return res.json(response);
} catch (e) {
console.log(e);
return res.status(500).json({ message: e.message });
}
})
.get('/twitter', async (req, res) => {
try {
let { url } = req.query;
url = url.replace('x.com', 'twitter.com'); // Mengganti x.com dengan twitter.com dalam URL
if (!/(https?:\/\/(www\.)?(twitter|x)\.com\/.*\/status\/.*)/.test(url)) {
return res.json({ message: 'Invalid URL' });
}
let data = await twitterDL(url);
return res.json(data);
} catch (e) {
console.log(e);
return res.json({ message: e.message });
}
})
.get('/mega', async (req, res) => {
try {
let { url } = req.query;
if (!/https:\/\/mega\.nz\/file\/[a-zA-Z0-9]{8}#[a-zA-Z0-9-_]{43}/.test(url)) {
return res.json({ message: 'Invalid URL' });
}
const file = File.fromURL(url);
await file.loadAttributes();
let data = await file.downloadBuffer();
return res.json({
title: file.name,
size: formatSize(file.size),
base64: data.toString('base64')
})
} catch (e) {
console.log(e);
return res.json({ message: e.message });
}
})
.listen(7860, () => console.log('App running on port 7860')); |