diff --git a/src/ru/mangahub/build.gradle b/src/ru/mangahub/build.gradle index 0a4bf31ee..2fd4cc8e1 100644 --- a/src/ru/mangahub/build.gradle +++ b/src/ru/mangahub/build.gradle @@ -5,12 +5,13 @@ ext { appName = 'Tachiyomi: Mangahub' pkgNameSuffix = 'ru.mangahub' extClass = '.Mangahub' - extVersionCode = 7 + extVersionCode = 8 libVersion = '1.2' } dependencies { implementation project(':lib-ratelimit') + compileOnly 'com.google.code.gson:gson:2.8.2' } apply from: "$rootDir/common.gradle" diff --git a/src/ru/mangahub/src/eu/kanade/tachiyomi/extension/ru/mangahub/Mangahub.kt b/src/ru/mangahub/src/eu/kanade/tachiyomi/extension/ru/mangahub/Mangahub.kt index e9eaa1fcb..77ad09e44 100644 --- a/src/ru/mangahub/src/eu/kanade/tachiyomi/extension/ru/mangahub/Mangahub.kt +++ b/src/ru/mangahub/src/eu/kanade/tachiyomi/extension/ru/mangahub/Mangahub.kt @@ -1,5 +1,6 @@ package eu.kanade.tachiyomi.extension.ru.mangahub +import com.google.gson.JsonParser import eu.kanade.tachiyomi.lib.ratelimit.RateLimitInterceptor import eu.kanade.tachiyomi.network.GET import eu.kanade.tachiyomi.source.model.FilterList @@ -27,6 +28,8 @@ open class Mangahub : ParsedHttpSource() { private val rateLimitInterceptor = RateLimitInterceptor(2) + private val jsonParser = JsonParser() + override val client: OkHttpClient = network.client.newBuilder() .addNetworkInterceptor(rateLimitInterceptor).build() @@ -111,11 +114,13 @@ open class Mangahub : ParsedHttpSource() { } override fun pageListParse(document: Document): List { - val pictures = document.select("div.row > div > div.mb-4").attr("data-js-scans").replace(""", "\"").replace("\\/", "/") - val r = Regex("""\/\/([\w\.\/])+""") + val chapInfo = document.select("reader").attr("data-reader-store").replace(""", "\"").replace("\\/", "/") + val chapter = jsonParser.parse(chapInfo).asJsonObject + val scans = chapter["scans"].asJsonArray + val pages = mutableListOf() - for ((index, value) in r.findAll(pictures).withIndex()) { - pages.add(Page(index = index, imageUrl = "https:${value.value}")) + scans.mapIndexed { i, page -> + pages.add(Page(i, "", "https:${page.asJsonObject.get("src").asString}")) } return pages