KomikStation: fix chapter page (#7520)

This commit is contained in:
Riztard Lanthorn 2021-06-07 17:50:29 +07:00 committed by GitHub
parent 13ff9880f4
commit 1d3c14b75e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 4 deletions

View File

@ -1,9 +1,15 @@
package eu.kanade.tachiyomi.extension.id.komikstation package eu.kanade.tachiyomi.extension.id.komikstation
import eu.kanade.tachiyomi.multisrc.wpmangastream.WPMangaStream
import okhttp3.OkHttpClient
import java.util.concurrent.TimeUnit
import eu.kanade.tachiyomi.lib.ratelimit.RateLimitInterceptor import eu.kanade.tachiyomi.lib.ratelimit.RateLimitInterceptor
import eu.kanade.tachiyomi.multisrc.wpmangastream.WPMangaStream
import eu.kanade.tachiyomi.source.model.Page
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.jsonArray
import kotlinx.serialization.json.jsonPrimitive
import okhttp3.OkHttpClient
import org.jsoup.nodes.Document
import uy.kohesive.injekt.injectLazy
import java.util.concurrent.TimeUnit
class KomikStation : WPMangaStream("Komik Station", "https://komikstation.com", "id") { class KomikStation : WPMangaStream("Komik Station", "https://komikstation.com", "id") {
// Formerly "Komik Station (WP Manga Stream)" // Formerly "Komik Station (WP Manga Stream)"
@ -17,4 +23,27 @@ class KomikStation : WPMangaStream("Komik Station", "https://komikstation.com",
.addNetworkInterceptor(rateLimitInterceptor) .addNetworkInterceptor(rateLimitInterceptor)
.build() .build()
private val json: Json by injectLazy()
override fun pageListParse(document: Document): List<Page> {
val pages = mutableListOf<Page>()
document.select(pageSelector)
.filterNot { it.attr("src").isNullOrEmpty() }
.mapIndexed { i, img -> pages.add(Page(i, "", img.attr("abs:src"))) }
// Some sites like mangakita now load pages via javascript
if (pages.isNotEmpty()) { return pages }
val docString = document.toString()
val imageListRegex = Regex("\\\"images.*?:.*?(\\[.*?\\])")
val imageListJson = imageListRegex.find(docString)!!.destructured.toList()[0]
val imageList = json.parseToJsonElement(imageListJson).jsonArray
pages += imageList.mapIndexed { i, jsonEl ->
Page(i, "", jsonEl.jsonPrimitive.content)
}
return pages
}
} }

View File

@ -20,7 +20,7 @@ class WPMangaStreamGenerator : ThemeSourceGenerator {
SingleLang("Boosei", "https://boosei.com", "id"), SingleLang("Boosei", "https://boosei.com", "id"),
SingleLang("Mangakyo", "https://www.mangakyo.me", "id"), SingleLang("Mangakyo", "https://www.mangakyo.me", "id"),
SingleLang("Sekte Komik", "https://sektekomik.com", "id", overrideVersionCode = 2), SingleLang("Sekte Komik", "https://sektekomik.com", "id", overrideVersionCode = 2),
SingleLang("Komik Station", "https://komikstation.com", "id"), SingleLang("Komik Station", "https://komikstation.com", "id", overrideVersionCode = 1),
SingleLang("Non-Stop Scans", "https://www.nonstopscans.com", "en", className = "NonStopScans"), SingleLang("Non-Stop Scans", "https://www.nonstopscans.com", "en", className = "NonStopScans"),
SingleLang("KomikIndo.co", "https://komikindo.co", "id", className = "KomikindoCo"), SingleLang("KomikIndo.co", "https://komikindo.co", "id", className = "KomikindoCo"),
SingleLang("Readkomik", "https://readkomik.com", "en", className = "ReadKomik"), SingleLang("Readkomik", "https://readkomik.com", "en", className = "ReadKomik"),