better-ani-scraped 1.2.4 → 1.2.5
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/package.json +1 -1
- package/scrapers/animesama.js +41 -32
package/package.json
CHANGED
package/scrapers/animesama.js
CHANGED
|
@@ -125,40 +125,49 @@ export async function getSeasons(animeUrl, language = "vostfr") {
|
|
|
125
125
|
|
|
126
126
|
import { chromium } from 'playwright';
|
|
127
127
|
|
|
128
|
-
export async function getEpisodeTitles(animeUrl) {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
browser = await chromium.launch({ headless: true });
|
|
132
|
-
const context = await browser.newContext({
|
|
133
|
-
locale: 'fr-FR',
|
|
134
|
-
userAgent: 'Mozilla/5.0'
|
|
135
|
-
});
|
|
136
|
-
const page = await context.newPage();
|
|
137
|
-
await page.route('**/*', (route) => {
|
|
138
|
-
const blocked = ['image', 'stylesheet', 'font', 'media'];
|
|
139
|
-
if (blocked.includes(route.request().resourceType())) {
|
|
140
|
-
route.abort();
|
|
141
|
-
} else {
|
|
142
|
-
route.continue();
|
|
143
|
-
}
|
|
144
|
-
});
|
|
128
|
+
export async function getEpisodeTitles(animeUrl, options = {}) {
|
|
129
|
+
const { executablePath = null } = options; // <-- ajout ici
|
|
130
|
+
let browser;
|
|
145
131
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
return titres;
|
|
152
|
-
} catch (error) {
|
|
153
|
-
console.error('❌ Erreur dans la récupération des titres :', error);
|
|
154
|
-
return [];
|
|
155
|
-
} finally {
|
|
156
|
-
if (browser) {
|
|
157
|
-
await browser.close();
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}
|
|
132
|
+
try {
|
|
133
|
+
browser = await chromium.launch({
|
|
134
|
+
headless: true,
|
|
135
|
+
...(executablePath ? { executablePath } : {}) // <-- on injecte le chemin si dispo
|
|
136
|
+
});
|
|
161
137
|
|
|
138
|
+
const context = await browser.newContext({
|
|
139
|
+
locale: 'fr-FR',
|
|
140
|
+
userAgent: 'Mozilla/5.0'
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
const page = await context.newPage();
|
|
144
|
+
|
|
145
|
+
await page.route('**/*', (route) => {
|
|
146
|
+
const blocked = ['image', 'stylesheet', 'font', 'media'];
|
|
147
|
+
if (blocked.includes(route.request().resourceType())) {
|
|
148
|
+
route.abort();
|
|
149
|
+
} else {
|
|
150
|
+
route.continue();
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
await page.goto(animeUrl, { waitUntil: 'domcontentloaded', timeout: 20000 });
|
|
155
|
+
await page.waitForSelector('#selectEpisodes', { timeout: 10000 });
|
|
156
|
+
|
|
157
|
+
const titres = await page.$$eval('#selectEpisodes option', options =>
|
|
158
|
+
options.map(o => o.textContent.trim())
|
|
159
|
+
);
|
|
160
|
+
|
|
161
|
+
return titres;
|
|
162
|
+
} catch (error) {
|
|
163
|
+
console.error('❌ Erreur dans la récupération des titres :', error);
|
|
164
|
+
return [];
|
|
165
|
+
} finally {
|
|
166
|
+
if (browser) {
|
|
167
|
+
await browser.close();
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
162
171
|
|
|
163
172
|
export async function getEmbed(animeUrl, hostPriority = ["vidmoly"]) {
|
|
164
173
|
const res = await axios.get(animeUrl, {
|