const express = require('express') const axios = require('axios') const cheerio = require('cheerio') const app = express() async function Spotify(q){ const r = await fetch('https://spotifydown.app/api/download?link='+q, {headers:{Referer:'https://spotifydown.app/'}}) return r.json(); } async function mediaFire(url) { try { const response = await fetch('https://r.jina.ai/' + url); const text = await response.text(); const result = { title: (text.match(/Title: (.+)/) || [])[1]?.trim() || '', link: (text.match(/URL Source: (.+)/) || [])[1]?.trim() || '', filename: '', url: '', size: '', repair: '' }; if (result.link) { const fileMatch = result.link.match(/\/([^\/]+\.zip)/); if (fileMatch) result.filename = fileMatch[1]; } const matches = [...text.matchAll(/\[(.*?)\]\((https:\/\/[^\s]+)\)/g)]; for (const match of matches) { const desc = match[1].trim(); const link = match[2].trim(); if (desc.toLowerCase().includes('download') && desc.match(/\((\d+(\.\d+)?[KMGT]B)\)/)) { result.url = link; result.size = (desc.match(/\((\d+(\.\d+)?[MG]B)\)/) || [])[1] || ''; } if (desc.toLowerCase().includes('repair')) { result.repair = link; } } return result; } catch (error) { return { error: error.message }; } } app.all('/download', async(req, res) => { const { url } = req.query || req.body if(/https:\/\/www.mediafire.com\/file/i.test(url)) { const _mediaf = await mediaFire(url) res.json(_mediaf) } else if(/https:\/\/spotify.com\/track\//i.test(url)) { const _spot = await Spotify(url) res.json(_spot) } }) app.listen(7860)