Update index.js
Browse files
index.js
CHANGED
|
@@ -381,46 +381,42 @@ async function twitterDL(url) {
|
|
| 381 |
method: 'POST',
|
| 382 |
body: form,
|
| 383 |
headers: {
|
| 384 |
-
|
| 385 |
'X-Forwarded-For': generateRandomIP(),
|
| 386 |
-
|
| 387 |
-
}
|
| 388 |
});
|
| 389 |
|
| 390 |
let data = await response.json();
|
| 391 |
-
|
| 392 |
const $ = cheerio.load(data?.data);
|
| 393 |
-
|
|
|
|
| 394 |
$('.dl-action a').each((index, element) => {
|
| 395 |
const format = $(element).text().trim();
|
| 396 |
const url = $(element).attr('href');
|
|
|
|
| 397 |
downloads.push({ format, url });
|
|
|
|
| 398 |
});
|
| 399 |
|
| 400 |
-
const convertToMP3 = {
|
| 401 |
-
url: $('.tw-middle a').attr('href')
|
| 402 |
-
};
|
| 403 |
-
|
| 404 |
-
const result = {
|
| 405 |
-
downloads,
|
| 406 |
-
convert_to_mp3: convertToMP3
|
| 407 |
-
};
|
| 408 |
-
|
| 409 |
-
const hrefArray = [];
|
| 410 |
-
|
| 411 |
$('a').each((index, element) => {
|
| 412 |
const href = $(element).attr('href');
|
| 413 |
if (href && href !== '/' && href !== '#') {
|
| 414 |
-
|
| 415 |
}
|
| 416 |
});
|
| 417 |
|
| 418 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 419 |
} catch (error) {
|
| 420 |
return error;
|
| 421 |
}
|
| 422 |
}
|
| 423 |
|
|
|
|
| 424 |
const app = express();
|
| 425 |
app.set('json spaces', 4);
|
| 426 |
app.use(morgan('dev'));
|
|
|
|
| 381 |
method: 'POST',
|
| 382 |
body: form,
|
| 383 |
headers: {
|
| 384 |
+
'User-Agent': generateRandomUserAgent(),
|
| 385 |
'X-Forwarded-For': generateRandomIP(),
|
| 386 |
+
...form.getHeaders()
|
| 387 |
+
}
|
| 388 |
});
|
| 389 |
|
| 390 |
let data = await response.json();
|
|
|
|
| 391 |
const $ = cheerio.load(data?.data);
|
| 392 |
+
let downloads = [];
|
| 393 |
+
|
| 394 |
$('.dl-action a').each((index, element) => {
|
| 395 |
const format = $(element).text().trim();
|
| 396 |
const url = $(element).attr('href');
|
| 397 |
+
if (url !== '#') {
|
| 398 |
downloads.push({ format, url });
|
| 399 |
+
}
|
| 400 |
});
|
| 401 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 402 |
$('a').each((index, element) => {
|
| 403 |
const href = $(element).attr('href');
|
| 404 |
if (href && href !== '/' && href !== '#') {
|
| 405 |
+
downloads.push(href);
|
| 406 |
}
|
| 407 |
});
|
| 408 |
|
| 409 |
+
const result = {
|
| 410 |
+
downloads
|
| 411 |
+
};
|
| 412 |
+
|
| 413 |
+
return { result };
|
| 414 |
} catch (error) {
|
| 415 |
return error;
|
| 416 |
}
|
| 417 |
}
|
| 418 |
|
| 419 |
+
|
| 420 |
const app = express();
|
| 421 |
app.set('json spaces', 4);
|
| 422 |
app.use(morgan('dev'));
|