Mangasusu: fix page parser (#2080)

This commit is contained in:
Vetle Ledaal 2024-03-25 08:21:54 +00:00 committed by Draff
parent a176c34f73
commit bc12176199
2 changed files with 25 additions and 1 deletions

View File

@ -3,7 +3,7 @@ ext {
extClass = '.Mangasusu'
themePkg = 'mangathemesia'
baseUrl = 'https://mangasusuku.xyz'
overrideVersionCode = 3
overrideVersionCode = 4
isNsfw = true
}

View File

@ -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<Page> {
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<TSReader>(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<ReaderImageSource>,
)
@Serializable
data class ReaderImageSource(
val source: String,
val images: List<String>,
)
}