mirror of
https://github.com/kodjodevf/mangayomi-extensions.git
synced 2026-02-14 10:51:17 +00:00
Merge pull request #116 from NBA2K1/main
dateUpload for AniWorld & SerienStream
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.3.1",
|
"version": "0.3.2",
|
||||||
"dateFormat": "",
|
"dateFormat": "",
|
||||||
"dateFormatLocale": "",
|
"dateFormatLocale": "",
|
||||||
"pkgPath": "anime/src/de/aniworld.js"
|
"pkgPath": "anime/src/de/aniworld.js"
|
||||||
@@ -85,17 +85,10 @@ 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");
|
||||||
|
const promises = seasonsElements.map(element => this.parseEpisodesFromSeries(element));
|
||||||
const promises = [];
|
const episodes = (await Promise.allSettled(promises))
|
||||||
const episodes = [];
|
.filter(p => p.status === 'fulfilled')
|
||||||
for (const element of seasonsElements) {
|
.flatMap(p => p.value);
|
||||||
promises.push(this.parseEpisodesFromSeries(element));
|
|
||||||
}
|
|
||||||
for (const p of (await Promise.allSettled(promises))) {
|
|
||||||
if (p.status == 'fulfilled') {
|
|
||||||
episodes.push(...p.value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
episodes.reverse();
|
episodes.reverse();
|
||||||
return { name, imageUrl, description, author, status: 5, genre, episodes };
|
return { name, imageUrl, description, author, status: 5, genre, episodes };
|
||||||
}
|
}
|
||||||
@@ -103,16 +96,13 @@ class DefaultExtension extends MProvider {
|
|||||||
const seasonId = element.getHref;
|
const seasonId = element.getHref;
|
||||||
const res = await this.client.get(this.source.baseUrl + seasonId);
|
const res = await this.client.get(this.source.baseUrl + seasonId);
|
||||||
const episodeElements = new Document(res.body).select("table.seasonEpisodesList tbody tr");
|
const episodeElements = new Document(res.body).select("table.seasonEpisodesList tbody tr");
|
||||||
const list = [];
|
return Promise.all(episodeElements.map(e => this.episodeFromElement(e)));
|
||||||
for (const episodeElement of episodeElements) {
|
|
||||||
list.push(this.episodeFromElement(episodeElement));
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
}
|
||||||
episodeFromElement(element) {
|
async episodeFromElement(element) {
|
||||||
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 = episodeSpan.text.replace(/'/g, "'");
|
let episode = episodeSpan.text.replace(/'/g, "'");
|
||||||
let name = "";
|
let name = "";
|
||||||
@@ -122,7 +112,36 @@ 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 } : {};
|
return name && url ? { name, url, dateUpload } : {};
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ const mangayomiSources = [{
|
|||||||
"typeSource": "single",
|
"typeSource": "single",
|
||||||
"isManga": false,
|
"isManga": false,
|
||||||
"isNsfw": false,
|
"isNsfw": false,
|
||||||
"version": "0.0.3",
|
"version": "0.0.4",
|
||||||
"dateFormat": "",
|
"dateFormat": "",
|
||||||
"dateFormatLocale": "",
|
"dateFormatLocale": "",
|
||||||
"pkgPath": "anime/src/de/serienstream.js"
|
"pkgPath": "anime/src/de/serienstream.js"
|
||||||
@@ -85,17 +85,10 @@ 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");
|
||||||
|
const promises = seasonsElements.map(element => this.parseEpisodesFromSeries(element));
|
||||||
const promises = [];
|
const episodes = (await Promise.allSettled(promises))
|
||||||
const episodes = [];
|
.filter(p => p.status === 'fulfilled')
|
||||||
for (const element of seasonsElements) {
|
.flatMap(p => p.value);
|
||||||
promises.push(this.parseEpisodesFromSeries(element));
|
|
||||||
}
|
|
||||||
for (const p of (await Promise.allSettled(promises))) {
|
|
||||||
if (p.status == 'fulfilled') {
|
|
||||||
episodes.push(...p.value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
episodes.reverse();
|
episodes.reverse();
|
||||||
return { name, imageUrl, description, author, status: 5, genre, episodes };
|
return { name, imageUrl, description, author, status: 5, genre, episodes };
|
||||||
}
|
}
|
||||||
@@ -103,16 +96,13 @@ class DefaultExtension extends MProvider {
|
|||||||
const seasonId = element.getHref;
|
const seasonId = element.getHref;
|
||||||
const res = await this.client.get(this.source.baseUrl + seasonId);
|
const res = await this.client.get(this.source.baseUrl + seasonId);
|
||||||
const episodeElements = new Document(res.body).select("table.seasonEpisodesList tbody tr");
|
const episodeElements = new Document(res.body).select("table.seasonEpisodesList tbody tr");
|
||||||
const list = [];
|
return Promise.all(episodeElements.map(e => this.episodeFromElement(e)));
|
||||||
for (const episodeElement of episodeElements) {
|
|
||||||
list.push(this.episodeFromElement(episodeElement));
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
}
|
||||||
episodeFromElement(element) {
|
async episodeFromElement(element) {
|
||||||
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 = episodeSpan.text.replace(/'/g, "'");
|
let episode = episodeSpan.text.replace(/'/g, "'");
|
||||||
let name = "";
|
let name = "";
|
||||||
@@ -122,7 +112,36 @@ 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 } : {};
|
return name && url ? { name, url, dateUpload } : {};
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
|||||||
Reference in New Issue
Block a user