better-ani-scraped 1.6.7 → 1.6.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,9 +2,9 @@ import { AnimeScraper } from "../../index.js"; // REPLACE BY "from 'better-ani-s
2
2
 
3
3
  const main = async () => {
4
4
  const animesama = new AnimeScraper('animesama');
5
- const seasonUrl = "https://anime-sama.fr/catalogue/solo-leveling/saison1/vostfr/";
5
+ const seasonUrl = "https://anime-sama.fr/catalogue/one-piece/saison11/vostfr";
6
6
 
7
- const embeds = await animesama.getEmbed(seasonUrl, ["sibnet", "vidmoly", "sendvid"], true, true);
7
+ const embeds = await animesama.getEmbed(seasonUrl, ["smoothpre", "movearnpre", "sibnet", "vidmoly", "sendvid"], true, true);
8
8
 
9
9
  console.log("Embed Links:", JSON.stringify(embeds, null, 2));
10
10
 
@@ -3,8 +3,10 @@ import { getVideoUrlFromEmbed } from "../../index.js"; // REPLACE BY "from 'bett
3
3
  const main = async () => {
4
4
  const embedUrlSibnet = "https://video.sibnet.ru/shell.php?videoid=4291083";
5
5
  const embedUrlSendvid = "https://sendvid.com/embed/4vzpcb0q";
6
- const embedUrlVidmoly = "https://vidmoly.to/embed-vt374ef2joph.html";
6
+ const embedUrlVidmoly = "https://vidmoly.to/embed-rvqrwg5zk37w.html";
7
7
  const embedUrlOneupload = "https://oneupload.net/embed-axdrxh1y3p37.html";
8
+ const embedUrlSmoothpre = "https://smoothpre.com/embed/8294jcf1q8jf";
9
+ const embedUrlMovearnpre = "https://movearnpre.com/embed/e3xbkin87yt3";
8
10
 
9
11
  const videoUrlSibnet = await getVideoUrlFromEmbed("sibnet", embedUrlSibnet)
10
12
  console.log("Video URL Sibnet:", videoUrlSibnet);
@@ -17,6 +19,13 @@ const main = async () => {
17
19
 
18
20
  const videoUrlOneupload = await getVideoUrlFromEmbed("oneupload", embedUrlOneupload)
19
21
  console.log("Video URL Oneupload:", videoUrlOneupload);
22
+
23
+ const videoUrlSmoothpre = await getVideoUrlFromEmbed("smoothpre", embedUrlSmoothpre)
24
+ console.log("Video URL Smoothpre:", videoUrlSmoothpre);
25
+
26
+ const videoUrlMovearnpre = await getVideoUrlFromEmbed("movearnpre", embedUrlMovearnpre)
27
+ console.log("Video URL Movearnpre:", videoUrlMovearnpre);
28
+
20
29
  };
21
30
 
22
31
  main().catch(console.error);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "better-ani-scraped",
3
- "version": "1.6.7",
4
- "description": "Scrape anime data from different sources (only anime-sama.fr for the moment)",
3
+ "version": "1.6.10",
4
+ "description": "Scrape anime data from different sources (only anime-sama.fr, animepahe and crunchyroll for the moment)",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
7
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -187,11 +187,15 @@ export async function getEpisodeTitles(seasonUrl, customChromiumPath) {
187
187
  browser = await puppeteer.launch({
188
188
  headless: true,
189
189
  executablePath,
190
- args: ['--no-sandbox', '--disable-setuid-sandbox'],
190
+ args: [
191
+ '--no-sandbox',
192
+ '--disable-setuid-sandbox',
193
+ ]
194
+
191
195
  });
192
196
 
193
197
  const page = await browser.newPage();
194
-
198
+ await page.setExtraHTTPHeaders(getHeaders(seasonUrl));
195
199
  await page.setRequestInterception(true);
196
200
  page.on('request', (req) => {
197
201
  const blocked = ['image', 'stylesheet', 'font', 'media'];
@@ -201,9 +205,13 @@ export async function getEpisodeTitles(seasonUrl, customChromiumPath) {
201
205
  req.continue();
202
206
  }
203
207
  });
204
-
208
+ await page.setUserAgent('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 ' + '(KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36');
209
+ await page.evaluateOnNewDocument(() => {
210
+ Object.defineProperty(navigator, 'webdriver', { get: () => false });
211
+ });
205
212
  await page.goto(seasonUrl, { waitUntil: 'domcontentloaded' });
206
213
  await page.waitForSelector('#selectEpisodes');
214
+
207
215
 
208
216
  const titres = await page.$$eval('#selectEpisodes option', options =>
209
217
  options.map(o => o.textContent.trim())
@@ -248,7 +256,7 @@ export async function getEmbed(
248
256
  .get(scriptUrl, { headers: getHeaders(seasonUrl) })
249
257
  .then((r) => r.data);
250
258
 
251
- const matches = [...episodesJs.matchAll(/var\s+(eps\d+)\s*=\s*(\[[^\]]+\])/g)];
259
+ const matches = [...episodesJs.toLowerCase().matchAll(/var\s+(eps\d+)\s*=\s*(\[[^\]]+\])/g)];
252
260
  if (!matches.length) throw new Error("No episode arrays found");
253
261
 
254
262
  let episodeMatrix = [];
@@ -271,18 +279,18 @@ export async function getEmbed(
271
279
 
272
280
  for (const host of hostPriority) {
273
281
  for (const arr of episodeMatrix) {
274
- if (i < arr.length && arr[i].includes(host)) {
275
- if (!hosts.includes(host)) {
282
+ if (i < arr.length && arr[i].includes(host.toLowerCase())) {
283
+ if (!hosts.includes(host.toLowerCase())) {
276
284
  urls.push(arr[i]);
277
- hosts.push(host);
285
+ hosts.push(host.toLowerCase());
278
286
  }
279
- break; // une seule URL par host
287
+ break;
280
288
  }
281
289
  }
282
290
  }
283
291
 
284
292
  finalEmbeds.push({
285
- title: null, // à remplir plus tard
293
+ title: null,
286
294
  url: urls.length ? urls : null,
287
295
  host: hosts.length ? hosts : null,
288
296
  });
@@ -293,9 +301,9 @@ export async function getEmbed(
293
301
 
294
302
  for (const host of hostPriority) {
295
303
  for (const arr of episodeMatrix) {
296
- if (i < arr.length && arr[i].includes(host)) {
304
+ if (i < arr.length && arr[i].includes(host.toLowerCase())) {
297
305
  selectedUrl = arr[i];
298
- selectedHost = host;
306
+ selectedHost = host.toLowerCase();
299
307
  break;
300
308
  }
301
309
  }
@@ -303,7 +311,7 @@ export async function getEmbed(
303
311
  }
304
312
 
305
313
  finalEmbeds.push({
306
- title: null, // à remplir plus tard
314
+ title: null,
307
315
  url: selectedUrl || null,
308
316
  host: selectedHost || null,
309
317
  });
@@ -601,4 +609,3 @@ export async function getRandomAnime(
601
609
  return null;
602
610
  }
603
611
  }
604
-
@@ -10,6 +10,9 @@ export async function getVideoUrlFromEmbed(source, embedUrl) {
10
10
  if (source === "vidmoly" || source === "oneupload" ) {
11
11
  return await extractor.getVidmolyOrOneuploadVideo(embedUrl);
12
12
  }
13
+ if (source === "movearnpre" || source === "smoothpre" ) {
14
+ return await extractor.getMovearnpreOrSmoothpreVideo(embedUrl);
15
+ }
13
16
 
14
17
  throw new Error(`Unsupported embed source: ${source}`);
15
18
  }
@@ -53,11 +53,13 @@ export async function getSendvidVideo(embedUrl) {
53
53
 
54
54
  export async function getVidmolyOrOneuploadVideo(embedUrl) {
55
55
  try {
56
+ if (embedUrl.includes("vidmoly.to/")) {
57
+ embedUrl = embedUrl.replace("vidmoly.to/", "vidmoly.net/");
58
+ }
56
59
  console.log(embedUrl)
57
60
  const { data } = await axios.get(embedUrl, {
58
61
  headers: getHeaders(embedUrl),
59
62
  });
60
- console.log(data)
61
63
  const $ = cheerio.load(data);
62
64
  const scripts = $("script");
63
65
 
@@ -74,3 +76,28 @@ export async function getVidmolyOrOneuploadVideo(embedUrl) {
74
76
  return null;
75
77
  }
76
78
  }
79
+
80
+ import puppeteer from 'puppeteer';
81
+
82
+ export async function getMovearnpreOrSmoothpreVideo(embedUrl) {
83
+ const browser = await puppeteer.launch({ headless: true });
84
+ const page = await browser.newPage();
85
+
86
+ await page.setUserAgent(
87
+ "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36"
88
+ );
89
+
90
+ await page.goto(embedUrl, { waitUntil: 'networkidle2' });
91
+
92
+ await page.waitForFunction('typeof jwplayer !== "undefined"');
93
+
94
+ const videoUrl = await page.evaluate(() => {
95
+ const player = jwplayer();
96
+ const sources = player?.getPlaylist()?.[0]?.sources;
97
+ return sources?.[0]?.file || null;
98
+ });
99
+
100
+ await browser.close();
101
+ const finalUrl = embedUrl.split("/").slice(0, 3).join("/") + videoUrl
102
+ return finalUrl;
103
+ }