File size: 1,538 Bytes
99174cb 5b38e77 99174cb 5b38e77 99174cb b544520 bee5ae5 b544520 99174cb 085da5b 99174cb 085da5b 99174cb |
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 |
const express = require("express");
const { yt, tiktok, instagram, threads, twitter } = require('./lib/yt.js');
const app = express();
app.use(express.json());
app.set('json spaces', 4);
app.all('/dl/start', async (req, res) => {
const { url, typeYT = 'mp3' } = req.query || req.body;
if(/^https?:\/\/(?:www\.)?(?:youtube\.com\/(?:embed\/|v\/|watch\?v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/.test(url)) {
if(!['mp3', 'mp4'].includes(typeYT)) return res.json({ status: false, r: 'invalid type, use mp3 or mp4.' });
const ytr = await yt(url, typeYT);
res.json({ status: true, ...ytr });
} else if(/^https?:\/\/(?:www\.)?(?:twitter|x)\.com\/(?:i\/web\/status|[^\/]+\/status)\/(\d+)/.test(url)) {
const xr = await twitter(url);
res.json(xr);
} else if(/^https?:\/\/(?:www\.)?(?:tiktok\.com\/(?:@[^\/]+\/video|t)\/|vt\.tiktok\.com\/)([a-zA-Z0-9]+)/.test(url)) {
const ttr = await tiktok(url);
res.json(ttr);
} else if(/^https?:\/\/(?:www\.)?instagram\.com\/(?:reel|p|tv)\/([a-zA-Z0-9_-]+)/.test(url)) {
const igr = await instagram(url);
res.json({ status: true, ...igr });
} else if(/^https?:\/\/(?:www\.)?facebook\.com\/(?:watch\/\?v=|reels\/|[^\/]+\/videos\/)(\d+)/.test(url)) {
} else if(/^https?:\/\/(?:www\.)?threads\.net\/@[^\/]+\/post\/([a-zA-Z0-9_-]+)/.test(url)) {
const thr = await threads(url);
res.json(thr);
} else {
res.json({ status: false, r: 'not supported' });
}
});
const PORT = 7860;
app.listen(PORT, () => console.log(`Server running on port ${PORT}`)); |