better-ani-scraped 1.6.0 → 1.6.2
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
|
@@ -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--sibnet-vidmoly)
|
|
33
|
+
- [getEmbed](#animesamagetembedseasonurl-hostpriority--sendvid-sibnet-vidmoly-oneupload)
|
|
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)
|
|
@@ -95,7 +95,7 @@ Fetches the names of all episodes in a season
|
|
|
95
95
|
|
|
96
96
|
---
|
|
97
97
|
|
|
98
|
-
### `animesama.getEmbed(seasonUrl, hostPriority = ["sibnet", "vidmoly"])`
|
|
98
|
+
### `animesama.getEmbed(seasonUrl, hostPriority = ["sendvid", "sibnet", "vidmoly", "oneupload"])`
|
|
99
99
|
Retrieves embed URLs for episodes, prioritizing by host.
|
|
100
100
|
|
|
101
101
|
- **Parameters:**
|
|
@@ -108,6 +108,7 @@ Retrieves embed URLs for episodes, prioritizing by host.
|
|
|
108
108
|
{
|
|
109
109
|
title: string,
|
|
110
110
|
url: string,
|
|
111
|
+
host: string,
|
|
111
112
|
}
|
|
112
113
|
...
|
|
113
114
|
]
|
|
@@ -4,7 +4,7 @@ const main = async () => {
|
|
|
4
4
|
const animesama = new AnimeScraper('animesama');
|
|
5
5
|
const seasonUrl = "https://anime-sama.fr/catalogue/86-eighty-six/saison1/vostfr/";
|
|
6
6
|
|
|
7
|
-
const embeds = await animesama.getEmbed(seasonUrl, ["sibnet", "vidmoly"]);
|
|
7
|
+
const embeds = await animesama.getEmbed(seasonUrl, ["sibnet", "vidmoly"], true);
|
|
8
8
|
console.log("Embed Links:", embeds);
|
|
9
9
|
};
|
|
10
10
|
|
package/package.json
CHANGED
package/scrapers/animesama.js
CHANGED
|
@@ -215,12 +215,23 @@ export async function getEpisodeTitles(seasonUrl, customChromiumPath) {
|
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
217
|
|
|
218
|
-
export async function getEmbed(
|
|
218
|
+
export async function getEmbed(
|
|
219
|
+
seasonUrl,
|
|
220
|
+
hostPriority = ["sendvid", "sibnet", "vidmoly", "oneupload"],
|
|
221
|
+
includeInfo = false,
|
|
222
|
+
customChromiumPath
|
|
223
|
+
) {
|
|
219
224
|
const res = await axios.get(seasonUrl, {
|
|
220
225
|
headers: getHeaders(seasonUrl.split("/").slice(0, 5).join("/")),
|
|
221
226
|
});
|
|
222
227
|
|
|
223
228
|
const $ = cheerio.load(res.data);
|
|
229
|
+
|
|
230
|
+
const seasonTitle = ($('script').toArray()
|
|
231
|
+
.map(s => $(s).html())
|
|
232
|
+
.find(c => c && c.includes('#avOeuvre')) || '')
|
|
233
|
+
.match(/#avOeuvre"\)\.html\("([^"]+)"/)?.[1] || "Saison inconnue";
|
|
234
|
+
|
|
224
235
|
const scriptTag = $('script[src*="episodes.js"]').attr("src");
|
|
225
236
|
if (!scriptTag) throw new Error("No episodes script found");
|
|
226
237
|
|
|
@@ -232,9 +243,7 @@ export async function getEmbed(seasonUrl, hostPriority = ["sibnet", "vidmoly"],
|
|
|
232
243
|
.get(scriptUrl, { headers: getHeaders(seasonUrl) })
|
|
233
244
|
.then((r) => r.data);
|
|
234
245
|
|
|
235
|
-
const matches = [
|
|
236
|
-
...episodesJs.matchAll(/var\s+(eps\d+)\s*=\s*(\[[^\]]+\])/g),
|
|
237
|
-
];
|
|
246
|
+
const matches = [...episodesJs.matchAll(/var\s+(eps\d+)\s*=\s*(\[[^\]]+\])/g)];
|
|
238
247
|
if (!matches.length) throw new Error("No episode arrays found");
|
|
239
248
|
|
|
240
249
|
let episodeMatrix = [];
|
|
@@ -249,27 +258,50 @@ export async function getEmbed(seasonUrl, hostPriority = ["sibnet", "vidmoly"],
|
|
|
249
258
|
|
|
250
259
|
const maxEpisodes = Math.max(...episodeMatrix.map(arr => arr.length));
|
|
251
260
|
const finalEmbeds = [];
|
|
261
|
+
|
|
252
262
|
for (let i = 0; i < maxEpisodes; i++) {
|
|
253
263
|
let selectedUrl = null;
|
|
264
|
+
let selectedHost = null;
|
|
265
|
+
|
|
254
266
|
for (const host of hostPriority) {
|
|
255
267
|
for (const arr of episodeMatrix) {
|
|
256
268
|
if (i < arr.length && arr[i].includes(host)) {
|
|
257
269
|
selectedUrl = arr[i];
|
|
270
|
+
selectedHost = host;
|
|
258
271
|
break;
|
|
259
272
|
}
|
|
260
273
|
}
|
|
261
274
|
if (selectedUrl) break;
|
|
262
275
|
}
|
|
263
|
-
|
|
276
|
+
|
|
277
|
+
finalEmbeds.push({
|
|
278
|
+
title: null, // on remplit après
|
|
279
|
+
url: selectedUrl || null,
|
|
280
|
+
host: selectedHost || null
|
|
281
|
+
});
|
|
264
282
|
}
|
|
265
283
|
|
|
266
284
|
const titles = await getEpisodeTitles(seasonUrl, customChromiumPath);
|
|
267
|
-
|
|
268
|
-
title
|
|
269
|
-
|
|
270
|
-
|
|
285
|
+
finalEmbeds.forEach((embed, i) => {
|
|
286
|
+
embed.title = titles[i] || `Episode ${i + 1}`;
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
if (includeInfo) {
|
|
290
|
+
return {
|
|
291
|
+
episodes: finalEmbeds,
|
|
292
|
+
animeInfo: {
|
|
293
|
+
seasonTitle,
|
|
294
|
+
episodeCount: maxEpisodes
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
|
|
298
|
+
} else {
|
|
299
|
+
return finalEmbeds;
|
|
300
|
+
}
|
|
271
301
|
}
|
|
272
302
|
|
|
303
|
+
|
|
304
|
+
|
|
273
305
|
export async function getAnimeInfo(animeUrl) {
|
|
274
306
|
const res = await axios.get(animeUrl, { headers: getHeaders(CATALOGUE_URL) });
|
|
275
307
|
const $ = cheerio.load(res.data);
|
package/utils/extractVideoUrl.js
CHANGED
|
@@ -53,9 +53,11 @@ export async function getSendvidVideo(embedUrl) {
|
|
|
53
53
|
|
|
54
54
|
export async function getVidmolyOrOneuploadVideo(embedUrl) {
|
|
55
55
|
try {
|
|
56
|
+
console.log(embedUrl)
|
|
56
57
|
const { data } = await axios.get(embedUrl, {
|
|
57
58
|
headers: getHeaders(embedUrl),
|
|
58
59
|
});
|
|
60
|
+
console.log(data)
|
|
59
61
|
const $ = cheerio.load(data);
|
|
60
62
|
const scripts = $("script");
|
|
61
63
|
|