From 1e13faa4907f82e379f27092d67341f9e2fb3cd9 Mon Sep 17 00:00:00 2001 From: Masga <45129872+mxsgx@users.noreply.github.com> Date: Fri, 24 Jun 2022 09:25:19 +0700 Subject: [PATCH] Fix GabutScans Broken Images (#12279) * fix broken image * refactor and fix chapter image broken * Apply suggestions Co-authored-by: stevenyomi <95685115+stevenyomi@users.noreply.github.com> * remove `pages` Co-authored-by: stevenyomi <95685115+stevenyomi@users.noreply.github.com> --- .../gabutscans/src/GabutScans.kt | 30 +++++++++++++++++++ .../wpmangareader/WPMangaReaderGenerator.kt | 2 +- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/multisrc/overrides/wpmangareader/gabutscans/src/GabutScans.kt b/multisrc/overrides/wpmangareader/gabutscans/src/GabutScans.kt index 31c30f772..9ade9db66 100644 --- a/multisrc/overrides/wpmangareader/gabutscans/src/GabutScans.kt +++ b/multisrc/overrides/wpmangareader/gabutscans/src/GabutScans.kt @@ -1,6 +1,11 @@ package eu.kanade.tachiyomi.extension.id.gabutscans import eu.kanade.tachiyomi.multisrc.wpmangareader.WPMangaReader +import eu.kanade.tachiyomi.source.model.Page +import kotlinx.serialization.json.jsonArray +import kotlinx.serialization.json.jsonPrimitive +import org.jsoup.nodes.Document +import org.jsoup.nodes.Element import java.text.SimpleDateFormat import java.util.Locale @@ -10,4 +15,29 @@ class GabutScans : WPMangaReader( ) { override val hasProjectPage = true + + override fun searchMangaFromElement(element: Element) = + super.searchMangaFromElement(element).apply { + thumbnail_url = element.select("img").attr("abs:data-src") + } + + override fun mangaDetailsParse(document: Document) = super.mangaDetailsParse(document).apply { + thumbnail_url = document.select(seriesThumbnailSelector).attr("abs:data-src") + } + + override fun pageListParse(document: Document): List { + // Prefer using sources loaded from javascript + // because current CDN (Statically) can't load old images. + // Example: https://gabutscans.com/cinderella-wa-sagasanai-chapter-41-end-bahasa-indonesia/ + + val docString = document.toString() + val imageListRegex = Regex("""\"images.*?:.*?(\[.*?])""") + val (imageListJson) = imageListRegex.find(docString)!!.destructured + + val imageList = json.parseToJsonElement(imageListJson).jsonArray + + return imageList.mapIndexed { i, jsonEl -> + Page(i, "", jsonEl.jsonPrimitive.content) + } + } } diff --git a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/wpmangareader/WPMangaReaderGenerator.kt b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/wpmangareader/WPMangaReaderGenerator.kt index a22ff25a1..4aad9269a 100644 --- a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/wpmangareader/WPMangaReaderGenerator.kt +++ b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/wpmangareader/WPMangaReaderGenerator.kt @@ -22,7 +22,7 @@ class WPMangaReaderGenerator : ThemeSourceGenerator { SingleLang("BeastScans", "https://beastscans.com", "en"), SingleLang("Franxx Mangás", "https://franxxmangas.net", "pt-BR", className = "FranxxMangas", isNsfw = true), SingleLang("Fusion Scanlation", "https://fusionscanlation.com", "es", className = "FusionScanlation", overrideVersionCode = 2), - SingleLang("Gabut Scans", "https://gabutscans.com", "id"), + SingleLang("Gabut Scans", "https://gabutscans.com", "id", overrideVersionCode = 1), SingleLang("Gecenin Lordu", "https://geceninlordu.com", "tr", overrideVersionCode = 1), SingleLang("InariManga", "https://inarimanga.com", "es"), SingleLang("Kiryuu", "https://kiryuu.id", "id", overrideVersionCode = 6),