better-ani-scraped 1.6.2 → 1.6.4

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
@@ -1,8 +1,8 @@
1
- # Better-Ani-Scraped Documentation
1
+ ,,,,# Better-Ani-Scraped Documentation
2
2
 
3
3
  A set of utility functions for scraping anime data from multiple sources (only [anime-sama](https://anime-sama.fr) and [animepahe](https://animepahe.ru) available at the moment). This tool allows you to search for anime, retrieve information, get episodes, and more.
4
4
 
5
- ---
5
+ ---
6
6
 
7
7
  ## Summary
8
8
  - [Main class](#main-class)
@@ -30,7 +30,7 @@ const crunchyroll = new AnimeScraper('crunchyroll') //for Crunchyroll
30
30
  - [searchAnime](#animesamasearchanimequery-limit--10-wantedlanguages--vostfr-vf-vastfr-wantedtypes--anime-film-page--null)
31
31
  - [getSeasons](#animesamagetseasonsanimeurl-language--vostfr)
32
32
  - [getEpisodeTitles](#animesamagetepisodetitlesseasonurl-customchromiumpath)
33
- - [getEmbed](#animesamagetembedseasonurl-hostpriority--sendvid-sibnet-vidmoly-oneupload)
33
+ - [getEmbed](#animesamagetembedseasonurl-hostpriority--sendvid-sibnet-vidmoly-oneupload-allhost--false-includeinfo--false-customchromiumpath)
34
34
  - [getAnimeInfo](#animesamagetanimeinfoanimeurl)
35
35
  - [getAvailableLanguages](#animesamagetavailablelanguagesseasonurl-wantedlanguages--vostfr-vf-va-vkr-vcn-vqc-vf1-vf2-numberepisodes--false)
36
36
  - [getAllAnime](#animesamagetallanimewantedlanguages--vostfr-vf-vastfr-wantedtypes--anime-film-page--null-output--anime_listjson-get_seasons--false)
@@ -80,7 +80,7 @@ Fetches all available seasons of an anime in the specified language.
80
80
  ...
81
81
  ]
82
82
  ```
83
- Or an error object if the language is not available.
83
+ Else, an error object if the language is not available.
84
84
 
85
85
  ---
86
86
 
@@ -95,23 +95,44 @@ Fetches the names of all episodes in a season
95
95
 
96
96
  ---
97
97
 
98
- ### `animesama.getEmbed(seasonUrl, hostPriority = ["sendvid", "sibnet", "vidmoly", "oneupload"])`
98
+ ### `animesama.getEmbed(seasonUrl, hostPriority = ["sendvid", "sibnet", "vidmoly", "oneupload"], allHost = false, includeInfo = false, customChromiumPath)`
99
99
  Retrieves embed URLs for episodes, prioritizing by host.
100
100
 
101
101
  - **Parameters:**
102
102
  - `seasonUrl` *(string)*: URL of the anime’s season page.
103
103
  - `hostPriority` *(string[])*: Array of preferred hostnames.
104
+ - `allHost` *(boolean)*: If `true`, fetches all available embeds contained in *hostPriority*
105
+ - `includeInfo` *(boolean)*: If `true`, also fetches the name of the season and the number of episodes in it
106
+ - `customChromiumPath` *(string)*: Path of the Chromium folder
104
107
  - **Returns:**
105
- An array of embed video:
108
+ An array of embed video if *includeInfo = false* :
106
109
  ```js
107
110
  [
108
111
  {
109
112
  title: string,
110
- url: string,
111
- host: string,
112
- }
113
+ url: string, //string[] if allHost = true
114
+ host: string, //string[] if allHost = true
115
+ },
113
116
  ...
114
117
  ]
118
+ ```
119
+ Else :
120
+ ```js
121
+ {
122
+ episodes :
123
+ [
124
+ {
125
+ title: string,
126
+ url: string, //string[] if allHost = true
127
+ host: string, //string[] if allHost = true
128
+ },
129
+ ...
130
+ ]
131
+ animeInfo : {
132
+ seasonTitle: string,
133
+ episodeCount:number,
134
+ }
135
+ }
115
136
 
116
137
  ```
117
138
  ---
@@ -149,7 +170,7 @@ Checks which languages are available for a given anime season (Avoid using `numb
149
170
  {
150
171
  language: string,
151
172
  episodeCount: number //if numberEpisodes = true
152
- }
173
+ },
153
174
  ...
154
175
  ]
155
176
  ```
@@ -178,7 +199,7 @@ Fetches the full anime catalog, optionally including season information.
178
199
  genres: string[],
179
200
  types: string[],
180
201
  languages: string[],
181
- }
202
+ },
182
203
  ...
183
204
  ]
184
205
  ```
@@ -2,7 +2,7 @@ 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/86-eighty-six/saison1/vostfr/";
5
+ const seasonUrl = "https://anime-sama.fr/catalogue/aggretsuko/saison1/vf/";
6
6
 
7
7
  const animeLanguages = await animesama.getAvailableLanguages(seasonUrl, ["vostfr", "vf", "va", "vkr","vcn", "vqc", "vf1", "vf2"], false);
8
8
  console.log(animeLanguages);
@@ -2,10 +2,12 @@ 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/86-eighty-six/saison1/vostfr/";
5
+ const seasonUrl = "https://anime-sama.fr/catalogue/solo-leveling/saison1/vostfr/";
6
6
 
7
- const embeds = await animesama.getEmbed(seasonUrl, ["sibnet", "vidmoly"], true);
8
- console.log("Embed Links:", embeds);
7
+ const embeds = await animesama.getEmbed(seasonUrl, ["sibnet", "vidmoly", "sendvid"], true, true);
8
+
9
+ console.log("Embed Links:", JSON.stringify(embeds, null, 2));
10
+
9
11
  };
10
12
 
11
13
  main().catch(console.error);
@@ -2,7 +2,7 @@ import { AnimeScraper, getVideoUrlFromEmbed } from "../../index.js"; // REPLACE
2
2
 
3
3
  const main = async () => {
4
4
  const animesama = new AnimeScraper('animesama');
5
- const animeUrl = "https://anime-sama.fr/catalogue/86-eighty-six/";
5
+ const animeUrl = "https://anime-sama.fr/catalogue/one-piece/";
6
6
 
7
7
  const seasons = await animesama.getSeasons(animeUrl, "vostfr");
8
8
  console.log("Seasons:", seasons);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "better-ani-scraped",
3
- "version": "1.6.2",
3
+ "version": "1.6.4",
4
4
  "description": "Scrape anime data from different sources (only anime-sama.fr for the moment)",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -218,7 +218,8 @@ export async function getEpisodeTitles(seasonUrl, customChromiumPath) {
218
218
  export async function getEmbed(
219
219
  seasonUrl,
220
220
  hostPriority = ["sendvid", "sibnet", "vidmoly", "oneupload"],
221
- includeInfo = false,
221
+ allHost = false,
222
+ includeInfo = false,
222
223
  customChromiumPath
223
224
  ) {
224
225
  const res = await axios.get(seasonUrl, {
@@ -260,25 +261,49 @@ export async function getEmbed(
260
261
  const finalEmbeds = [];
261
262
 
262
263
  for (let i = 0; i < maxEpisodes; i++) {
263
- let selectedUrl = null;
264
- let selectedHost = null;
265
-
266
- for (const host of hostPriority) {
267
- for (const arr of episodeMatrix) {
268
- if (i < arr.length && arr[i].includes(host)) {
269
- selectedUrl = arr[i];
270
- selectedHost = host;
271
- break;
264
+ if (allHost) {
265
+ const urls = [];
266
+ const hosts = [];
267
+
268
+ for (const host of hostPriority) {
269
+ for (const arr of episodeMatrix) {
270
+ if (i < arr.length && arr[i].includes(host)) {
271
+ if (!hosts.includes(host)) {
272
+ urls.push(arr[i]);
273
+ hosts.push(host);
274
+ }
275
+ break; // une seule URL par host
276
+ }
272
277
  }
273
278
  }
274
- if (selectedUrl) break;
275
- }
276
279
 
277
- finalEmbeds.push({
278
- title: null, // on remplit après
279
- url: selectedUrl || null,
280
- host: selectedHost || null
281
- });
280
+ finalEmbeds.push({
281
+ title: null, // à remplir plus tard
282
+ url: urls.length ? urls : null,
283
+ host: hosts.length ? hosts : null,
284
+ });
285
+
286
+ } else {
287
+ let selectedUrl = null;
288
+ let selectedHost = null;
289
+
290
+ for (const host of hostPriority) {
291
+ for (const arr of episodeMatrix) {
292
+ if (i < arr.length && arr[i].includes(host)) {
293
+ selectedUrl = arr[i];
294
+ selectedHost = host;
295
+ break;
296
+ }
297
+ }
298
+ if (selectedUrl) break;
299
+ }
300
+
301
+ finalEmbeds.push({
302
+ title: null, // à remplir plus tard
303
+ url: selectedUrl || null,
304
+ host: selectedHost || null,
305
+ });
306
+ }
282
307
  }
283
308
 
284
309
  const titles = await getEpisodeTitles(seasonUrl, customChromiumPath);
@@ -294,7 +319,6 @@ export async function getEmbed(
294
319
  episodeCount: maxEpisodes
295
320
  }
296
321
  };
297
-
298
322
  } else {
299
323
  return finalEmbeds;
300
324
  }
@@ -343,7 +367,7 @@ export async function getAvailableLanguages(
343
367
 
344
368
  // Iterate over each possible language and check if the page exists
345
369
  for (let language of wantedLanguages) {
346
- const languageUrl = seasonUrl.replace("vostfr", `${language}`);
370
+ const languageUrl = seasonUrl.split('/').map((s, i) => i === 6 ? language : s).join('/');
347
371
  try {
348
372
  const res = await axios.get(languageUrl, {
349
373
  headers: getHeaders(CATALOGUE_URL),