Spaces:
Running
Running
Update index.js
Browse files
index.js
CHANGED
@@ -1270,21 +1270,25 @@ async function scrapeHAnimeDetails(url) {
|
|
1270 |
await newPage.goto(iframeSrc, { waitUntil: "domcontentloaded" });
|
1271 |
|
1272 |
// Ambil data-id dari elemen <li>
|
1273 |
-
const
|
1274 |
-
|
1275 |
-
|
1276 |
-
|
|
|
|
|
|
|
1277 |
|
1278 |
console.log("Data-ID URL:", dataId);
|
1279 |
|
1280 |
if (dataId) {
|
1281 |
-
//
|
1282 |
-
|
1283 |
-
|
1284 |
-
const
|
|
|
1285 |
|
1286 |
-
|
1287 |
-
const scriptContent =
|
1288 |
if (scriptContent && scriptContent.includes("jwplayer.setup")) {
|
1289 |
const match = scriptContent.match(/file:\s*"(https?:\/\/[^"]+\.mp4)"/);
|
1290 |
if (match && match[1]) {
|
@@ -1309,13 +1313,11 @@ async function scrapeHAnimeDetails(url) {
|
|
1309 |
|
1310 |
// Tutup browser jika ada kesalahan
|
1311 |
await browser.close();
|
1312 |
-
return { error: error
|
1313 |
}
|
1314 |
}
|
1315 |
|
1316 |
|
1317 |
-
|
1318 |
-
|
1319 |
app.get('/hanime/search', async (req, res) => {
|
1320 |
const { query } = req.query;
|
1321 |
if (!query) {
|
|
|
1270 |
await newPage.goto(iframeSrc, { waitUntil: "domcontentloaded" });
|
1271 |
|
1272 |
// Ambil data-id dari elemen <li>
|
1273 |
+
const htmlContent = await newPage.content(); // Ambil seluruh konten HTML halaman
|
1274 |
+
const $ = cheerio.load(htmlContent);
|
1275 |
+
|
1276 |
+
const dataIdElement = $(".servers ul li");
|
1277 |
+
const dataId = dataIdElement.length
|
1278 |
+
? "https://nhplayer.com" + dataIdElement.attr("data-id")
|
1279 |
+
: null;
|
1280 |
|
1281 |
console.log("Data-ID URL:", dataId);
|
1282 |
|
1283 |
if (dataId) {
|
1284 |
+
// Buka halaman data-id menggunakan Puppeteer
|
1285 |
+
await newPage.goto(dataId, { waitUntil: "domcontentloaded" });
|
1286 |
+
|
1287 |
+
const newPageHTML = await newPage.content();
|
1288 |
+
const newPageCheerio = cheerio.load(newPageHTML);
|
1289 |
|
1290 |
+
newPageCheerio("script").each((i, script) => {
|
1291 |
+
const scriptContent = newPageCheerio(script).html();
|
1292 |
if (scriptContent && scriptContent.includes("jwplayer.setup")) {
|
1293 |
const match = scriptContent.match(/file:\s*"(https?:\/\/[^"]+\.mp4)"/);
|
1294 |
if (match && match[1]) {
|
|
|
1313 |
|
1314 |
// Tutup browser jika ada kesalahan
|
1315 |
await browser.close();
|
1316 |
+
return { error: error };
|
1317 |
}
|
1318 |
}
|
1319 |
|
1320 |
|
|
|
|
|
1321 |
app.get('/hanime/search', async (req, res) => {
|
1322 |
const { query } = req.query;
|
1323 |
if (!query) {
|