randydev commited on
Commit
245a10c
Β·
verified Β·
1 Parent(s): c1fb847

Upload alldownloader.js

Browse files
Files changed (1) hide show
  1. plugins/alldownloader.js +192 -2
plugins/alldownloader.js CHANGED
@@ -91,7 +91,39 @@ async function downloadMedia(media) {
91
  */
92
  AllDlRoutes.get('/api/v1/dl/twitter-v3', async (req, res) => {
93
  try {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
  const q = req.query.url;
 
 
 
 
 
 
95
  const results = await TwitterDownloderV3(q);
96
  res.json({ message: results });
97
  } catch (error) {
@@ -131,7 +163,39 @@ AllDlRoutes.get('/api/v1/dl/twitter-v3', async (req, res) => {
131
  */
132
  AllDlRoutes.get('/api/v1/dl/twitter-v2', async (req, res) => {
133
  try {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134
  const q = req.query.url;
 
 
 
 
 
 
135
  const results = await TwitterDownloaderV2(q);
136
  res.json({ message: results });
137
  } catch (error) {
@@ -171,11 +235,43 @@ AllDlRoutes.get('/api/v1/dl/twitter-v2', async (req, res) => {
171
  */
172
  AllDlRoutes.get('/api/v1/dl/xnxx-info-v2', authenticateApiKey, apiLimiter, async (req, res) => {
173
  try {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
174
  const q = req.query.url;
175
 
176
  if (!q) {
177
  return res.status(400).json({ error: "url parameter is required." });
178
  }
 
 
 
 
 
 
179
  const results = await XInfoDownloaderV2(q);
180
  res.json({ message: results });
181
  } catch (error) {
@@ -215,11 +311,42 @@ AllDlRoutes.get('/api/v1/dl/xnxx-info-v2', authenticateApiKey, apiLimiter, async
215
  */
216
  AllDlRoutes.get('/api/v1/dl/xnxx-search-v2', authenticateApiKey, apiLimiter, async (req, res) => {
217
  try {
218
- const q = req.query.q;
 
219
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
220
  if (!q) {
221
  return res.status(400).json({ error: "q parameter is required." });
222
  }
 
 
 
 
 
 
223
  const results = await XsearchDownloaderV2(q);
224
  res.json({ message: results });
225
  // console.dir(testings);
@@ -260,11 +387,43 @@ AllDlRoutes.get('/api/v1/dl/xnxx-search-v2', authenticateApiKey, apiLimiter, asy
260
  */
261
  AllDlRoutes.get('/api/v1/dl/instagram-v4', authenticateApiKey, apiLimiter, async (req, res) => {
262
  try {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
263
  const q = req.query.url;
264
 
265
  if (!q) {
266
  return res.status(400).json({ error: "URL parameter is required." });
267
  }
 
 
 
 
 
 
268
  const results = await InstagramDLV4(q);
269
  res.json({ results });
270
  } catch (error) {
@@ -305,11 +464,42 @@ AllDlRoutes.get('/api/v1/dl/instagram-v4', authenticateApiKey, apiLimiter, async
305
  */
306
  AllDlRoutes.get('/api/v1/dl/instagram-v3', authenticateApiKey, apiLimiter, async (req, res) => {
307
  try {
308
- const q = req.query.url;
 
 
 
 
 
 
 
309
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
310
  if (!q) {
311
  return res.status(400).json({ error: "URL parameter is required." });
312
  }
 
 
 
 
 
 
313
  const results = await InstagramDLV3(q);
314
  res.json({ results });
315
  } catch (error) {
 
91
  */
92
  AllDlRoutes.get('/api/v1/dl/twitter-v3', async (req, res) => {
93
  try {
94
+ const apiKey = req.headers['x-api-key'];
95
+ const userAgent = req.headers['user-agent'];
96
+
97
+ const xForwardedFor = req.headers['x-forwarded-for'];
98
+ const xRealIP = req.headers['x-real-ip'];
99
+ const cfConnectingIP = req.headers['cf-connecting-ip'];
100
+
101
+ let realIP = req.ip;
102
+
103
+ if (xForwardedFor) {
104
+ realIP = xForwardedFor.split(',')[0].trim();
105
+ } else if (xRealIP) {
106
+ realIP = xRealIP;
107
+ } else if (cfConnectingIP) {
108
+ realIP = cfConnectingIP;
109
+ }
110
+
111
+ req.realIP = realIP;
112
+
113
+ console.log(`πŸ” Captured IPs:`, { xForwardedFor, xRealIP, cfConnectingIP, realIP });
114
+
115
+ const keyDoc = await db.findOne({ key: apiKey });
116
+
117
+ if (!keyDoc) {
118
+ return res.status(403).json({ error: "Invalid API Key." });
119
+ }
120
  const q = req.query.url;
121
+ await updateIP(apiKey, realIP);
122
+ await TelegramUseLog(
123
+ keyDoc.owner,
124
+ keyDoc.key,
125
+ `Accessed: ${req.path}\nRealIP: ${realIP}\nUser-Agent: ${userAgent}`
126
+ );
127
  const results = await TwitterDownloderV3(q);
128
  res.json({ message: results });
129
  } catch (error) {
 
163
  */
164
  AllDlRoutes.get('/api/v1/dl/twitter-v2', async (req, res) => {
165
  try {
166
+ const apiKey = req.headers['x-api-key'];
167
+ const userAgent = req.headers['user-agent'];
168
+
169
+ const xForwardedFor = req.headers['x-forwarded-for'];
170
+ const xRealIP = req.headers['x-real-ip'];
171
+ const cfConnectingIP = req.headers['cf-connecting-ip'];
172
+
173
+ let realIP = req.ip;
174
+
175
+ if (xForwardedFor) {
176
+ realIP = xForwardedFor.split(',')[0].trim();
177
+ } else if (xRealIP) {
178
+ realIP = xRealIP;
179
+ } else if (cfConnectingIP) {
180
+ realIP = cfConnectingIP;
181
+ }
182
+
183
+ req.realIP = realIP;
184
+
185
+ console.log(`πŸ” Captured IPs:`, { xForwardedFor, xRealIP, cfConnectingIP, realIP });
186
+
187
+ const keyDoc = await db.findOne({ key: apiKey });
188
+
189
+ if (!keyDoc) {
190
+ return res.status(403).json({ error: "Invalid API Key." });
191
+ }
192
  const q = req.query.url;
193
+ await updateIP(apiKey, realIP);
194
+ await TelegramUseLog(
195
+ keyDoc.owner,
196
+ keyDoc.key,
197
+ `Accessed: ${req.path}\nRealIP: ${realIP}\nUser-Agent: ${userAgent}`
198
+ );
199
  const results = await TwitterDownloaderV2(q);
200
  res.json({ message: results });
201
  } catch (error) {
 
235
  */
236
  AllDlRoutes.get('/api/v1/dl/xnxx-info-v2', authenticateApiKey, apiLimiter, async (req, res) => {
237
  try {
238
+ const apiKey = req.headers['x-api-key'];
239
+ const userAgent = req.headers['user-agent'];
240
+
241
+ const xForwardedFor = req.headers['x-forwarded-for'];
242
+ const xRealIP = req.headers['x-real-ip'];
243
+ const cfConnectingIP = req.headers['cf-connecting-ip'];
244
+
245
+ let realIP = req.ip;
246
+
247
+ if (xForwardedFor) {
248
+ realIP = xForwardedFor.split(',')[0].trim();
249
+ } else if (xRealIP) {
250
+ realIP = xRealIP;
251
+ } else if (cfConnectingIP) {
252
+ realIP = cfConnectingIP;
253
+ }
254
+
255
+ req.realIP = realIP;
256
+
257
+ console.log(`πŸ” Captured IPs:`, { xForwardedFor, xRealIP, cfConnectingIP, realIP });
258
+
259
+ const keyDoc = await db.findOne({ key: apiKey });
260
+
261
+ if (!keyDoc) {
262
+ return res.status(403).json({ error: "Invalid API Key." });
263
+ }
264
  const q = req.query.url;
265
 
266
  if (!q) {
267
  return res.status(400).json({ error: "url parameter is required." });
268
  }
269
+ await updateIP(apiKey, realIP);
270
+ await TelegramUseLog(
271
+ keyDoc.owner,
272
+ keyDoc.key,
273
+ `Accessed: ${req.path}\nRealIP: ${realIP}\nUser-Agent: ${userAgent}`
274
+ );
275
  const results = await XInfoDownloaderV2(q);
276
  res.json({ message: results });
277
  } catch (error) {
 
311
  */
312
  AllDlRoutes.get('/api/v1/dl/xnxx-search-v2', authenticateApiKey, apiLimiter, async (req, res) => {
313
  try {
314
+ const apiKey = req.headers['x-api-key'];
315
+ const userAgent = req.headers['user-agent'];
316
 
317
+ const xForwardedFor = req.headers['x-forwarded-for'];
318
+ const xRealIP = req.headers['x-real-ip'];
319
+ const cfConnectingIP = req.headers['cf-connecting-ip'];
320
+
321
+ let realIP = req.ip;
322
+
323
+ if (xForwardedFor) {
324
+ realIP = xForwardedFor.split(',')[0].trim();
325
+ } else if (xRealIP) {
326
+ realIP = xRealIP;
327
+ } else if (cfConnectingIP) {
328
+ realIP = cfConnectingIP;
329
+ }
330
+
331
+ req.realIP = realIP;
332
+
333
+ console.log(`πŸ” Captured IPs:`, { xForwardedFor, xRealIP, cfConnectingIP, realIP });
334
+
335
+ const keyDoc = await db.findOne({ key: apiKey });
336
+
337
+ if (!keyDoc) {
338
+ return res.status(403).json({ error: "Invalid API Key." });
339
+ }
340
+ const q = req.query.q;
341
  if (!q) {
342
  return res.status(400).json({ error: "q parameter is required." });
343
  }
344
+ await updateIP(apiKey, realIP);
345
+ await TelegramUseLog(
346
+ keyDoc.owner,
347
+ keyDoc.key,
348
+ `Accessed: ${req.path}\nRealIP: ${realIP}\nUser-Agent: ${userAgent}`
349
+ );
350
  const results = await XsearchDownloaderV2(q);
351
  res.json({ message: results });
352
  // console.dir(testings);
 
387
  */
388
  AllDlRoutes.get('/api/v1/dl/instagram-v4', authenticateApiKey, apiLimiter, async (req, res) => {
389
  try {
390
+ const apiKey = req.headers['x-api-key'];
391
+ const userAgent = req.headers['user-agent'];
392
+
393
+ const xForwardedFor = req.headers['x-forwarded-for'];
394
+ const xRealIP = req.headers['x-real-ip'];
395
+ const cfConnectingIP = req.headers['cf-connecting-ip'];
396
+
397
+ let realIP = req.ip;
398
+
399
+ if (xForwardedFor) {
400
+ realIP = xForwardedFor.split(',')[0].trim();
401
+ } else if (xRealIP) {
402
+ realIP = xRealIP;
403
+ } else if (cfConnectingIP) {
404
+ realIP = cfConnectingIP;
405
+ }
406
+
407
+ req.realIP = realIP;
408
+
409
+ console.log(`πŸ” Captured IPs:`, { xForwardedFor, xRealIP, cfConnectingIP, realIP });
410
+
411
+ const keyDoc = await db.findOne({ key: apiKey });
412
+
413
+ if (!keyDoc) {
414
+ return res.status(403).json({ error: "Invalid API Key." });
415
+ }
416
  const q = req.query.url;
417
 
418
  if (!q) {
419
  return res.status(400).json({ error: "URL parameter is required." });
420
  }
421
+ await updateIP(apiKey, realIP);
422
+ await TelegramUseLog(
423
+ keyDoc.owner,
424
+ keyDoc.key,
425
+ `Accessed: ${req.path}\nRealIP: ${realIP}\nUser-Agent: ${userAgent}`
426
+ );
427
  const results = await InstagramDLV4(q);
428
  res.json({ results });
429
  } catch (error) {
 
464
  */
465
  AllDlRoutes.get('/api/v1/dl/instagram-v3', authenticateApiKey, apiLimiter, async (req, res) => {
466
  try {
467
+ const apiKey = req.headers['x-api-key'];
468
+ const userAgent = req.headers['user-agent'];
469
+
470
+ const xForwardedFor = req.headers['x-forwarded-for'];
471
+ const xRealIP = req.headers['x-real-ip'];
472
+ const cfConnectingIP = req.headers['cf-connecting-ip'];
473
+
474
+ let realIP = req.ip;
475
 
476
+ if (xForwardedFor) {
477
+ realIP = xForwardedFor.split(',')[0].trim();
478
+ } else if (xRealIP) {
479
+ realIP = xRealIP;
480
+ } else if (cfConnectingIP) {
481
+ realIP = cfConnectingIP;
482
+ }
483
+
484
+ req.realIP = realIP;
485
+
486
+ console.log(`πŸ” Captured IPs:`, { xForwardedFor, xRealIP, cfConnectingIP, realIP });
487
+
488
+ const keyDoc = await db.findOne({ key: apiKey });
489
+
490
+ if (!keyDoc) {
491
+ return res.status(403).json({ error: "Invalid API Key." });
492
+ }
493
+ const q = req.query.url;
494
  if (!q) {
495
  return res.status(400).json({ error: "URL parameter is required." });
496
  }
497
+ await updateIP(apiKey, realIP);
498
+ await TelegramUseLog(
499
+ keyDoc.owner,
500
+ keyDoc.key,
501
+ `Accessed: ${req.path}\nRealIP: ${realIP}\nUser-Agent: ${userAgent}`
502
+ );
503
  const results = await InstagramDLV3(q);
504
  res.json({ results });
505
  } catch (error) {