Update server.js
Browse files
server.js
CHANGED
|
@@ -3,7 +3,7 @@ const { chromium } = require('playwright-chromium');
|
|
| 3 |
const cors = require('cors');
|
| 4 |
|
| 5 |
const app = express();
|
| 6 |
-
const PORT =
|
| 7 |
|
| 8 |
app.use(cors());
|
| 9 |
|
|
@@ -25,14 +25,27 @@ app.get('/download-links', async (req, res) => {
|
|
| 25 |
|
| 26 |
async function getVideoLinks(downloadPageUrl) {
|
| 27 |
console.log(`Opening Playwright: ${downloadPageUrl}`);
|
| 28 |
-
const browser = await chromium.launch({
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
const page = await browser.newPage();
|
| 30 |
|
| 31 |
try {
|
| 32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
-
// Wait for download buttons to
|
| 35 |
-
await page.waitForSelector('a[href*="ggredi.info/download.php"]', { timeout:
|
| 36 |
|
| 37 |
// Extract links
|
| 38 |
const videoLinks = await page.evaluate(() => {
|
|
|
|
| 3 |
const cors = require('cors');
|
| 4 |
|
| 5 |
const app = express();
|
| 6 |
+
const PORT = 3000;
|
| 7 |
|
| 8 |
app.use(cors());
|
| 9 |
|
|
|
|
| 25 |
|
| 26 |
async function getVideoLinks(downloadPageUrl) {
|
| 27 |
console.log(`Opening Playwright: ${downloadPageUrl}`);
|
| 28 |
+
const browser = await chromium.launch({
|
| 29 |
+
headless: true,
|
| 30 |
+
args: [
|
| 31 |
+
"--no-sandbox",
|
| 32 |
+
"--disable-blink-features=AutomationControlled",
|
| 33 |
+
"--disable-dev-shm-usage"
|
| 34 |
+
]
|
| 35 |
+
});
|
| 36 |
+
|
| 37 |
const page = await browser.newPage();
|
| 38 |
|
| 39 |
try {
|
| 40 |
+
// Use stealth mode (prevents bot detection)
|
| 41 |
+
await page.setUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36");
|
| 42 |
+
await page.setViewportSize({ width: 1280, height: 720 });
|
| 43 |
+
|
| 44 |
+
// Navigate to the page (faster, avoids timeout)
|
| 45 |
+
await page.goto(downloadPageUrl, { waitUntil: 'domcontentloaded', timeout: 60000 });
|
| 46 |
|
| 47 |
+
// Wait for the download buttons (increase timeout to 20s)
|
| 48 |
+
await page.waitForSelector('a[href*="ggredi.info/download.php"]', { timeout: 20000 });
|
| 49 |
|
| 50 |
// Extract links
|
| 51 |
const videoLinks = await page.evaluate(() => {
|