randydev commited on
Commit
e923dc1
·
verified ·
1 Parent(s): 5da1c2e

Update plugins/alldownloader.js

Browse files
Files changed (1) hide show
  1. plugins/alldownloader.js +72 -0
plugins/alldownloader.js CHANGED
@@ -17,6 +17,7 @@ import {
17
  InstagramDownloader,
18
  TeraboxDownloader,
19
  TeraboxV2Downloader,
 
20
  PinterestDownloader,
21
  XsearchDownloaderV2,
22
  InstagramDLV3,
@@ -502,6 +503,77 @@ AllDlRoutes.get('/api/v1/dl/sfilemobi-search', authenticateApiKey, apiLimiter, a
502
  }
503
  });
504
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
505
  /**
506
  * @swagger
507
  * /api/v1/dl/terabox-v2:
 
17
  InstagramDownloader,
18
  TeraboxDownloader,
19
  TeraboxV2Downloader,
20
+ TeraboxV3Downloader,
21
  PinterestDownloader,
22
  XsearchDownloaderV2,
23
  InstagramDLV3,
 
503
  }
504
  });
505
 
506
+ /**
507
+ * @swagger
508
+ * /api/v1/dl/terabox-v3:
509
+ * get:
510
+ * summary: Terabox V3 Downloader
511
+ * tags: [ALL-Downloader]
512
+ * parameters:
513
+ * - in: query
514
+ * name: url
515
+ * required: true
516
+ * description: null
517
+ * schema:
518
+ * type: string
519
+ * - in: header
520
+ * name: x-api-key
521
+ * required: true
522
+ * description: API key for authentication
523
+ * schema:
524
+ * type: string
525
+ * responses:
526
+ * 200:
527
+ * description: Success
528
+ * 400:
529
+ * description: Bad Request (e.g., missing or invalid URL)
530
+ * 401:
531
+ * description: Unauthorized (e.g., missing or invalid API key)
532
+ * 500:
533
+ * description: Internal Server Error
534
+ */
535
+ AllDlRoutes.get('/api/v1/dl/terabox-v3', authenticateApiKey, apiLimiter, async (req, res) => {
536
+ try {
537
+ const apiKey = req.headers['x-api-key'];
538
+ const userAgent = req.headers['user-agent'];
539
+
540
+ const xForwardedFor = req.headers['x-forwarded-for'];
541
+ const xRealIP = req.headers['x-real-ip'];
542
+ const cfConnectingIP = req.headers['cf-connecting-ip'];
543
+
544
+ let realIP = req.ip;
545
+
546
+ if (xForwardedFor) {
547
+ realIP = xForwardedFor.split(',')[0].trim();
548
+ } else if (xRealIP) {
549
+ realIP = xRealIP;
550
+ } else if (cfConnectingIP) {
551
+ realIP = cfConnectingIP;
552
+ }
553
+
554
+ req.realIP = realIP;
555
+
556
+ console.log(`🔍 Captured IPs:`, { xForwardedFor, xRealIP, cfConnectingIP, realIP });
557
+
558
+ const keyDoc = await db.findOne({ key: apiKey });
559
+
560
+ if (!keyDoc) {
561
+ return res.status(403).json({ error: "Invalid API Key." });
562
+ }
563
+ const url = req.query.url;
564
+
565
+ if (!url) {
566
+ return res.status(400).json({ error: "URL parameter is required." });
567
+ }
568
+ await updateIP(apiKey, realIP);
569
+ const results = await TeraboxV3Downloader(url);
570
+ res.json({ results });
571
+ } catch (error) {
572
+ res.status(500).json({ error: error.message });
573
+ }
574
+ });
575
+
576
+
577
  /**
578
  * @swagger
579
  * /api/v1/dl/terabox-v2: