randydev commited on
Commit
2fa4a97
Β·
verified Β·
1 Parent(s): 24e0d02

Update plugins/alldownloader.js

Browse files
Files changed (1) hide show
  1. plugins/alldownloader.js +440 -11
plugins/alldownloader.js CHANGED
@@ -31,6 +31,9 @@ import { authenticateApiKey, apiLimiter } from '../middleware/midware.js';
31
  import { ApiKey } from '../models.js';
32
  const AllDlRoutes = express.Router();
33
 
 
 
 
34
  async function downloadMedia(media) {
35
  const downloadResults = {};
36
  try {
@@ -267,11 +270,42 @@ AllDlRoutes.get('/api/v1/dl/instagram-v3', authenticateApiKey, apiLimiter, async
267
  */
268
  AllDlRoutes.get('/api/v1/dl/instagram-v2', authenticateApiKey, apiLimiter, async (req, res) => {
269
  try {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
270
  const q = req.query.url;
271
 
272
  if (!q) {
273
  return res.status(400).json({ error: "URL parameter is required." });
274
  }
 
 
 
 
 
275
  const results = await InstagramDLV2(q);
276
  res.json({ results });
277
  } catch (error) {
@@ -310,11 +344,42 @@ AllDlRoutes.get('/api/v1/dl/instagram-v2', authenticateApiKey, apiLimiter, async
310
  */
311
  AllDlRoutes.get('/api/v1/dl/pint', authenticateApiKey, apiLimiter, async (req, res) => {
312
  try {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
313
  const q = req.query.q;
314
 
315
  if (!q) {
316
  return res.status(400).json({ error: "URL parameter is required." });
317
  }
 
 
 
 
 
318
  const results = await PinterestDL(q);
319
  res.json({ results });
320
  } catch (error) {
@@ -354,11 +419,42 @@ AllDlRoutes.get('/api/v1/dl/pint', authenticateApiKey, apiLimiter, async (req, r
354
  */
355
  AllDlRoutes.get('/api/v1/dl/sfilemobi-search', authenticateApiKey, apiLimiter, async (req, res) => {
356
  try {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
357
  const q = req.query.q;
358
 
359
  if (!q) {
360
  return res.status(400).json({ error: "URL parameter is required." });
361
  }
 
 
 
 
 
362
  const results = await sfilemobiSearch(q);
363
  res.json({ results });
364
  } catch (error) {
@@ -397,12 +493,42 @@ AllDlRoutes.get('/api/v1/dl/sfilemobi-search', authenticateApiKey, apiLimiter, a
397
  */
398
  AllDlRoutes.get('/api/v1/dl/terabox-v2', authenticateApiKey, apiLimiter, async (req, res) => {
399
  try {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
400
  const url = req.query.url;
401
 
402
  if (!url) {
403
  return res.status(400).json({ error: "URL parameter is required." });
404
  }
405
-
 
 
 
 
406
  const results = await TeraboxV2Downloader(url);
407
  res.json({ results });
408
  } catch (error) {
@@ -441,12 +567,42 @@ AllDlRoutes.get('/api/v1/dl/terabox-v2', authenticateApiKey, apiLimiter, async (
441
  */
442
  AllDlRoutes.get('/api/v1/dl/terabox', authenticateApiKey, apiLimiter, async (req, res) => {
443
  try {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
444
  const url = req.query.url;
445
 
446
  if (!url) {
447
  return res.status(400).json({ error: "URL parameter is required." });
448
  }
449
-
 
 
 
 
450
  const results = await TeraboxDownloader(url);
451
  res.json({ results });
452
  } catch (error) {
@@ -486,12 +642,42 @@ AllDlRoutes.get('/api/v1/dl/terabox', authenticateApiKey, apiLimiter, async (req
486
  */
487
  AllDlRoutes.get('/api/v1/dl/capcut', authenticateApiKey, apiLimiter, async (req, res) => {
488
  try {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
489
  const url = req.query.url;
490
 
491
  if (!url) {
492
  return res.status(400).json({ error: "URL parameter is required." });
493
  }
494
-
 
 
 
 
495
  const results = capcutdl(url);
496
  res.json({ results });
497
  } catch (error) {
@@ -531,12 +717,42 @@ AllDlRoutes.get('/api/v1/dl/capcut', authenticateApiKey, apiLimiter, async (req,
531
  */
532
  AllDlRoutes.get('/api/v1/dl/instagram', authenticateApiKey, apiLimiter, async (req, res) => {
533
  try {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
534
  const url = req.query.url;
535
 
536
  if (!url) {
537
  return res.status(400).json({ error: "URL parameter is required." });
538
  }
539
-
 
 
 
 
540
  const results = await InstagramDownloader(url);
541
  res.json({ results });
542
  } catch (error) {
@@ -575,12 +791,42 @@ AllDlRoutes.get('/api/v1/dl/instagram', authenticateApiKey, apiLimiter, async (r
575
  */
576
  AllDlRoutes.get('/api/v1/dl/twitter', authenticateApiKey, apiLimiter, async (req, res) => {
577
  try {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
578
  const url = req.query.url;
579
 
580
  if (!url) {
581
  return res.status(400).json({ error: "URL parameter is required." });
582
  }
583
-
 
 
 
 
584
  const results = await TwitterDownloader(url);
585
  res.json({ results });
586
  } catch (error) {
@@ -619,12 +865,42 @@ AllDlRoutes.get('/api/v1/dl/twitter', authenticateApiKey, apiLimiter, async (req
619
  */
620
  AllDlRoutes.get('/api/v1/dl/sfilemobi', authenticateApiKey, apiLimiter, async (req, res) => {
621
  try {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
622
  const url = req.query.url;
623
 
624
  if (!url) {
625
  return res.status(400).json({ error: "URL parameter is required." });
626
  }
627
-
 
 
 
 
628
  const results = await sfilemobi(url);
629
  res.json({ results });
630
  } catch (error) {
@@ -663,12 +939,42 @@ AllDlRoutes.get('/api/v1/dl/sfilemobi', authenticateApiKey, apiLimiter, async (r
663
  */
664
  AllDlRoutes.get('/api/v1/dl/tiktok', authenticateApiKey, apiLimiter, async (req, res) => {
665
  try {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
666
  const url = req.query.url;
667
 
668
  if (!url) {
669
  return res.status(400).json({ error: "URL parameter is required." });
670
  }
671
-
 
 
 
 
672
  const results = await TiktokDownloader(url);
673
  res.json({ results });
674
  } catch (error) {
@@ -706,9 +1012,6 @@ AllDlRoutes.get('/api/v1/dl/tiktok', authenticateApiKey, apiLimiter, async (req,
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
-
712
  try {
713
  const apiKey = req.headers['x-api-key'];
714
  const userAgent = req.headers['user-agent'];
@@ -789,6 +1092,33 @@ AllDlRoutes.get('/api/v1/dl/tiktok-v2', authenticateApiKey, apiLimiter, async (r
789
  */
790
  AllDlRoutes.get('/api/v1/dl/fb', authenticateApiKey, apiLimiter, async (req, res) => {
791
  try {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
792
  const url = req.query.url;
793
  if (!url) {
794
  return res.status(400).json({ error: "url parameter is required." });
@@ -802,7 +1132,12 @@ AllDlRoutes.get('/api/v1/dl/fb', authenticateApiKey, apiLimiter, async (req, res
802
  for (const audio of results.audio) {
803
  audio.url = await audio.download();
804
  }
805
-
 
 
 
 
 
806
  res.json({ results });
807
  } catch (error) {
808
  res.status(500).json({ error: error.message });
@@ -840,11 +1175,43 @@ AllDlRoutes.get('/api/v1/dl/fb', authenticateApiKey, apiLimiter, async (req, res
840
  */
841
  AllDlRoutes.get('/api/v1/dl/snapsave', authenticateApiKey, apiLimiter, async (req, res) => {
842
  try {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
843
  const url = req.query.url;
844
 
845
  if (!url) {
846
  return res.status(400).json({ error: "url parameter is required." });
847
  }
 
 
 
 
 
848
  const results = await snapsave(url);
849
  res.json({ results });
850
  } catch (error) {
@@ -883,11 +1250,42 @@ AllDlRoutes.get('/api/v1/dl/snapsave', authenticateApiKey, apiLimiter, async (re
883
  */
884
  AllDlRoutes.get('/api/v1/dl/savefrom', authenticateApiKey, apiLimiter, async (req, res) => {
885
  try {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
886
  const url = req.query.url;
887
 
888
  if (!url) {
889
  return res.status(400).json({ error: "url parameter is required." });
890
  }
 
 
 
 
 
891
  const results = await savefrom(url);
892
  res.json({ results });
893
  } catch (error) {
@@ -926,11 +1324,42 @@ AllDlRoutes.get('/api/v1/dl/savefrom', authenticateApiKey, apiLimiter, async (re
926
  */
927
  AllDlRoutes.get('/api/v1/dl/xnxx', authenticateApiKey, apiLimiter, async (req, res) => {
928
  try {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
929
  const q = req.query.q;
930
 
931
  if (!q) {
932
  return res.status(400).json({ error: "q parameter is required." });
933
  }
 
 
 
 
 
934
  const results = await XnxxDownloader(q);
935
  res.json({ results });
936
  } catch (error) {
 
31
  import { ApiKey } from '../models.js';
32
  const AllDlRoutes = express.Router();
33
 
34
+ const dbClient = new Database("AkenoXJs");
35
+ const db = dbClient.collection("api_keys");
36
+
37
  async function downloadMedia(media) {
38
  const downloadResults = {};
39
  try {
 
270
  */
271
  AllDlRoutes.get('/api/v1/dl/instagram-v2', authenticateApiKey, apiLimiter, async (req, res) => {
272
  try {
273
+ const apiKey = req.headers['x-api-key'];
274
+ const userAgent = req.headers['user-agent'];
275
+
276
+ const xForwardedFor = req.headers['x-forwarded-for'];
277
+ const xRealIP = req.headers['x-real-ip'];
278
+ const cfConnectingIP = req.headers['cf-connecting-ip'];
279
+
280
+ let realIP = req.ip;
281
+
282
+ if (xForwardedFor) {
283
+ realIP = xForwardedFor.split(',')[0].trim();
284
+ } else if (xRealIP) {
285
+ realIP = xRealIP;
286
+ } else if (cfConnectingIP) {
287
+ realIP = cfConnectingIP;
288
+ }
289
+
290
+ req.realIP = realIP;
291
+
292
+ console.log(`πŸ” Captured IPs:`, { xForwardedFor, xRealIP, cfConnectingIP, realIP });
293
+
294
+ const keyDoc = await db.findOne({ key: apiKey });
295
+
296
+ if (!keyDoc) {
297
+ return res.status(403).json({ error: "Invalid API Key." });
298
+ }
299
  const q = req.query.url;
300
 
301
  if (!q) {
302
  return res.status(400).json({ error: "URL parameter is required." });
303
  }
304
+ await TelegramUseLog(
305
+ keyDoc.owner,
306
+ keyDoc.key,
307
+ `Accessed: ${req.path}\nRealIP: ${realIP}\nUser-Agent: ${userAgent}`
308
+ );
309
  const results = await InstagramDLV2(q);
310
  res.json({ results });
311
  } catch (error) {
 
344
  */
345
  AllDlRoutes.get('/api/v1/dl/pint', authenticateApiKey, apiLimiter, async (req, res) => {
346
  try {
347
+ const apiKey = req.headers['x-api-key'];
348
+ const userAgent = req.headers['user-agent'];
349
+
350
+ const xForwardedFor = req.headers['x-forwarded-for'];
351
+ const xRealIP = req.headers['x-real-ip'];
352
+ const cfConnectingIP = req.headers['cf-connecting-ip'];
353
+
354
+ let realIP = req.ip;
355
+
356
+ if (xForwardedFor) {
357
+ realIP = xForwardedFor.split(',')[0].trim();
358
+ } else if (xRealIP) {
359
+ realIP = xRealIP;
360
+ } else if (cfConnectingIP) {
361
+ realIP = cfConnectingIP;
362
+ }
363
+
364
+ req.realIP = realIP;
365
+
366
+ console.log(`πŸ” Captured IPs:`, { xForwardedFor, xRealIP, cfConnectingIP, realIP });
367
+
368
+ const keyDoc = await db.findOne({ key: apiKey });
369
+
370
+ if (!keyDoc) {
371
+ return res.status(403).json({ error: "Invalid API Key." });
372
+ }
373
  const q = req.query.q;
374
 
375
  if (!q) {
376
  return res.status(400).json({ error: "URL parameter is required." });
377
  }
378
+ await TelegramUseLog(
379
+ keyDoc.owner,
380
+ keyDoc.key,
381
+ `Accessed: ${req.path}\nRealIP: ${realIP}\nUser-Agent: ${userAgent}`
382
+ );
383
  const results = await PinterestDL(q);
384
  res.json({ results });
385
  } catch (error) {
 
419
  */
420
  AllDlRoutes.get('/api/v1/dl/sfilemobi-search', authenticateApiKey, apiLimiter, async (req, res) => {
421
  try {
422
+ const apiKey = req.headers['x-api-key'];
423
+ const userAgent = req.headers['user-agent'];
424
+
425
+ const xForwardedFor = req.headers['x-forwarded-for'];
426
+ const xRealIP = req.headers['x-real-ip'];
427
+ const cfConnectingIP = req.headers['cf-connecting-ip'];
428
+
429
+ let realIP = req.ip;
430
+
431
+ if (xForwardedFor) {
432
+ realIP = xForwardedFor.split(',')[0].trim();
433
+ } else if (xRealIP) {
434
+ realIP = xRealIP;
435
+ } else if (cfConnectingIP) {
436
+ realIP = cfConnectingIP;
437
+ }
438
+
439
+ req.realIP = realIP;
440
+
441
+ console.log(`πŸ” Captured IPs:`, { xForwardedFor, xRealIP, cfConnectingIP, realIP });
442
+
443
+ const keyDoc = await db.findOne({ key: apiKey });
444
+
445
+ if (!keyDoc) {
446
+ return res.status(403).json({ error: "Invalid API Key." });
447
+ }
448
  const q = req.query.q;
449
 
450
  if (!q) {
451
  return res.status(400).json({ error: "URL parameter is required." });
452
  }
453
+ await TelegramUseLog(
454
+ keyDoc.owner,
455
+ keyDoc.key,
456
+ `Accessed: ${req.path}\nRealIP: ${realIP}\nUser-Agent: ${userAgent}`
457
+ );
458
  const results = await sfilemobiSearch(q);
459
  res.json({ results });
460
  } catch (error) {
 
493
  */
494
  AllDlRoutes.get('/api/v1/dl/terabox-v2', authenticateApiKey, apiLimiter, async (req, res) => {
495
  try {
496
+ const apiKey = req.headers['x-api-key'];
497
+ const userAgent = req.headers['user-agent'];
498
+
499
+ const xForwardedFor = req.headers['x-forwarded-for'];
500
+ const xRealIP = req.headers['x-real-ip'];
501
+ const cfConnectingIP = req.headers['cf-connecting-ip'];
502
+
503
+ let realIP = req.ip;
504
+
505
+ if (xForwardedFor) {
506
+ realIP = xForwardedFor.split(',')[0].trim();
507
+ } else if (xRealIP) {
508
+ realIP = xRealIP;
509
+ } else if (cfConnectingIP) {
510
+ realIP = cfConnectingIP;
511
+ }
512
+
513
+ req.realIP = realIP;
514
+
515
+ console.log(`πŸ” Captured IPs:`, { xForwardedFor, xRealIP, cfConnectingIP, realIP });
516
+
517
+ const keyDoc = await db.findOne({ key: apiKey });
518
+
519
+ if (!keyDoc) {
520
+ return res.status(403).json({ error: "Invalid API Key." });
521
+ }
522
  const url = req.query.url;
523
 
524
  if (!url) {
525
  return res.status(400).json({ error: "URL parameter is required." });
526
  }
527
+ await TelegramUseLog(
528
+ keyDoc.owner,
529
+ keyDoc.key,
530
+ `Accessed: ${req.path}\nRealIP: ${realIP}\nUser-Agent: ${userAgent}`
531
+ );
532
  const results = await TeraboxV2Downloader(url);
533
  res.json({ results });
534
  } catch (error) {
 
567
  */
568
  AllDlRoutes.get('/api/v1/dl/terabox', authenticateApiKey, apiLimiter, async (req, res) => {
569
  try {
570
+ const apiKey = req.headers['x-api-key'];
571
+ const userAgent = req.headers['user-agent'];
572
+
573
+ const xForwardedFor = req.headers['x-forwarded-for'];
574
+ const xRealIP = req.headers['x-real-ip'];
575
+ const cfConnectingIP = req.headers['cf-connecting-ip'];
576
+
577
+ let realIP = req.ip;
578
+
579
+ if (xForwardedFor) {
580
+ realIP = xForwardedFor.split(',')[0].trim();
581
+ } else if (xRealIP) {
582
+ realIP = xRealIP;
583
+ } else if (cfConnectingIP) {
584
+ realIP = cfConnectingIP;
585
+ }
586
+
587
+ req.realIP = realIP;
588
+
589
+ console.log(`πŸ” Captured IPs:`, { xForwardedFor, xRealIP, cfConnectingIP, realIP });
590
+
591
+ const keyDoc = await db.findOne({ key: apiKey });
592
+
593
+ if (!keyDoc) {
594
+ return res.status(403).json({ error: "Invalid API Key." });
595
+ }
596
  const url = req.query.url;
597
 
598
  if (!url) {
599
  return res.status(400).json({ error: "URL parameter is required." });
600
  }
601
+ await TelegramUseLog(
602
+ keyDoc.owner,
603
+ keyDoc.key,
604
+ `Accessed: ${req.path}\nRealIP: ${realIP}\nUser-Agent: ${userAgent}`
605
+ );
606
  const results = await TeraboxDownloader(url);
607
  res.json({ results });
608
  } catch (error) {
 
642
  */
643
  AllDlRoutes.get('/api/v1/dl/capcut', authenticateApiKey, apiLimiter, async (req, res) => {
644
  try {
645
+ const apiKey = req.headers['x-api-key'];
646
+ const userAgent = req.headers['user-agent'];
647
+
648
+ const xForwardedFor = req.headers['x-forwarded-for'];
649
+ const xRealIP = req.headers['x-real-ip'];
650
+ const cfConnectingIP = req.headers['cf-connecting-ip'];
651
+
652
+ let realIP = req.ip;
653
+
654
+ if (xForwardedFor) {
655
+ realIP = xForwardedFor.split(',')[0].trim();
656
+ } else if (xRealIP) {
657
+ realIP = xRealIP;
658
+ } else if (cfConnectingIP) {
659
+ realIP = cfConnectingIP;
660
+ }
661
+
662
+ req.realIP = realIP;
663
+
664
+ console.log(`πŸ” Captured IPs:`, { xForwardedFor, xRealIP, cfConnectingIP, realIP });
665
+
666
+ const keyDoc = await db.findOne({ key: apiKey });
667
+
668
+ if (!keyDoc) {
669
+ return res.status(403).json({ error: "Invalid API Key." });
670
+ }
671
  const url = req.query.url;
672
 
673
  if (!url) {
674
  return res.status(400).json({ error: "URL parameter is required." });
675
  }
676
+ await TelegramUseLog(
677
+ keyDoc.owner,
678
+ keyDoc.key,
679
+ `Accessed: ${req.path}\nRealIP: ${realIP}\nUser-Agent: ${userAgent}`
680
+ );
681
  const results = capcutdl(url);
682
  res.json({ results });
683
  } catch (error) {
 
717
  */
718
  AllDlRoutes.get('/api/v1/dl/instagram', authenticateApiKey, apiLimiter, async (req, res) => {
719
  try {
720
+ const apiKey = req.headers['x-api-key'];
721
+ const userAgent = req.headers['user-agent'];
722
+
723
+ const xForwardedFor = req.headers['x-forwarded-for'];
724
+ const xRealIP = req.headers['x-real-ip'];
725
+ const cfConnectingIP = req.headers['cf-connecting-ip'];
726
+
727
+ let realIP = req.ip;
728
+
729
+ if (xForwardedFor) {
730
+ realIP = xForwardedFor.split(',')[0].trim();
731
+ } else if (xRealIP) {
732
+ realIP = xRealIP;
733
+ } else if (cfConnectingIP) {
734
+ realIP = cfConnectingIP;
735
+ }
736
+
737
+ req.realIP = realIP;
738
+
739
+ console.log(`πŸ” Captured IPs:`, { xForwardedFor, xRealIP, cfConnectingIP, realIP });
740
+
741
+ const keyDoc = await db.findOne({ key: apiKey });
742
+
743
+ if (!keyDoc) {
744
+ return res.status(403).json({ error: "Invalid API Key." });
745
+ }
746
  const url = req.query.url;
747
 
748
  if (!url) {
749
  return res.status(400).json({ error: "URL parameter is required." });
750
  }
751
+ await TelegramUseLog(
752
+ keyDoc.owner,
753
+ keyDoc.key,
754
+ `Accessed: ${req.path}\nRealIP: ${realIP}\nUser-Agent: ${userAgent}`
755
+ );
756
  const results = await InstagramDownloader(url);
757
  res.json({ results });
758
  } catch (error) {
 
791
  */
792
  AllDlRoutes.get('/api/v1/dl/twitter', authenticateApiKey, apiLimiter, async (req, res) => {
793
  try {
794
+ const apiKey = req.headers['x-api-key'];
795
+ const userAgent = req.headers['user-agent'];
796
+
797
+ const xForwardedFor = req.headers['x-forwarded-for'];
798
+ const xRealIP = req.headers['x-real-ip'];
799
+ const cfConnectingIP = req.headers['cf-connecting-ip'];
800
+
801
+ let realIP = req.ip;
802
+
803
+ if (xForwardedFor) {
804
+ realIP = xForwardedFor.split(',')[0].trim();
805
+ } else if (xRealIP) {
806
+ realIP = xRealIP;
807
+ } else if (cfConnectingIP) {
808
+ realIP = cfConnectingIP;
809
+ }
810
+
811
+ req.realIP = realIP;
812
+
813
+ console.log(`πŸ” Captured IPs:`, { xForwardedFor, xRealIP, cfConnectingIP, realIP });
814
+
815
+ const keyDoc = await db.findOne({ key: apiKey });
816
+
817
+ if (!keyDoc) {
818
+ return res.status(403).json({ error: "Invalid API Key." });
819
+ }
820
  const url = req.query.url;
821
 
822
  if (!url) {
823
  return res.status(400).json({ error: "URL parameter is required." });
824
  }
825
+ await TelegramUseLog(
826
+ keyDoc.owner,
827
+ keyDoc.key,
828
+ `Accessed: ${req.path}\nRealIP: ${realIP}\nUser-Agent: ${userAgent}`
829
+ );
830
  const results = await TwitterDownloader(url);
831
  res.json({ results });
832
  } catch (error) {
 
865
  */
866
  AllDlRoutes.get('/api/v1/dl/sfilemobi', authenticateApiKey, apiLimiter, async (req, res) => {
867
  try {
868
+ const apiKey = req.headers['x-api-key'];
869
+ const userAgent = req.headers['user-agent'];
870
+
871
+ const xForwardedFor = req.headers['x-forwarded-for'];
872
+ const xRealIP = req.headers['x-real-ip'];
873
+ const cfConnectingIP = req.headers['cf-connecting-ip'];
874
+
875
+ let realIP = req.ip;
876
+
877
+ if (xForwardedFor) {
878
+ realIP = xForwardedFor.split(',')[0].trim();
879
+ } else if (xRealIP) {
880
+ realIP = xRealIP;
881
+ } else if (cfConnectingIP) {
882
+ realIP = cfConnectingIP;
883
+ }
884
+
885
+ req.realIP = realIP;
886
+
887
+ console.log(`πŸ” Captured IPs:`, { xForwardedFor, xRealIP, cfConnectingIP, realIP });
888
+
889
+ const keyDoc = await db.findOne({ key: apiKey });
890
+
891
+ if (!keyDoc) {
892
+ return res.status(403).json({ error: "Invalid API Key." });
893
+ }
894
  const url = req.query.url;
895
 
896
  if (!url) {
897
  return res.status(400).json({ error: "URL parameter is required." });
898
  }
899
+ await TelegramUseLog(
900
+ keyDoc.owner,
901
+ keyDoc.key,
902
+ `Accessed: ${req.path}\nRealIP: ${realIP}\nUser-Agent: ${userAgent}`
903
+ );
904
  const results = await sfilemobi(url);
905
  res.json({ results });
906
  } catch (error) {
 
939
  */
940
  AllDlRoutes.get('/api/v1/dl/tiktok', authenticateApiKey, apiLimiter, async (req, res) => {
941
  try {
942
+ const apiKey = req.headers['x-api-key'];
943
+ const userAgent = req.headers['user-agent'];
944
+
945
+ const xForwardedFor = req.headers['x-forwarded-for'];
946
+ const xRealIP = req.headers['x-real-ip'];
947
+ const cfConnectingIP = req.headers['cf-connecting-ip'];
948
+
949
+ let realIP = req.ip;
950
+
951
+ if (xForwardedFor) {
952
+ realIP = xForwardedFor.split(',')[0].trim();
953
+ } else if (xRealIP) {
954
+ realIP = xRealIP;
955
+ } else if (cfConnectingIP) {
956
+ realIP = cfConnectingIP;
957
+ }
958
+
959
+ req.realIP = realIP;
960
+
961
+ console.log(`πŸ” Captured IPs:`, { xForwardedFor, xRealIP, cfConnectingIP, realIP });
962
+
963
+ const keyDoc = await db.findOne({ key: apiKey });
964
+
965
+ if (!keyDoc) {
966
+ return res.status(403).json({ error: "Invalid API Key." });
967
+ }
968
  const url = req.query.url;
969
 
970
  if (!url) {
971
  return res.status(400).json({ error: "URL parameter is required." });
972
  }
973
+ await TelegramUseLog(
974
+ keyDoc.owner,
975
+ keyDoc.key,
976
+ `Accessed: ${req.path}\nRealIP: ${realIP}\nUser-Agent: ${userAgent}`
977
+ );
978
  const results = await TiktokDownloader(url);
979
  res.json({ results });
980
  } catch (error) {
 
1012
  * description: Internal Server Error
1013
  */
1014
  AllDlRoutes.get('/api/v1/dl/tiktok-v2', authenticateApiKey, apiLimiter, async (req, res) => {
 
 
 
1015
  try {
1016
  const apiKey = req.headers['x-api-key'];
1017
  const userAgent = req.headers['user-agent'];
 
1092
  */
1093
  AllDlRoutes.get('/api/v1/dl/fb', authenticateApiKey, apiLimiter, async (req, res) => {
1094
  try {
1095
+ const apiKey = req.headers['x-api-key'];
1096
+ const userAgent = req.headers['user-agent'];
1097
+
1098
+ const xForwardedFor = req.headers['x-forwarded-for'];
1099
+ const xRealIP = req.headers['x-real-ip'];
1100
+ const cfConnectingIP = req.headers['cf-connecting-ip'];
1101
+
1102
+ let realIP = req.ip;
1103
+
1104
+ if (xForwardedFor) {
1105
+ realIP = xForwardedFor.split(',')[0].trim();
1106
+ } else if (xRealIP) {
1107
+ realIP = xRealIP;
1108
+ } else if (cfConnectingIP) {
1109
+ realIP = cfConnectingIP;
1110
+ }
1111
+
1112
+ req.realIP = realIP;
1113
+
1114
+ console.log(`πŸ” Captured IPs:`, { xForwardedFor, xRealIP, cfConnectingIP, realIP });
1115
+
1116
+ const keyDoc = await db.findOne({ key: apiKey });
1117
+
1118
+ if (!keyDoc) {
1119
+ return res.status(403).json({ error: "Invalid API Key." });
1120
+ }
1121
+
1122
  const url = req.query.url;
1123
  if (!url) {
1124
  return res.status(400).json({ error: "url parameter is required." });
 
1132
  for (const audio of results.audio) {
1133
  audio.url = await audio.download();
1134
  }
1135
+
1136
+ await TelegramUseLog(
1137
+ keyDoc.owner,
1138
+ keyDoc.key,
1139
+ `Accessed: ${req.path}\nRealIP: ${realIP}\nUser-Agent: ${userAgent}`
1140
+ );
1141
  res.json({ results });
1142
  } catch (error) {
1143
  res.status(500).json({ error: error.message });
 
1175
  */
1176
  AllDlRoutes.get('/api/v1/dl/snapsave', authenticateApiKey, apiLimiter, async (req, res) => {
1177
  try {
1178
+ const apiKey = req.headers['x-api-key'];
1179
+ const userAgent = req.headers['user-agent'];
1180
+
1181
+ const xForwardedFor = req.headers['x-forwarded-for'];
1182
+ const xRealIP = req.headers['x-real-ip'];
1183
+ const cfConnectingIP = req.headers['cf-connecting-ip'];
1184
+
1185
+ let realIP = req.ip;
1186
+
1187
+ if (xForwardedFor) {
1188
+ realIP = xForwardedFor.split(',')[0].trim();
1189
+ } else if (xRealIP) {
1190
+ realIP = xRealIP;
1191
+ } else if (cfConnectingIP) {
1192
+ realIP = cfConnectingIP;
1193
+ }
1194
+
1195
+ req.realIP = realIP;
1196
+
1197
+ console.log(`πŸ” Captured IPs:`, { xForwardedFor, xRealIP, cfConnectingIP, realIP });
1198
+
1199
+ const keyDoc = await db.findOne({ key: apiKey });
1200
+
1201
+ if (!keyDoc) {
1202
+ return res.status(403).json({ error: "Invalid API Key." });
1203
+ }
1204
+
1205
  const url = req.query.url;
1206
 
1207
  if (!url) {
1208
  return res.status(400).json({ error: "url parameter is required." });
1209
  }
1210
+ await TelegramUseLog(
1211
+ keyDoc.owner,
1212
+ keyDoc.key,
1213
+ `Accessed: ${req.path}\nRealIP: ${realIP}\nUser-Agent: ${userAgent}`
1214
+ );
1215
  const results = await snapsave(url);
1216
  res.json({ results });
1217
  } catch (error) {
 
1250
  */
1251
  AllDlRoutes.get('/api/v1/dl/savefrom', authenticateApiKey, apiLimiter, async (req, res) => {
1252
  try {
1253
+ const apiKey = req.headers['x-api-key'];
1254
+ const userAgent = req.headers['user-agent'];
1255
+
1256
+ const xForwardedFor = req.headers['x-forwarded-for'];
1257
+ const xRealIP = req.headers['x-real-ip'];
1258
+ const cfConnectingIP = req.headers['cf-connecting-ip'];
1259
+
1260
+ let realIP = req.ip;
1261
+
1262
+ if (xForwardedFor) {
1263
+ realIP = xForwardedFor.split(',')[0].trim();
1264
+ } else if (xRealIP) {
1265
+ realIP = xRealIP;
1266
+ } else if (cfConnectingIP) {
1267
+ realIP = cfConnectingIP;
1268
+ }
1269
+
1270
+ req.realIP = realIP;
1271
+
1272
+ console.log(`πŸ” Captured IPs:`, { xForwardedFor, xRealIP, cfConnectingIP, realIP });
1273
+
1274
+ const keyDoc = await db.findOne({ key: apiKey });
1275
+
1276
+ if (!keyDoc) {
1277
+ return res.status(403).json({ error: "Invalid API Key." });
1278
+ }
1279
  const url = req.query.url;
1280
 
1281
  if (!url) {
1282
  return res.status(400).json({ error: "url parameter is required." });
1283
  }
1284
+ await TelegramUseLog(
1285
+ keyDoc.owner,
1286
+ keyDoc.key,
1287
+ `Accessed: ${req.path}\nRealIP: ${realIP}\nUser-Agent: ${userAgent}`
1288
+ );
1289
  const results = await savefrom(url);
1290
  res.json({ results });
1291
  } catch (error) {
 
1324
  */
1325
  AllDlRoutes.get('/api/v1/dl/xnxx', authenticateApiKey, apiLimiter, async (req, res) => {
1326
  try {
1327
+ const apiKey = req.headers['x-api-key'];
1328
+ const userAgent = req.headers['user-agent'];
1329
+
1330
+ const xForwardedFor = req.headers['x-forwarded-for'];
1331
+ const xRealIP = req.headers['x-real-ip'];
1332
+ const cfConnectingIP = req.headers['cf-connecting-ip'];
1333
+
1334
+ let realIP = req.ip;
1335
+
1336
+ if (xForwardedFor) {
1337
+ realIP = xForwardedFor.split(',')[0].trim();
1338
+ } else if (xRealIP) {
1339
+ realIP = xRealIP;
1340
+ } else if (cfConnectingIP) {
1341
+ realIP = cfConnectingIP;
1342
+ }
1343
+
1344
+ req.realIP = realIP;
1345
+
1346
+ console.log(`πŸ” Captured IPs:`, { xForwardedFor, xRealIP, cfConnectingIP, realIP });
1347
+
1348
+ const keyDoc = await db.findOne({ key: apiKey });
1349
+
1350
+ if (!keyDoc) {
1351
+ return res.status(403).json({ error: "Invalid API Key." });
1352
+ }
1353
  const q = req.query.q;
1354
 
1355
  if (!q) {
1356
  return res.status(400).json({ error: "q parameter is required." });
1357
  }
1358
+ await TelegramUseLog(
1359
+ keyDoc.owner,
1360
+ keyDoc.key,
1361
+ `Accessed: ${req.path}\nRealIP: ${realIP}\nUser-Agent: ${userAgent}`
1362
+ );
1363
  const results = await XnxxDownloader(q);
1364
  res.json({ results });
1365
  } catch (error) {