mirror of
https://github.com/kodjodevf/mangayomi-extensions.git
synced 2026-02-14 10:51:17 +00:00
extension(Animeparadise): Added details
This commit is contained in:
@@ -6,7 +6,7 @@ const mangayomiSources = [{
|
|||||||
"iconUrl": "https://www.google.com/s2/favicons?sz=128&domain=https://animeparadise.moe",
|
"iconUrl": "https://www.google.com/s2/favicons?sz=128&domain=https://animeparadise.moe",
|
||||||
"typeSource": "single",
|
"typeSource": "single",
|
||||||
"itemType": 1,
|
"itemType": 1,
|
||||||
"version": "0.0.2",
|
"version": "0.0.3",
|
||||||
"pkgPath": "anime/src/en/animeparadise.js"
|
"pkgPath": "anime/src/en/animeparadise.js"
|
||||||
}];
|
}];
|
||||||
|
|
||||||
@@ -20,6 +20,13 @@ class DefaultExtension extends MProvider {
|
|||||||
return preferences.get(key);
|
return preferences.get(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async extractFromUrl(url) {
|
||||||
|
var res = await new Client().get(url);
|
||||||
|
var doc = new Document(res.body);
|
||||||
|
var jsonData = doc.selectFirst("#__NEXT_DATA__").text
|
||||||
|
return JSON.parse(jsonData).props.pageProps.data;
|
||||||
|
}
|
||||||
|
|
||||||
async requestAPI(slug) {
|
async requestAPI(slug) {
|
||||||
var api = `${this.source.apiUrl}/${slug}`
|
var api = `${this.source.apiUrl}/${slug}`
|
||||||
var response = await new Client().get(api);
|
var response = await new Client().get(api);
|
||||||
@@ -72,8 +79,33 @@ class DefaultExtension extends MProvider {
|
|||||||
async search(query, page, filters) {
|
async search(query, page, filters) {
|
||||||
throw new Error("search not implemented");
|
throw new Error("search not implemented");
|
||||||
}
|
}
|
||||||
|
statusCode(status) {
|
||||||
|
return {
|
||||||
|
"current": 0,
|
||||||
|
"finished": 1,
|
||||||
|
}[status] ?? 5;
|
||||||
|
}
|
||||||
|
|
||||||
async getDetail(url) {
|
async getDetail(url) {
|
||||||
throw new Error("getDetail not implemented");
|
var link = this.source.baseUrl + `/anime/${url}`
|
||||||
|
var jsonData = await this.extractFromUrl(link)
|
||||||
|
var details = {}
|
||||||
|
var chapters = []
|
||||||
|
details.name = jsonData.title
|
||||||
|
details.link = link
|
||||||
|
details.imageUrl = jsonData.posterImage.original
|
||||||
|
details.description = jsonData.synopsys
|
||||||
|
details.genre = jsonData.genres
|
||||||
|
details.status = this.statusCode(jsonData.status)
|
||||||
|
var id = jsonData._id
|
||||||
|
var epAPI = await this.requestAPI(`anime/${id}/episode`)
|
||||||
|
epAPI.data.forEach(ep => {
|
||||||
|
var epName = `E${ep.number}: ${ep.title}`;
|
||||||
|
var epUrl = `${ep.uid}?origin=${ep.origin}`
|
||||||
|
chapters.push({ name: epName, url: epUrl })
|
||||||
|
})
|
||||||
|
details.chapters = chapters.reverse();
|
||||||
|
return details;
|
||||||
}
|
}
|
||||||
// For novel html content
|
// For novel html content
|
||||||
async getHtmlContent(url) {
|
async getHtmlContent(url) {
|
||||||
|
|||||||
Reference in New Issue
Block a user