better-ani-scraped 1.6.2 → 1.6.3
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
|
-
|
|
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
|
-
|
|
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,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/
|
|
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
|
-
|
|
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);
|
package/package.json
CHANGED
package/scrapers/animesama.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
for (const
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
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
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
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
|
}
|