Update index.js
Browse files123445673 unmodified lines111213141415161718192021212223242426252627282930313233303132333435343536373839404142434041424445464748454947484950515253545556575859606162505152535455565758596061626364656667686465666768697071727374757672777874798076778182837980818284858687888985868790919293949596979394959697989910010110210310410510698991001011021031041051061071081091101111121131091141151161171181121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581 unmodified line16016116215315415515615715815916316416516616716816917017117210 unmodified lines1831841851761771781791801811821831841851861871881891861871881891901911921931941951961971981992001912012022032042052061971981992002012022032042052062072082092102112122132142152162072082092102112122132142152162172182192202212222232242252262272282192202212222232242252262272292302312322332342352362372382292302392402412322332342352362372382392402422432442452462472482492502512522532442452462472482492502512522532542542552562572582592602612622632642652662672582592602612622682692642652662672682702712722732742752762772782792702712722732742752762802812822832842852862872882892902782912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233242812822832842852862873253263273283293303312892902912922932942952962972982993003013023033043053063073083093103323123333343143153163173353363373383393403413423433443453463473483493503513523533543553563573583593603613623633203213223233243253263273283293303313323333343353363373383393403643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024033473483493503513523533543553563573583593603613623633643653663673683693703713723733743753764044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334343784354364374383823833843854394404414424433873883893903913923933943953963974444454464474484494504514524534544553994004014024034044564574584594604614624064074084094104114124634644654664674684694704714724734174184194204744754764774784794804814824834844854864874224234244254264274284294304884894904914324334344924934944954964974984994364374384394405005015025035045055065074434444454464474484494504514524534544554565084585095105115125135145155165172 unmodified lines520521522468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553523524525526555556527528529530531532533559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699534535536537538539540541542543702703704705706707708709710711712713714715716717718719544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674792675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727794795796728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770798799800801802803804805806807808771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887811888const yts = require('yt-search');const morgan = require('morgan');const express = require('express');const youtubedl = require('youtubedl-core');const ytdl = require('ytdl-core');const { Writable, pipeline } = require('stream');const util = require('util');const axios = require('axios');3 unmodified linesconst cheerio = require('cheerio')const cloudscraper = require('cloudscraper')const acrcloud = require("acrcloud"); const { File } = require('megajs')const { File } = require('megajs')const { BingChat } = require("bing-chat-cjs-rnz");const path = require("path")const fs = require("fs")let fetch;
(async () => { fetch = (await import('node-fetch')).default;fetch = (await import('node-fetch')).default;})();
// Regex untuk mengidentifikasi URL YouTube dan Megaconst ytIdRegex = /(?:http(?:s|):\/\/|)(?:(?:www\.|)?youtube(?:\-nocookie|)\.com\/(?:shorts\/)?(?:watch\?.*(?:|\&)v=|embed\/|v\/)?|youtu\.be\/)([-_0-9A-Za-z]{11})/;const ytIdRegex = /(?(?|)://|)(?:(?.|)?youtube(?:-nocookie|).com/(?/)?(??.*(?:|&)v=|embed/|v/)?|youtu.be/)([-_0-9A-Za-z]{11})/;
// Fungsi untuk melakukan HTTP POST requestconst post = async (url, form, headers = {}) => { const response = await fetch(url, { method: 'post', body: new URLSearchParams(form), headers }); return response;const response = await fetch(url, {method: 'post',body: new URLSearchParams(form),headers});return response;};
// isURLfunction 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);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 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'];
javascriptSalin kodeconst 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('.');function generateRandomIP() {return Array(4).fill(0).map(() => Math.floor(Math.random() * 256)).join('.');}//BIMGasync function bimg(query) { const { BingApi } = await import("bing-nodejs");const { BingApi } = await import("bing-nodejs");const bing = new BingApi({ cookie: process.env.BING_IMAGE_COOKIEcookie: process.env.BING_IMAGE_COOKIE}); let data = await bing.createImage(query).then((res) => { return res.urls; // string[]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
// 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 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'); }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 DLasync function mediafire(url) { return new Promise(async (resolve, reject) => { var a, b; if (!/https?:\/\/(www\.)?mediafire.com/.test(url)) return resolve(); return new Promise(async(resolve, reject) => { var a, b; if (!/https?:\/\/(www\.)?mediafire\.com/.test(url)) return resolve() const data = await axios.get(url, {headers: { 'User-Agent': generateRandomUserAgent(), 'X-Forwarded-For': generateRandomIP(),}}).catch(function (error) {}) 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 = /\(\.(.*?)\)/.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 aploud = $li.eq(1).find('span').text().trim(); const filesize = $li.eq(0).find('span').text().trim(); const filesizeB = (0, formatSize)(filesize); const result = { url: Url || url2, url2, filename, filetype, ext, upload_date: aploud, filesize, filesizeB }; resolve(result) } }) 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); } });}
1 unmodified lineasync 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' }'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',10 unmodified lines//FBDLasync 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 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 return e; }}
//YTDL-COREasync function uploadBuffer(media) { return new Promise(async (resolve, reject) => { try { let {fileTypeFromBuffer} = await (await import('file-type')) let mime = await fileTypeFromBuffer(media); let form = new FormData(); form.append("files[]", media, `file-${new Date().getTime()}.${mime.ext}`);
let response = await axios.post("https://pomf.lain.la/upload.php", form, { headers: { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36 Edg/119.0.0.0", ...form.getHeaders() } });
resolve(response.data?.files[0]?.url || null); } catch (error) { console.error(error); resolve(null); // Ensure null is returned if there's an error } });return new Promise(async (resolve, reject) => {try {let {fileTypeFromBuffer} = await (await import('file-type'))let mime = await fileTypeFromBuffer(media);let form = new FormData();form.append("files[]", media, `file-${new Date().getTime()}.${mime.ext}`);
let response = await axios.post("https://pomf.lain.la/upload.php", form, { headers: { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36 Edg/119.0.0.0", ...form.getHeaders() } });
resolve(response.data?.files[0]?.url || null); } catch (error) { console.error(error); resolve(null); // Ensure null is returned if there's an error }});}async function streamToBuffer(stream) { const chunks = []; const captureChunks = new Writable({ write(chunk, encoding, callback) { chunks.push(chunk); callback(); } }); await util.promisify(pipeline)(stream, captureChunks);const chunks = [];const captureChunks = new Writable({write(chunk, encoding, callback) {chunks.push(chunk);callback();}});
await util.promisify(pipeline)(stream, captureChunks);
return Buffer.concat(chunks);} return Buffer.concat(chunks);}function formatViews(viewCount) { if (viewCount >= 1000000000) { return (viewCount / 1000000000).toFixed(1) + 'B'; } else if (viewCount >= 1000000) { return (viewCount / 1000000).toFixed(1) + 'M'; } else { return viewCount >= 1000 ? (viewCount / 1000).toFixed(1) + 'K' : viewCount.toString(); }if (viewCount >= 1000000000) {return (viewCount / 1000000000).toFixed(1) + 'B';} else if (viewCount >= 1000000) {return (viewCount / 1000000).toFixed(1) + 'M';} else {return viewCount >= 1000? (viewCount / 1000).toFixed(1) + 'K': viewCount.toString();}}
function formatDuration(durationInSeconds) { const hours = Math.floor(durationInSeconds / 3600); const minutes = Math.floor((durationInSeconds % 3600) / 60); const seconds = durationInSeconds % 60;
return hours > 0 ? hours + ':' + minutes.toString().padStart(2, '0') + ':' + seconds.toString().padStart(2, '0') : minutes + ':' + seconds.toString().padStart(2, '0');const hours = Math.floor(durationInSeconds / 3600);const minutes = Math.floor((durationInSeconds % 3600) / 60);const seconds = durationInSeconds % 60;
return hours > 0? hours +':' +minutes.toString().padStart(2, '0') +':' +seconds.toString().padStart(2, '0'): minutes + ':' + seconds.toString().padStart(2, '0');}
function formatSize(bytes, si = false, dp = 2) { const thresh = si ? 1000 : 1024;
if (Math.abs(bytes) < thresh) { return `${bytes} B`; }const thresh = si ? 1000 : 1024;
const units = si ? ["kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"] : ["KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"]; let u = -1; const r = 10 ** dp;if (Math.abs(bytes) < thresh) {return `${bytes} B`;}
const units = si? ["kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"]: ["KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"];let u = -1;const r = 10 ** dp;
do { bytes /= thresh; ++u; } while ( Math.round(Math.abs(bytes) * r) / r >= thresh && u < units.length - 1 );do {bytes /= thresh;++u;} while (Math.round(Math.abs(bytes) * r) / r >= thresh &&u < units.length - 1);
return `${bytes.toFixed(dp)} ${units[u]}`;}
return `${bytes.toFixed(dp)} ${units[u]}`;async function ytmp4(url, quality = 'highestvideo') {try {const ID = ytdl.getVideoID(url),data = await ytdl.getInfo('https://www.youtube.com/watch?v=' + ID);const videoStream = await ytdl(ID, { filter: format => format.hasVideo && format.hasAudio, quality: quality });let buffer = await streamToBuffer(videoStream);let upload = await uploadBuffer(buffer);let urel = upload != null ? { url_v2: upload } : null;let format = ytdl.chooseFormat(data.formats, { filter: format => format.hasVideo && format.hasAudio, quality: quality });
if (format) { return { title: data.videoDetails.title, description: data.videoDetails.description, channel: data.videoDetails.ownerChannelName, views: formatViews(data.videoDetails.viewCount), publish: data.videoDetails.publishDate, duration: formatDuration(data.videoDetails.lengthSeconds), size: format.contentLength ? formatSize(format.contentLength) : 0, quality: format.qualityLabel, thumb: data.videoDetails.thumbnails[0].url, dl_url: format.url, ...urel, };} else { throw new Error('No suitable format found');}} catch (error) {console.error('Error occurred:', error);return error;}}
async function ytmp4(url, quality = 'highest') { try { const info = await youtubedl.getInfo(url); const videoStream = youtubedl(url, { quality: 'highestvideo', filter: (format) => format.container === 'mp4' && format.qualityLabel === quality });async function ytmp3(url, bitrate = 'lowestaudio') {try {const ID = ytdl.getVideoID(url),data = await ytdl.getInfo('https://www.youtube.com/watch?v=' + ID);const audioStream = await ytdl(ID, { filter: 'audioonly', quality: bitrate });let buffer = await streamToBuffer(audioStream);
let buffer = await streamToBuffer(videoStream); let upload = await uploadBuffer(buffer); let urel = upload != null ? { url_v2: upload } : null;
return { title: info.title, description: info.description, channel: info.channel, views: formatViews(info.view_count), publish: info.upload_date, duration: formatDuration(info.duration), size: info.formats[0].filesize, quality: info.formats[0].quality, thumb: info.thumbnail, dl_url: info.url, ...urel, }; } catch (error) { console.error('Error occurred:', error); return error; }}
async function ytmp3(url, bitrate = 'lowest') {async function convertToAudio(buffer, ext) { try { const info = await youtubedl.getInfo(url); const audioStream = youtubedl(url, { quality: 'highestaudio', filter: 'audioonly' const tmp = path.join(os.tmpdir(), `${+new Date()}.${ext}`); const out = `${tmp}.mp3`; await fs.promises.writeFile(tmp, buffer);
const ffmpegProcess = cp.spawn('ffmpeg', [ '-y', '-i', tmp, '-vn', '-ac', '2', '-b:a', '128k', '-ar', '44100', '-f', 'mp3', out ]);
await new Promise((resolve, reject) => { ffmpegProcess.on('error', (err) => { console.error(err); reject(err); }); ffmpegProcess.on('close', (code) => { if (code !== 0) { reject(`ffmpeg process closed with code: ${code}`); } else { resolve(); } }); });
let buffer = await streamToBuffer(audioStream); let konver = await convertToAudio(buffer, "mp4"); let upload = await uploadBuffer(konver); let urel = upload != null ? { url_v2: upload } : null;
return { title: info.title, description: info.description, channel: info.channel, views: formatViews(info.view_count), publish: info.upload_date, duration: formatDuration(info.duration), size: info.formats[0].filesize, quality: info.formats[0].quality, thumb: info.thumbnail, dl_url: info.url, ...urel, }; } catch (error) { console.error('Error occurred:', error); return error; const result = await fs.promises.readFile(out); await fs.promises.unlink(tmp); await fs.promises.unlink(out); return result; } catch (e) { console.error(e); throw e; }}
let konver = await convertToAudio(buffer, "mp4");let upload = await uploadBuffer(konver);let urel = upload != null ? { url_v2: upload } : null;let format = ytdl.chooseFormat(data.formats, { filter: 'audioonly', quality: bitrate });
if (format) { return { title: data.videoDetails.title, description: data.videoDetails.description, channel: data.videoDetails.ownerChannelName, views: formatViews(data.videoDetails.viewCount), publish: data.videoDetails.publishDate, duration: formatDuration(data.videoDetails.lengthSeconds), size: format.contentLength ? formatSize(format.contentLength) : 0, quality: format.audioQuality, thumb: data.videoDetails.thumbnails[0].url, dl_url: format.url, ...urel, };} else { throw new Error('No suitable format found');}} catch (error) {console.error('Error occurred:', error);return error;}}
// Fungsi untuk mengkonversi video dari YouTubeconst 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));let params = {v_id,ftype,fquality,fname,token,timeExpire,client: 'yt5s.com'};
// Mengirim permintaan konversilet 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 nullif (!server && ftype === 'mp3') return server || resServer.d_url || '';
// Mengambil data hasil konversilet data = await (await post(`${server}/api/json/convert`, params)).json();let result;
// Memeriksa status kode hasil konversiif (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;return result;};
// Fungsi untuk mendownload video dari YouTubeconst youtubedl_2 = async (url) => { let html = await (await fetch('https://yt5s.com/en32', {headers: { 'User-Agent': generateRandomUserAgent(), 'X-Forwarded-For': generateRandomIP(),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)) });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)) });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 };return { id: json.vid, title: json.title, thumbnail: `https://i.ytimg.com/vi/${json.vid}/0.jpg`, video, audio};};
//TWITTER APIasync function twitterDL(url) { try { let form = new FormData(); form.append('q', url); form.append('lang', 'en');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 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 = [];
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 }); } });
$('.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); } });
// 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; }}
return { downloads };} catch (error) { return error;}}
const app = express();app.set('json spaces', 4);2 unmodified lines
const v8 = require('v8');
app.all('/', async (req, res) => { 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=" }]app.all('/', async (req, res) => {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)}`
app.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_2(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 }); } }); app.get('/ig', async (req,res) => { try { let {url} = req.query let regex = /https?:\/\/(www\.)?instagram\.com\/(p|reel|tv)/; 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 }); } }); app.get('/tt', async (req, res) => { try { let { url } = req.query let regex = /https?:\/\/(www\.|v(t|m|vt)\.|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:v' }); return res.json(data) } catch (e) { console.log(e); return res.json({ message: e.message }); } }); app.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:v' }); return res.json(data) } catch (e) { console.log(e); return res.json({ message: e.message }); } }); app.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 }); } });app.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 }); } });app.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).slice(1) 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!'// Menambahkan statistik heap V8const heapStats = v8.getHeapStatistics();for (let x in heapStats) status[x] = formatSize(heapStats[x])
// Menambahkan semua properti dan metode dari v8for (let x in v8) {if (typeof v8[x] !== 'function') {status[x] = v8[x]}} data = await gpt4o(q) //return res.json({message: 'Terkena Chaptcha BOT!!!'}) } return res.json({result:data}) } catch (e) { console.log(e); return res.json({ message: e.message }); }})app.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'
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=` } ]});
app.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 }); 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:v'}) return res.json(data); } catch (e) { console.log(e); return res.json({ message: e.message }); } }) app.get('/ytsearch', async (req, res) => { try { let q = req.query.q || req.query.query; if (!q) return res.json({ message: 'Input parameter q' }); let data = await yts(q); if (!data.all[0]) return res.json({ message: 'Not found' }); return res.json(data.all); } catch (e) { console.log(e); return res.json({ message: e.message }); } }); app.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 }); } }); app.get('/ytdl', async (req, res) => { try { let { url } = req.query if (!ytIdRegex.test(url)) return res.json({ message: 'Invalid URL' }); let video = await ytmp4(url) let audio = await ytmp3(url) return res.json({ video: video, audio: audio }) } catch (e) { console.log(e); return res.json({ message: e.message }); } }); app.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) { } 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 }); }});app.get('/ig', async (req,res) => {try {let {url} = req.querylet 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 });}});app.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 }); }});
app.get('/mega', async (req, res) => {app.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 }); }});
app.get('/fb', async (req, res) => {try {let {url} = req.querylet 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 });}});app.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 });}});app.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 { 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' }); 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!'; } 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 }); } 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 });}})app.get('/whatmusic', async (req, res) => {try {let { url } = req.queryasync 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 });}})app.get('/ytsearch', async (req, res) => {try {let q = req.query.q || req.query.query;if (!q) return res.json({ message: 'Input parameter q' });let data = await yts(q);if (!data.all[0]) return res.json({ message: 'Not found' });return res.json(data.all);} catch (e) {console.log(e);return res.json({ message: e.message });}});app.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 });}});app.get('/ytdl', async (req, res) => {try {let { url } = req.queryif (!ytIdRegex.test(url)) return res.json({ message: 'Invalid URL' });let video = await ytmp4(url)let audio = await ytmp3(url)return res.json({video: video,audio: audio})} catch (e) {console.log(e);return res.json({ message: e.message });}});app.get('/twitter', async (req, res) => {try {let { url } = req.query;url = url.replace('x.com', 'twitter.com'); // Mengganti x.com dengan twitter.com dalam URLif (!/(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 });}});
app.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 });}}); app.listen(7860, () => console.log('App running on port 7860'));app.listen(7860, () => console.log('App running on port 7860'));index.js+743-666