better-ani-scraped 1.6.1 → 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.
|
@@ -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 = ["sendvid", "sibnet", "
|
|
|
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,37 +258,50 @@ export async function getEmbed(seasonUrl, hostPriority = ["sendvid", "sibnet", "
|
|
|
249
258
|
|
|
250
259
|
const maxEpisodes = Math.max(...episodeMatrix.map(arr => arr.length));
|
|
251
260
|
const finalEmbeds = [];
|
|
252
|
-
|
|
253
|
-
let
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
for (const
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
261
|
+
|
|
262
|
+
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;
|
|
272
|
+
}
|
|
262
273
|
}
|
|
274
|
+
if (selectedUrl) break;
|
|
263
275
|
}
|
|
264
|
-
|
|
276
|
+
|
|
277
|
+
finalEmbeds.push({
|
|
278
|
+
title: null, // on remplit après
|
|
279
|
+
url: selectedUrl || null,
|
|
280
|
+
host: selectedHost || null
|
|
281
|
+
});
|
|
265
282
|
}
|
|
266
283
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
284
|
+
const titles = await getEpisodeTitles(seasonUrl, customChromiumPath);
|
|
285
|
+
finalEmbeds.forEach((embed, i) => {
|
|
286
|
+
embed.title = titles[i] || `Episode ${i + 1}`;
|
|
270
287
|
});
|
|
271
|
-
}
|
|
272
288
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
}
|
|
289
|
+
if (includeInfo) {
|
|
290
|
+
return {
|
|
291
|
+
episodes: finalEmbeds,
|
|
292
|
+
animeInfo: {
|
|
293
|
+
seasonTitle,
|
|
294
|
+
episodeCount: maxEpisodes
|
|
295
|
+
}
|
|
296
|
+
};
|
|
280
297
|
|
|
298
|
+
} else {
|
|
299
|
+
return finalEmbeds;
|
|
300
|
+
}
|
|
281
301
|
}
|
|
282
302
|
|
|
303
|
+
|
|
304
|
+
|
|
283
305
|
export async function getAnimeInfo(animeUrl) {
|
|
284
306
|
const res = await axios.get(animeUrl, { headers: getHeaders(CATALOGUE_URL) });
|
|
285
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
|
|