const axios = require('axios'); async function teradl(url) { try { const pattern = /^https?:\/\/(?:www\.|1024)?terabox(?:app)?\.com\/.*[?&]?surl=([a-zA-Z0-9_-]+)/i; let match = url.match(pattern); let surl = match?.[1]; if (!surl) { if (!/^https?:\/\/(?:www\.|1024)?terabox(?:app)?\.com/i.test(url)) throw new Error('Invalid TeraBox URL.'); const { request } = await axios.get(url, { maxRedirects: 10, validateStatus: status => status >= 200 && status < 400 }); match = request.res.responseUrl.match(pattern); surl = match?.[1]; if (!surl) throw new Error('SURL not found.'); } const { data } = await axios.get('https://tera2.sylyt93.workers.dev/info', { headers: { origin: 'https://www.kauruka.com', referer: 'https://www.kauruka.com/', 'user-agent': 'Mozilla/5.0 (Linux; Android 15; SM-F958 Build/AP3A.240905.015) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.6723.86 Mobile Safari/537.36' }, params: { s: surl } }); return data; } catch (error) { throw new Error(error.message); } }; // Usage: teradl('https://terabox.com/s/1ZdiYMWn2JsklSZxGdKJEBw').then(console.log);