From bc121761998bf643943937a4eb085cd55dfa16f9 Mon Sep 17 00:00:00 2001 From: Vetle Ledaal Date: Mon, 25 Mar 2024 08:21:54 +0000 Subject: [PATCH] Mangasusu: fix page parser (#2080) --- src/id/mangasusu/build.gradle | 2 +- .../extension/id/mangasusu/Mangasusu.kt | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/id/mangasusu/build.gradle b/src/id/mangasusu/build.gradle index b666dfd46..59591a2bd 100644 --- a/src/id/mangasusu/build.gradle +++ b/src/id/mangasusu/build.gradle @@ -3,7 +3,7 @@ ext { extClass = '.Mangasusu' themePkg = 'mangathemesia' baseUrl = 'https://mangasusuku.xyz' - overrideVersionCode = 3 + overrideVersionCode = 4 isNsfw = true } diff --git a/src/id/mangasusu/src/eu/kanade/tachiyomi/extension/id/mangasusu/Mangasusu.kt b/src/id/mangasusu/src/eu/kanade/tachiyomi/extension/id/mangasusu/Mangasusu.kt index 76aa7aaff..cc01b30e4 100644 --- a/src/id/mangasusu/src/eu/kanade/tachiyomi/extension/id/mangasusu/Mangasusu.kt +++ b/src/id/mangasusu/src/eu/kanade/tachiyomi/extension/id/mangasusu/Mangasusu.kt @@ -2,10 +2,14 @@ package eu.kanade.tachiyomi.extension.id.mangasusu import app.cash.quickjs.QuickJs import eu.kanade.tachiyomi.multisrc.mangathemesia.MangaThemesia +import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.util.asJsoup +import kotlinx.serialization.Serializable +import kotlinx.serialization.decodeFromString import okhttp3.Cookie import okhttp3.Interceptor import okhttp3.Response +import org.jsoup.nodes.Document import java.io.IOException class Mangasusu : MangaThemesia("Mangasusu", "https://mangasusuku.xyz", "id", "/komik") { @@ -46,4 +50,24 @@ class Mangasusu : MangaThemesia("Mangasusu", "https://mangasusuku.xyz", "id", "/ } return response } + + override fun pageListParse(document: Document): List { + val scriptContent = document.selectFirst("script:containsData(ts_reader)")?.data() + ?: return super.pageListParse(document) + val jsonString = scriptContent.substringAfter("ts_reader.run(").substringBefore(");") + val tsReader = json.decodeFromString(jsonString) + val imageUrls = tsReader.sources.firstOrNull()?.images ?: return emptyList() + return imageUrls.mapIndexed { index, imageUrl -> Page(index, document.location(), imageUrl) } + } + + @Serializable + data class TSReader( + val sources: List, + ) + + @Serializable + data class ReaderImageSource( + val source: String, + val images: List, + ) }