Update server.js
Browse files
server.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
const express = require('express');
|
| 2 |
const axios = require('axios');
|
| 3 |
const cheerio = require('cheerio');
|
| 4 |
-
const puppeteer = require('puppeteer');
|
| 5 |
|
| 6 |
const app = express();
|
| 7 |
const PORT = 7860;
|
|
@@ -84,7 +84,12 @@ async function getEpisodeInfo(episodeUrl, animeTitle, episodeNumber) {
|
|
| 84 |
|
| 85 |
async function getVideoLinks(downloadPageUrl) {
|
| 86 |
console.log(`Opening Puppeteer: ${downloadPageUrl}`);
|
| 87 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
const page = await browser.newPage();
|
| 89 |
|
| 90 |
try {
|
|
@@ -104,20 +109,11 @@ async function getVideoLinks(downloadPageUrl) {
|
|
| 104 |
|
| 105 |
await browser.close();
|
| 106 |
|
| 107 |
-
|
| 108 |
-
const directDownloadLinks = {};
|
| 109 |
-
for (const link of videoLinks) {
|
| 110 |
-
const directLink = await getFinalMp4Link(link.url);
|
| 111 |
-
if (link.quality.includes('360')) directDownloadLinks["360p"] = directLink;
|
| 112 |
-
if (link.quality.includes('480')) directDownloadLinks["480p"] = directLink;
|
| 113 |
-
if (link.quality.includes('720')) directDownloadLinks["720p"] = directLink;
|
| 114 |
-
}
|
| 115 |
-
|
| 116 |
-
return directDownloadLinks;
|
| 117 |
} catch (error) {
|
| 118 |
console.error("Error extracting video links:", error.message);
|
| 119 |
await browser.close();
|
| 120 |
-
return
|
| 121 |
}
|
| 122 |
}
|
| 123 |
|
|
|
|
| 1 |
const express = require('express');
|
| 2 |
const axios = require('axios');
|
| 3 |
const cheerio = require('cheerio');
|
| 4 |
+
const puppeteer = require('puppeteer-core');
|
| 5 |
|
| 6 |
const app = express();
|
| 7 |
const PORT = 7860;
|
|
|
|
| 84 |
|
| 85 |
async function getVideoLinks(downloadPageUrl) {
|
| 86 |
console.log(`Opening Puppeteer: ${downloadPageUrl}`);
|
| 87 |
+
|
| 88 |
+
const browser = await puppeteer.launch({
|
| 89 |
+
executablePath: "/usr/bin/chromium",
|
| 90 |
+
args: ["--no-sandbox", "--disable-setuid-sandbox"]
|
| 91 |
+
});
|
| 92 |
+
|
| 93 |
const page = await browser.newPage();
|
| 94 |
|
| 95 |
try {
|
|
|
|
| 109 |
|
| 110 |
await browser.close();
|
| 111 |
|
| 112 |
+
return videoLinks;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 113 |
} catch (error) {
|
| 114 |
console.error("Error extracting video links:", error.message);
|
| 115 |
await browser.close();
|
| 116 |
+
return [];
|
| 117 |
}
|
| 118 |
}
|
| 119 |
|