mirror of
https://github.com/kodjodevf/mangayomi-extensions.git
synced 2026-02-14 19:01:15 +00:00
Fix apostrophe rendering and improve performance
Fixed apostrophe rendering in episode names (e.g., for "DAN DA DAN") by replacing HTML character references (') with actual apostrophes. Optimized performance by reusing a single Client instance, passing it to parseEpisodesFromSeries() instead of creating a new instance in each loop. Parallelized episode fetching in getDetail() using Promise.all to improve request efficiency, replacing the sequential loop.
This commit is contained in:
@@ -7,7 +7,7 @@ const mangayomiSources = [{
|
|||||||
"typeSource": "single",
|
"typeSource": "single",
|
||||||
"isManga": false,
|
"isManga": false,
|
||||||
"isNsfw": false,
|
"isNsfw": false,
|
||||||
"version": "0.0.26",
|
"version": "0.0.27",
|
||||||
"dateFormat": "",
|
"dateFormat": "",
|
||||||
"dateFormatLocale": "",
|
"dateFormatLocale": "",
|
||||||
"pkgPath": "anime/src/de/aniworld.js"
|
"pkgPath": "anime/src/de/aniworld.js"
|
||||||
@@ -67,7 +67,8 @@ class DefaultExtension extends MProvider {
|
|||||||
}
|
}
|
||||||
async getDetail(url) {
|
async getDetail(url) {
|
||||||
const baseUrl = this.source.baseUrl;
|
const baseUrl = this.source.baseUrl;
|
||||||
const res = await new Client().get(baseUrl + url);
|
const client = new Client();
|
||||||
|
const res = await client.get(baseUrl + url);
|
||||||
const document = new Document(res.body);
|
const document = new Document(res.body);
|
||||||
const imageUrl = baseUrl +
|
const imageUrl = baseUrl +
|
||||||
document.selectFirst("div.seriesCoverBox img").attr("data-src");
|
document.selectFirst("div.seriesCoverBox img").attr("data-src");
|
||||||
@@ -81,47 +82,33 @@ class DefaultExtension extends MProvider {
|
|||||||
author = produzent[0].select("li").map(e => e.text).join(", ");
|
author = produzent[0].select("li").map(e => e.text).join(", ");
|
||||||
}
|
}
|
||||||
const seasonsElements = document.select("#stream > ul:nth-child(1) > li > a");
|
const seasonsElements = document.select("#stream > ul:nth-child(1) > li > a");
|
||||||
let episodes = [];
|
const episodes = (await Promise.all(seasonsElements.map(element => this.parseEpisodesFromSeries(element, client)))).flat();
|
||||||
for (const element of seasonsElements) {
|
|
||||||
const eps = await this.parseEpisodesFromSeries(element);
|
|
||||||
for (const ep of eps) {
|
|
||||||
episodes.push(ep);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
episodes.reverse();
|
episodes.reverse();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name, imageUrl, description, author, status: 5, genre, episodes
|
name, imageUrl, description, author, status: 5, genre, episodes
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
async parseEpisodesFromSeries(element) {
|
async parseEpisodesFromSeries(seriesElement, client) {
|
||||||
const seasonId = element.getHref;
|
const seasonId = seriesElement.getHref;
|
||||||
const res = await new Client().get(this.source.baseUrl + seasonId);
|
const response = await client.get(`${this.source.baseUrl}${seasonId}`);
|
||||||
const episodeElements = new Document(res.body).select("table.seasonEpisodesList tbody tr");
|
const episodeElements = new Document(response.body).select("table.seasonEpisodesList tbody tr");
|
||||||
const list = [];
|
const episodes = Array.from(episodeElements).map((episodeElement) => this.episodeFromElement(episodeElement));
|
||||||
for (const episodeElement of episodeElements) {
|
return episodes.filter(ep => Object.keys(ep).length > 0);
|
||||||
list.push(this.episodeFromElement(episodeElement));
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
}
|
||||||
episodeFromElement(element) {
|
episodeFromElement(element) {
|
||||||
|
const titleAnchor = element.selectFirst("td.seasonEpisodeTitle a");
|
||||||
|
const episodeSpan = titleAnchor.selectFirst("span");
|
||||||
|
const url = titleAnchor.attr("href");
|
||||||
|
const episodeSeasonId = element.attr("data-episode-season-id");
|
||||||
|
let episode = episodeSpan.text.replace(/'/g, "'");
|
||||||
let name = "";
|
let name = "";
|
||||||
let url = "";
|
if (url.includes("/film")) {
|
||||||
if (element.selectFirst("td.seasonEpisodeTitle a").attr("href").includes("/film")) {
|
name = `Film ${episodeSeasonId} : ${episode}`;
|
||||||
const num = element.attr("data-episode-season-id");
|
|
||||||
name = `Film ${num}` + " : " + element.selectFirst("td.seasonEpisodeTitle a span").text;
|
|
||||||
url = element.selectFirst("td.seasonEpisodeTitle a").attr("href");
|
|
||||||
} else {
|
} else {
|
||||||
const season =
|
const seasonMatch = url.match(/staffel-(\d+)\/episode/);
|
||||||
element.selectFirst("td.seasonEpisodeTitle a").attr("href").substringAfter("staffel-").substringBefore("/episode");;
|
name = `Staffel ${seasonMatch[1]} Folge ${episodeSeasonId} : ${episode}`;
|
||||||
const num = element.attr("data-episode-season-id");
|
|
||||||
name = `Staffel ${season} Folge ${num}` + " : " + element.selectFirst("td.seasonEpisodeTitle a span").text;
|
|
||||||
url = element.selectFirst("td.seasonEpisodeTitle a").attr("href");
|
|
||||||
}
|
}
|
||||||
if (name.length > 0 && url.length > 0) {
|
return name && url ? { name, url } : {};
|
||||||
return { name, url }
|
|
||||||
}
|
|
||||||
return {}
|
|
||||||
}
|
}
|
||||||
getRandomString(length) {
|
getRandomString(length) {
|
||||||
const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890";
|
const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890";
|
||||||
|
|||||||
Reference in New Issue
Block a user