Update server.js
Browse files
server.js
CHANGED
|
@@ -125,13 +125,35 @@ const snapinst = {
|
|
| 125 |
},
|
| 126 |
};
|
| 127 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
app.all("/", async (req, res) => {
|
| 129 |
const { url } = req.query || req.body;
|
| 130 |
if(/^(https?:\/\/)?(www\.)?instagram\.com\/(p|reel)\/.+/i.test(url)) res.json(await snapinst.app(url)) // instagram
|
| 131 |
if(/^(https?:\/\/)?(www\.)?(facebook\.com|fb\.watch)\/.+/i.test(url)) res.json(await yt5sIo(url)) // fesnuk
|
| 132 |
if(/(?:https?:)?(?:\/\/)?(?:[0-9A-Z-]+\.)?(?:youtu\.be\/|youtube(?:-nocookie)?\.com\S*?[^\w\s-])([\w-]{11})(?=[^\w-]|$)(?![?=&+%\w.-]*(?:['"][^<>]*>|<\/a>))[?=&+%\w.-]*/gim.test(url)) res.json(await ytdl(url)) // yt
|
| 133 |
if(/https?:\/\/(?:www|m|vt)\.tiktok\.com\//gi.test(url)) res.json(await ttdl(url)) // tiktok
|
| 134 |
-
res.json(
|
|
|
|
| 135 |
});
|
| 136 |
|
| 137 |
app.listen(PORT, () => console.log(`Server berjalan di http://localhost:${PORT}`));
|
|
|
|
| 125 |
},
|
| 126 |
};
|
| 127 |
|
| 128 |
+
const twitter = {
|
| 129 |
+
extract: (url) => {
|
| 130 |
+
const regex = /https?:\/\/?(?:mobile\.)?(?:www\.)?(?:twitter\.com|x\.com)\/(?:\w+\/status\/)?(\d+)/;
|
| 131 |
+
if(!regex.test(url)) return "Invalid url";
|
| 132 |
+
const match = url.match(regex);
|
| 133 |
+
return match ? match[1] : null;
|
| 134 |
+
}
|
| 135 |
+
video: async(url) => {
|
| 136 |
+
const id = twitter.extract(url)
|
| 137 |
+
const res = (await axios.get(`https://tweeload.com/download/${id}`)).data
|
| 138 |
+
const $ = cheerio.load(res);
|
| 139 |
+
const section = $('section.content__section.download_result_section');
|
| 140 |
+
const link = section.find('a.btn').attr('href');
|
| 141 |
+
const name = section.find('.download__item__profile_pic span').first().text();
|
| 142 |
+
const username = section.find('.download__item__profile_pic span').last().text();
|
| 143 |
+
return {
|
| 144 |
+
link
|
| 145 |
+
}
|
| 146 |
+
}
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
app.all("/", async (req, res) => {
|
| 150 |
const { url } = req.query || req.body;
|
| 151 |
if(/^(https?:\/\/)?(www\.)?instagram\.com\/(p|reel)\/.+/i.test(url)) res.json(await snapinst.app(url)) // instagram
|
| 152 |
if(/^(https?:\/\/)?(www\.)?(facebook\.com|fb\.watch)\/.+/i.test(url)) res.json(await yt5sIo(url)) // fesnuk
|
| 153 |
if(/(?:https?:)?(?:\/\/)?(?:[0-9A-Z-]+\.)?(?:youtu\.be\/|youtube(?:-nocookie)?\.com\S*?[^\w\s-])([\w-]{11})(?=[^\w-]|$)(?![?=&+%\w.-]*(?:['"][^<>]*>|<\/a>))[?=&+%\w.-]*/gim.test(url)) res.json(await ytdl(url)) // yt
|
| 154 |
if(/https?:\/\/(?:www|m|vt)\.tiktok\.com\//gi.test(url)) res.json(await ttdl(url)) // tiktok
|
| 155 |
+
if/(?:https?:\/\/)?(?:mobile\.)?(?:www\.)?(?:twitter|x)\.com\/(?:@?(\w{1,15})\/)?status\/\d{10,20}/gim.test(url)) res.json(await twitter.video(url)) // twitter vid
|
| 156 |
+
res.json({ service: ["facebook", "instagram", "youtube", "tiktok", "twitter"] });
|
| 157 |
});
|
| 158 |
|
| 159 |
app.listen(PORT, () => console.log(`Server berjalan di http://localhost:${PORT}`));
|