Imitui: fix page list parsing (#14203)
This commit is contained in:
parent
578b4b85fa
commit
6a8cf260e1
|
@ -1,34 +1,16 @@
|
|||
package eu.kanade.tachiyomi.extension.zh.imitui
|
||||
|
||||
import eu.kanade.tachiyomi.multisrc.sinmh.SinMH
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
import eu.kanade.tachiyomi.source.model.Page
|
||||
import eu.kanade.tachiyomi.source.model.SChapter
|
||||
import eu.kanade.tachiyomi.util.asJsoup
|
||||
import org.jsoup.nodes.Document
|
||||
import rx.Observable
|
||||
import rx.Single
|
||||
|
||||
class Imitui : SinMH("爱米推漫画", "https://www.imitui.com") {
|
||||
|
||||
override fun chapterListSelector() = ".chapter-body li > a:not([href^=/comic/app/])"
|
||||
|
||||
override fun fetchPageList(chapter: SChapter): Observable<List<Page>> =
|
||||
Single.create<List<Page>> {
|
||||
val pcResponse = client.newCall(GET(baseUrl + chapter.url, headers)).execute()
|
||||
val pcResult = pageListParse(pcResponse.asJsoup())
|
||||
if (pcResult.isNotEmpty()) return@create it.onSuccess(pcResult)
|
||||
val mobileResponse = client.newCall(GET(mobileUrl + chapter.url, headers)).execute()
|
||||
it.onSuccess(mobilePageListParse(mobileResponse.asJsoup()))
|
||||
}.toObservable()
|
||||
|
||||
private fun mobilePageListParse(document: Document): List<Page> {
|
||||
val pageCount = document.select("div.image-content > p").text().removePrefix("1/").toInt()
|
||||
val prefix = document.location().removeSuffix(".html")
|
||||
return (0 until pageCount).map { Page(it, url = "$prefix-${it + 1}.html") }
|
||||
}
|
||||
|
||||
// mobile
|
||||
override fun imageUrlParse(document: Document): String =
|
||||
document.select("div.image-content > img#image").attr("src")
|
||||
override fun pageListParse(document: Document): List<Page> =
|
||||
document.select("img[onclick]").mapIndexed { index, img ->
|
||||
val url = img.attr("data-src").ifEmpty { img.attr("src") }
|
||||
Page(index, imageUrl = url)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ class SinMHGenerator : ThemeSourceGenerator {
|
|||
),
|
||||
SingleLang(
|
||||
name = "Imitui Manhua", baseUrl = "https://www.imitui.com", lang = "zh",
|
||||
className = "Imitui", sourceName = "爱米推漫画", overrideVersionCode = 2
|
||||
className = "Imitui", sourceName = "爱米推漫画", overrideVersionCode = 3
|
||||
),
|
||||
SingleLang( // This site blocks IP outside China
|
||||
name = "YKMH", baseUrl = "http://www.ykmh.com", lang = "zh", className = "YKMH",
|
||||
|
|
Loading…
Reference in New Issue