better-ani-scraped 1.5.0 → 1.5.1

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.
package/DOCUMENTATION.md CHANGED
@@ -169,8 +169,13 @@ Fetches the full anime catalog, optionally including season information.
169
169
  ```js
170
170
  [
171
171
  {
172
- title: string,
173
172
  url: string,
173
+ title: string,
174
+ altTitles: string[],
175
+ cover: string,
176
+ genres: string[],
177
+ types: string[],
178
+ languages: string[],
174
179
  }
175
180
  ...
176
181
  ]
@@ -302,7 +307,7 @@ Extracts information from all episodes of a season of an anime.
302
307
  ```
303
308
  ---
304
309
 
305
- ## Utility functions
310
+ ## Utility functions
306
311
 
307
312
  - [getVideoUrlFromEmbed](#getvideourlfromembedsource-embedurl)
308
313
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "better-ani-scraped",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
4
4
  "description": "Scrape anime data from different sources (only anime-sama.fr for the moment)",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -343,31 +343,45 @@ export async function getAllAnime(
343
343
  const url = pageNum === 1 ? CATALOGUE_URL : `${CATALOGUE_URL}?page=${pageNum}`;
344
344
  const res = await axios.get(url, { headers: getHeaders(CATALOGUE_URL) });
345
345
  const $ = cheerio.load(res.data);
346
-
346
+
347
347
  const containers = $("div.shrink-0.m-3.rounded.border-2");
348
-
348
+
349
349
  containers.each((_, el) => {
350
350
  const anchor = $(el).find("a");
351
351
  const title = anchor.find("h1").text().trim();
352
352
  const link = anchor.attr("href");
353
-
354
- const tagText = anchor.find("p").filter((_, p) =>
355
- isWanted($(p).text(), wantedTypes)
356
- ).first().text();
357
-
358
- const languageText = anchor.find("p").filter((_, p) =>
359
- isWanted($(p).text(), wantedLanguages)
360
- ).first().text();
361
-
362
- if (title && link && tagText && languageText) {
353
+ const img = anchor.find("img").attr("src");
354
+
355
+ const paragraphs = anchor.find("p").toArray().map(p => $(p).text().trim());
356
+
357
+ const altTitles = paragraphs[0] ? paragraphs[0].split(',').map(name => name.trim()) : [];
358
+ const genres = paragraphs[1] ? paragraphs[1].split(',').map(genre => genre.trim()) : [];
359
+ const type = paragraphs[2] ? paragraphs[2].split(',').map(t => t.trim()) : [];
360
+ const language = paragraphs[3] ? paragraphs[3].split(',').map(lang => lang.trim()) : [];
361
+ const filteredTypes = type.filter(t => isWanted(t, wantedTypes));
362
+ const filteredLanguages = language.filter(lang => isWanted(lang, wantedLanguages));
363
+ if (
364
+ title &&
365
+ link &&
366
+ filteredTypes.length > 0 &&
367
+ filteredLanguages.length > 0
368
+ ) {
363
369
  const fullUrl = link.startsWith("http") ? link : `${BASE_URL}${link}`;
364
- animeLinks.push({ title, url: fullUrl });
370
+ animeLinks.push({
371
+ url: fullUrl,
372
+ title,
373
+ altTitles,
374
+ cover: img,
375
+ genres,
376
+ types: filteredTypes,
377
+ languages: filteredLanguages,
378
+ });
365
379
  }
366
380
  });
367
-
381
+
368
382
  return containers.length > 0;
369
383
  };
370
-
384
+
371
385
  const enrichWithSeasons = async (list) => {
372
386
  for (const anime of list) {
373
387
  try {
@@ -392,7 +406,6 @@ export async function getAllAnime(
392
406
  await new Promise(r => setTimeout(r, 300));
393
407
  }
394
408
 
395
- // Dédupliquer les URLs
396
409
  const uniqueLinks = [...new Map(animeLinks.map(item => [item.url, item])).values()];
397
410
  if (get_seasons) await enrichWithSeasons(uniqueLinks);
398
411
 
@@ -400,7 +413,7 @@ export async function getAllAnime(
400
413
  return true;
401
414
  }
402
415
  } catch (err) {
403
- console.error("🔥 Erreur surpuissante détectée :", err.message);
416
+ console.error("error :", err.message);
404
417
  return false;
405
418
  }
406
419
  }