mirror of
https://github.com/kodjodevf/mangayomi-extensions.git
synced 2026-02-15 03:10:59 +00:00
AniWorld: remove getUploadDateFromEpisode for better performance
This commit is contained in:
@@ -7,7 +7,7 @@ const mangayomiSources = [{
|
|||||||
"typeSource": "single",
|
"typeSource": "single",
|
||||||
"itemType": 1,
|
"itemType": 1,
|
||||||
"isNsfw": false,
|
"isNsfw": false,
|
||||||
"version": "0.3.4",
|
"version": "0.3.5",
|
||||||
"dateFormat": "",
|
"dateFormat": "",
|
||||||
"dateFormatLocale": "",
|
"dateFormatLocale": "",
|
||||||
"pkgPath": "anime/src/de/aniworld.js"
|
"pkgPath": "anime/src/de/aniworld.js"
|
||||||
@@ -142,7 +142,6 @@ class DefaultExtension extends MProvider {
|
|||||||
const titleAnchor = element.selectFirst("td.seasonEpisodeTitle a");
|
const titleAnchor = element.selectFirst("td.seasonEpisodeTitle a");
|
||||||
const episodeSpan = titleAnchor.selectFirst("span");
|
const episodeSpan = titleAnchor.selectFirst("span");
|
||||||
const url = titleAnchor.attr("href");
|
const url = titleAnchor.attr("href");
|
||||||
const dateUpload = await this.getUploadDateFromEpisode(url);
|
|
||||||
const episodeSeasonId = element.attr("data-episode-season-id");
|
const episodeSeasonId = element.attr("data-episode-season-id");
|
||||||
let episode = this.cleanHtmlString(episodeSpan.text);
|
let episode = this.cleanHtmlString(episodeSpan.text);
|
||||||
let name = "";
|
let name = "";
|
||||||
@@ -152,37 +151,9 @@ class DefaultExtension extends MProvider {
|
|||||||
const seasonMatch = url.match(/staffel-(\d+)\/episode/);
|
const seasonMatch = url.match(/staffel-(\d+)\/episode/);
|
||||||
name = `Staffel ${seasonMatch[1]} Folge ${episodeSeasonId} : ${episode}`;
|
name = `Staffel ${seasonMatch[1]} Folge ${episodeSeasonId} : ${episode}`;
|
||||||
}
|
}
|
||||||
return name && url ? { name, url, dateUpload } : {};
|
return name && url ? { name, url } : {};
|
||||||
}
|
|
||||||
async getUploadDateFromEpisode(url) {
|
|
||||||
const baseUrl = this.source.baseUrl;
|
|
||||||
const res = await this.client.get(baseUrl + url);
|
|
||||||
const getLastSundayOfMonth = (year, month) => {
|
|
||||||
const lastDay = new Date(year, month, 0);
|
|
||||||
const lastSunday = lastDay.getDate() - lastDay.getDay();
|
|
||||||
return new Date(year, month - 1, lastSunday);
|
|
||||||
};
|
|
||||||
const document = new Document(res.body);
|
|
||||||
const dateString = document.selectFirst('strong[style="color: white;"]').text;
|
|
||||||
const dateTimePart = dateString.split(", ")[1];
|
|
||||||
const [date, time] = dateTimePart.split(" ");
|
|
||||||
const [day, month, year] = date.split(".");
|
|
||||||
const [hours, minutes] = time.split(":");
|
|
||||||
const dayInt = parseInt(day);
|
|
||||||
const monthInt = parseInt(month);
|
|
||||||
const yearInt = parseInt(year);
|
|
||||||
const hoursInt = parseInt(hours);
|
|
||||||
const minutesInt = parseInt(minutes);
|
|
||||||
const lastSundayOfMarch = getLastSundayOfMonth(yearInt, 3);
|
|
||||||
const lastSundayOfOctober = getLastSundayOfMonth(yearInt, 10);
|
|
||||||
const jsDate = new Date(yearInt, monthInt - 1, dayInt, hoursInt, minutesInt);
|
|
||||||
// If Date between lastSundayOfMarch & lastSundayOfOctober -> CEST (MESZ)
|
|
||||||
const isInDST = jsDate >= lastSundayOfMarch && jsDate < lastSundayOfOctober;
|
|
||||||
let timeZoneOffset = isInDST ? 0 : 1;
|
|
||||||
// If it's in CEST, subtract 1 hour from UTC (to get local time in CEST)
|
|
||||||
const correctedTime = new Date(jsDate.getTime() + (timeZoneOffset - 1) * 60 * 60 * 1000);
|
|
||||||
return String(correctedTime.valueOf()); // dateUpload is a string containing date expressed in millisecondsSinceEpoch.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async getVideoList(url) {
|
async getVideoList(url) {
|
||||||
const baseUrl = this.source.baseUrl;
|
const baseUrl = this.source.baseUrl;
|
||||||
const res = await this.client.get(baseUrl + url, {
|
const res = await this.client.get(baseUrl + url, {
|
||||||
|
|||||||
Reference in New Issue
Block a user