Nexchan commited on
Commit
b56131c
Β·
verified Β·
1 Parent(s): 1c06ec8

Update index.js

Browse files
Files changed (1) hide show
  1. index.js +59 -0
index.js CHANGED
@@ -373,6 +373,65 @@ app.get('/html', async (req, res) => {
373
  });
374
 
375
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
376
 
377
  /*
378
  ┏┓┏━┓┏━━━┓┏━┓┏━┓┏━━┓┏┓┏━┓┏┓╋┏┓
 
373
  });
374
 
375
 
376
+ async function XnDl(url) {
377
+ const browser = await puppeteer.launch({
378
+ headless: true,
379
+ args: ['--no-sandbox', '--disable-setuid-sandbox']
380
+ });
381
+
382
+ try {
383
+ const page = await browser.newPage();
384
+ await page.setUserAgent("Mozilla/5.0 (Linux; Android 10; SM-G965U Build/QP1A.190711.020; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/114.0.5735.141 Mobile Safari/537.36 [FB_IAB/FB4A;FBAV/420.0.0.32.61;]");
385
+
386
+ await page.goto(url.replace("xnxx.com", "xnxxvideodownload.com"), { waitUntil: 'networkidle0' });
387
+
388
+ const data = await page.evaluate(() => {
389
+ const title = document.querySelector("body > main > section.e.j.d2.dsection > h2")?.textContent || '';
390
+ const thumbnail = document.querySelector("body > main > section.e.j.d2.dsection > div > div.thumbdiv > img")?.src || '';
391
+ const url = document.querySelector("body > main > section.e.j.d2.dsection > div > div.thumbdiv > a")?.href || '';
392
+
393
+ const table = document.getElementById('dtable')?.getElementsByTagName('table')[0];
394
+ const videoDownload = [];
395
+
396
+ if (table) {
397
+ for (let i = 0; i < table.rows.length; i++) {
398
+ const row = table.rows[i];
399
+ const rowData = {
400
+ quality: row.cells[0]?.innerText || '',
401
+ ext: row.cells[1]?.innerText || '',
402
+ url: row.cells[2]?.getElementsByTagName('a')[0]?.href || ''
403
+ };
404
+ videoDownload.push(rowData);
405
+ }
406
+ }
407
+
408
+ return { title, thumbnail, url, videoDownload };
409
+ });
410
+
411
+ return data;
412
+ } catch (error) {
413
+ console.error('Error:', error);
414
+ return null;
415
+ } finally {
416
+ await browser.close();
417
+ }
418
+ }
419
+
420
+
421
+ app.get('/xnxx', async (req, res) => {
422
+ try {
423
+ const { url } = req.query;
424
+ if (!url) return res.status(400).json({ error: 'Parameter url is required' });
425
+ let result = await XnDl(url);
426
+ res.send(result);
427
+ } catch (error) {
428
+ console.error('Error processing request:', error);
429
+ res.status(500).json({
430
+ error: 'Failed to process request\n' + error
431
+ });
432
+ }
433
+ });
434
+
435
 
436
  /*
437
  ┏┓┏━┓┏━━━┓┏━┓┏━┓┏━━┓┏┓┏━┓┏┓╋┏┓