Closure-RI commited on
Commit
41a09b0
·
verified ·
1 Parent(s): 33105ff

Update index.js

Browse files
Files changed (1) hide show
  1. index.js +39 -19
index.js CHANGED
@@ -1275,25 +1275,45 @@ async function scrapeHAnimeDetails(url) {
1275
  : null;
1276
 
1277
  if (dataId) {
1278
- console.log("Data-ID URL:", dataId);
1279
-
1280
- // Ambil konten dari data-id
1281
- const responseB = await axios.get(`https://arashicode-api.hf.space/html?url=${dataId}`);
1282
- const newPageHTML = responseB.data;
1283
- console.log("Data-ID URL:", newPageHTML);
1284
-
1285
- // Cari video URL
1286
- const newPageCheerio = cheerio.load(newPageHTML);
1287
- newPageCheerio("script").each((i, script) => {
1288
- const scriptContent = newPageCheerio(script).html();
1289
- if (scriptContent && scriptContent.includes("jwplayer.setup")) {
1290
- const match = scriptContent.match(/file:\s*"(https?:\/\/[^"]+\.mp4)"/);
1291
- if (match && match[1]) {
1292
- result.video = match[1];
1293
- }
1294
- }
1295
- });
1296
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1297
 
1298
  await browser.close();
1299
  return result;
 
1275
  : null;
1276
 
1277
  if (dataId) {
1278
+ console.log("Data-ID URL:", dataId);
1279
+
1280
+ // Ambil konten dari data-id
1281
+ const responseB = await axios.get(`https://arashicode-api.hf.space/html?url=${dataId}`);
1282
+ const newPageHTML = responseB.data;
1283
+ console.log("HTML Konten Data-ID:", newPageHTML);
1284
+
1285
+ // Cari script yang mengandung konfigurasi jwplayer.setup
1286
+ const scriptTagRegex = /<script\b[^>]*>([\s\S]*?)<\/script>/g;
1287
+ let scriptContent;
1288
+ let match;
1289
+
1290
+ // Iterasi semua <script> tag dalam HTML
1291
+ while ((match = scriptTagRegex.exec(newPageHTML)) !== null) {
1292
+ const scriptBody = match[1];
1293
+ if (scriptBody && scriptBody.includes("jwplayer.setup")) {
1294
+ scriptContent = scriptBody;
1295
+ break;
1296
+ }
1297
+ }
1298
+
1299
+ if (scriptContent) {
1300
+ console.log("Konten Script JWPlayer:", scriptContent);
1301
+
1302
+ // Ekstrak URL video dari script
1303
+ const videoUrlRegex = /file:\s*"(https?:\/\/[^"]+\.mp4)"/;
1304
+ const videoMatch = scriptContent.match(videoUrlRegex);
1305
+
1306
+ if (videoMatch && videoMatch[1]) {
1307
+ result.video = videoMatch[1];
1308
+ console.log("Video URL:", result.video);
1309
+ } else {
1310
+ console.log("Video URL tidak ditemukan dalam script!");
1311
+ }
1312
+ } else {
1313
+ console.log("Script JWPlayer tidak ditemukan dalam HTML!");
1314
+ }
1315
+ }
1316
+
1317
 
1318
  await browser.close();
1319
  return result;