Update index.js
Browse files9 unmodified lines10111213141516 unmodified lines32333435363739 unmodified lines777879808182379 unmodified lines462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515105 unmodified lines6216226236246256269 unmodified linesconst os = require('os')const cheerio = require('cheerio')const cloudscraper = require('cloudscraper')const { File } = require('megajs')const { BingChat } = require("bing-chat-cjs-rnz");let fetch;16 unmodified linesreturn response;};//RANDOMfunction 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'];39 unmodified linesconst res = await api.sendMessage(text, { variant: 'Precise' })return res?.text}// MEDIAFIRE DLasync function mediafire(url) {379 unmodified lines{"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": "Youtube Downloader","method": "GET","example": `${host}/ytdl?url=`},{"title": "Youtube Search","method": "GET","example": `${host}/ytsearch?q=`}]});});105 unmodified linesconsole.log(e);return res.json({ message: e.message });}})app.get('/ytsearch', async (req, res) => {try {9 unmodified lines1011121314151616 unmodified lines333435363738394041424344454639 unmodified lines8687888990919293949596979899100101102103104105106107108109379 unmodified lines489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548105 unmodified lines6546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836849 unmodified linesconst os = require('os')const cheerio = require('cheerio')const cloudscraper = require('cloudscraper')const { acr } = require("acrcloud");const { File } = require('megajs')const { BingChat } = require("bing-chat-cjs-rnz");let fetch;16 unmodified linesreturn 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);}//RANDOMfunction 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'];39 unmodified linesconst 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 acr({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) {379 unmodified lines{"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="}]});});105 unmodified linesconsole.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:v'})return res.json(data);} catch (e) {console.log(e);return res.json({ message: e.message });}})app.get('/ytsearch', async (req, res) => {try {
index.js+68-10