mirror of
https://github.com/kodjodevf/mangayomi-extensions.git
synced 2026-02-14 19:01:15 +00:00
anime(gojo): Added details
This commit is contained in:
@@ -6,7 +6,7 @@ const mangayomiSources = [{
|
|||||||
"iconUrl": "https://www.google.com/s2/favicons?sz=128&domain=https://gojo.wtf/",
|
"iconUrl": "https://www.google.com/s2/favicons?sz=128&domain=https://gojo.wtf/",
|
||||||
"typeSource": "multi",
|
"typeSource": "multi",
|
||||||
"itemType": 1,
|
"itemType": 1,
|
||||||
"version": "0.0.1",
|
"version": "0.0.3",
|
||||||
"pkgPath": "anime/src/en/gojo.js"
|
"pkgPath": "anime/src/en/gojo.js"
|
||||||
}];
|
}];
|
||||||
|
|
||||||
@@ -57,7 +57,7 @@ class DefaultExtension extends MProvider {
|
|||||||
} else {
|
} else {
|
||||||
imageUrl = image
|
imageUrl = image
|
||||||
}
|
}
|
||||||
var link = ""+anime.id
|
var link = "" + anime.id
|
||||||
|
|
||||||
list.push({ name, imageUrl, link });
|
list.push({ name, imageUrl, link });
|
||||||
})
|
})
|
||||||
@@ -83,7 +83,7 @@ class DefaultExtension extends MProvider {
|
|||||||
list.push(...this.formatList(res))
|
list.push(...this.formatList(res))
|
||||||
}
|
}
|
||||||
var hasNextPage = true;
|
var hasNextPage = true;
|
||||||
if(list.length < 30) hasNextPage = false;
|
if (list.length < 30) hasNextPage = false;
|
||||||
|
|
||||||
return { list, hasNextPage }
|
return { list, hasNextPage }
|
||||||
}
|
}
|
||||||
@@ -95,7 +95,7 @@ class DefaultExtension extends MProvider {
|
|||||||
var res = await this.gojoAPI(`/search?query=${query}&page=${page}&perPage=30`)
|
var res = await this.gojoAPI(`/search?query=${query}&page=${page}&perPage=30`)
|
||||||
if (res != null) {
|
if (res != null) {
|
||||||
list.push(...this.formatList(res.results))
|
list.push(...this.formatList(res.results))
|
||||||
if(res.lastPage < page) hasNextPage = true;
|
if (res.lastPage < page) hasNextPage = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return { list, hasNextPage }
|
return { list, hasNextPage }
|
||||||
@@ -103,30 +103,113 @@ class DefaultExtension extends MProvider {
|
|||||||
|
|
||||||
|
|
||||||
async getDetail(url) {
|
async getDetail(url) {
|
||||||
throw new Error("getDetail not implemented");
|
var anilistId = url
|
||||||
}
|
var res = await this.gojoAPI(`/info/${anilistId}`)
|
||||||
// For novel html content
|
if (res == null) {
|
||||||
async getHtmlContent(url) {
|
throw new Error("Error on getDetail");
|
||||||
throw new Error("getHtmlContent not implemented");
|
}
|
||||||
}
|
var name = this.getTitle(res.title)
|
||||||
// Clean html up for reader
|
var imageUrl = res.coverImage.large
|
||||||
async cleanHtmlContent(html) {
|
var description = res.description;
|
||||||
throw new Error("cleanHtmlContent not implemented");
|
var link = `${this.source.baseUrl}/watch/${anilistId}`
|
||||||
|
var genres = res.genres
|
||||||
|
var status = (() => {
|
||||||
|
switch (res.status) {
|
||||||
|
case "RELEASING":
|
||||||
|
return 0;
|
||||||
|
case "FINISHED":
|
||||||
|
return 1;
|
||||||
|
case "HIATUS":
|
||||||
|
return 2;
|
||||||
|
case "NOT_YET_RELEASED":
|
||||||
|
return 3;
|
||||||
|
default:
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
||||||
|
|
||||||
|
var chapters = [];
|
||||||
|
|
||||||
|
var body = await this.gojoAPI(`/episodes/${anilistId}`)
|
||||||
|
if (body != null && body.length > 0) {
|
||||||
|
|
||||||
|
// Find the maximum episodes as some providers may not have all.
|
||||||
|
var maxEpisodes = 0
|
||||||
|
for (var prd of body) {
|
||||||
|
if (prd['episodes'].length > maxEpisodes) {
|
||||||
|
maxEpisodes = prd['episodes'].length;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var i = 0; i < maxEpisodes; i++) {
|
||||||
|
var chapNum = -1
|
||||||
|
var chapName = ""
|
||||||
|
var chapLink = {}
|
||||||
|
var chapScan = "Sub"
|
||||||
|
|
||||||
|
for (var prd of body) {
|
||||||
|
var chap = prd.episodes[i];
|
||||||
|
|
||||||
|
// Check if the current provider episode is the same as the previous one.
|
||||||
|
// If not, break out of the loop.
|
||||||
|
var epNum = chap.number
|
||||||
|
if (chapNum == -1) {
|
||||||
|
chapNum = epNum
|
||||||
|
}
|
||||||
|
|
||||||
|
if (chapNum != epNum) continue;
|
||||||
|
|
||||||
|
// Episode Name is stored only once.
|
||||||
|
if (chapName.length == 0) {
|
||||||
|
chapName = `E${epNum}`
|
||||||
|
if (chap.hasOwnProperty("title")) {
|
||||||
|
if (chap.title != null) chapName += ": " + chap.title;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If Dub is available, add it to the scanlator list.
|
||||||
|
if (chap.hasOwnProperty("hasDub")) {
|
||||||
|
if (!(chapScan.includes("Dub")) && chap.hasDub) {
|
||||||
|
chapScan += ", Dub"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If isFiller is available, add it to the scanlator list.
|
||||||
|
if (chap.hasOwnProperty("isFiller")) {
|
||||||
|
if (!(chapScan.includes("Filler")) && chap.isFiller && this.getPreference("gojo_pref_mark_filler")) {
|
||||||
|
chapScan = "Filler, " + chapScan
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete unnecessary properties from the chapter object.
|
||||||
|
delete chap.image
|
||||||
|
delete chap.description
|
||||||
|
delete chap.isFiller
|
||||||
|
delete chap.title
|
||||||
|
|
||||||
|
var prdName = prd.providerId
|
||||||
|
chapLink[prdName] = chap
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
chapters.push({ name: chapName, url: `${anilistId}||` + JSON.stringify(chapLink), scanlator: chapScan })
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
chapters.reverse()
|
||||||
|
|
||||||
|
|
||||||
|
return { name, imageUrl, description, link, chapters, genres, status }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// For anime episode video list
|
// For anime episode video list
|
||||||
async getVideoList(url) {
|
async getVideoList(url) {
|
||||||
throw new Error("getVideoList not implemented");
|
throw new Error("getVideoList not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// For manga chapter pages
|
|
||||||
async getPageList(url) {
|
|
||||||
throw new Error("getPageList not implemented");
|
|
||||||
}
|
|
||||||
getFilterList() {
|
|
||||||
throw new Error("getFilterList not implemented");
|
|
||||||
}
|
|
||||||
getSourcePreferences() {
|
getSourcePreferences() {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
@@ -138,6 +221,13 @@ class DefaultExtension extends MProvider {
|
|||||||
entries: ["Romaji", "English", "Native"],
|
entries: ["Romaji", "English", "Native"],
|
||||||
entryValues: ["romaji", "english", "native"],
|
entryValues: ["romaji", "english", "native"],
|
||||||
}
|
}
|
||||||
|
}, {
|
||||||
|
key: "gojo_pref_mark_filler",
|
||||||
|
switchPreferenceCompat: {
|
||||||
|
title: "Mark filler episodes",
|
||||||
|
summary: "",
|
||||||
|
value: true
|
||||||
|
}
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user