Update plugins/alldownloader.js
Browse files- plugins/alldownloader.js +13 -3
plugins/alldownloader.js
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
import express from 'express';
|
|
|
2 |
import {
|
3 |
facebookdl,
|
4 |
savefrom,
|
@@ -705,18 +706,27 @@ AllDlRoutes.get('/api/v1/dl/tiktok', authenticateApiKey, apiLimiter, async (req,
|
|
705 |
* description: Internal Server Error
|
706 |
*/
|
707 |
AllDlRoutes.get('/api/v1/dl/tiktok-v2', authenticateApiKey, apiLimiter, async (req, res) => {
|
|
|
|
|
708 |
try {
|
709 |
const apiKey = req.headers['x-api-key'];
|
710 |
-
const
|
711 |
-
|
|
|
|
|
|
|
712 |
|
|
|
713 |
if (!url) {
|
714 |
return res.status(400).json({ error: "URL parameter is required." });
|
715 |
}
|
716 |
-
|
|
|
|
|
717 |
const results = await tiktokdl(url);
|
718 |
res.json({ results });
|
719 |
} catch (error) {
|
|
|
720 |
res.status(500).json({ error: error.message });
|
721 |
}
|
722 |
});
|
|
|
1 |
import express from 'express';
|
2 |
+
import { Database } from '../database/database.js';
|
3 |
import {
|
4 |
facebookdl,
|
5 |
savefrom,
|
|
|
706 |
* description: Internal Server Error
|
707 |
*/
|
708 |
AllDlRoutes.get('/api/v1/dl/tiktok-v2', authenticateApiKey, apiLimiter, async (req, res) => {
|
709 |
+
const dbClient = new Database("AkenoXJs");
|
710 |
+
const db = dbClient.collection("api_keys");
|
711 |
try {
|
712 |
const apiKey = req.headers['x-api-key'];
|
713 |
+
const keyDoc = await db.findOne({key: apiKey});
|
714 |
+
|
715 |
+
if (!keyData) {
|
716 |
+
return res.status(403).json({ error: "Invalid API Key." });
|
717 |
+
}
|
718 |
|
719 |
+
const url = req.query.url;
|
720 |
if (!url) {
|
721 |
return res.status(400).json({ error: "URL parameter is required." });
|
722 |
}
|
723 |
+
|
724 |
+
await TelegramUseLog(keyData.user_id, keyData.key, `Accessed: ${req.path}`);
|
725 |
+
|
726 |
const results = await tiktokdl(url);
|
727 |
res.json({ results });
|
728 |
} catch (error) {
|
729 |
+
console.error("TikTok Downloader Error:", error.message);
|
730 |
res.status(500).json({ error: error.message });
|
731 |
}
|
732 |
});
|