Update server.js
Browse files
server.js
CHANGED
|
@@ -56,10 +56,26 @@ async function yt5sIo(url) {
|
|
| 56 |
}
|
| 57 |
}
|
| 58 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
app.all("/", async (req, res) => {
|
| 60 |
const { url } = req.query || req.body;
|
| 61 |
if(/^(https?:\/\/)?(www\.)?instagram\.com\/(p|reel)\/.+/i.test(url)) res.json(await yt5sIo(url)) // instagram
|
| 62 |
if(/^(https?:\/\/)?(www\.)?(facebook\.com|fb\.watch)\/.+/i.test(url)) res.json(await yt5sIo(url)) // fesnuk
|
|
|
|
| 63 |
});
|
| 64 |
|
| 65 |
app.listen(PORT, () => console.log(`Server berjalan di http://localhost:${PORT}`));
|
|
|
|
| 56 |
}
|
| 57 |
}
|
| 58 |
|
| 59 |
+
const ytdl = async(url) => {
|
| 60 |
+
const { data } = await axios.post('https://www.clipto.com/api/youtube', { url },
|
| 61 |
+
{
|
| 62 |
+
headers: {
|
| 63 |
+
'accept': 'application/json, text/plain, */*',
|
| 64 |
+
'content-type': 'application/json',
|
| 65 |
+
'origin': 'https://www.clipto.com',
|
| 66 |
+
'referer': 'https://www.clipto.com/id/media-downloader/youtube-downloader',
|
| 67 |
+
'user-agent': 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Mobile Safari/537.36'
|
| 68 |
+
}
|
| 69 |
+
}
|
| 70 |
+
);
|
| 71 |
+
return data
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
app.all("/", async (req, res) => {
|
| 75 |
const { url } = req.query || req.body;
|
| 76 |
if(/^(https?:\/\/)?(www\.)?instagram\.com\/(p|reel)\/.+/i.test(url)) res.json(await yt5sIo(url)) // instagram
|
| 77 |
if(/^(https?:\/\/)?(www\.)?(facebook\.com|fb\.watch)\/.+/i.test(url)) res.json(await yt5sIo(url)) // fesnuk
|
| 78 |
+
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
|
| 79 |
});
|
| 80 |
|
| 81 |
app.listen(PORT, () => console.log(`Server berjalan di http://localhost:${PORT}`));
|