Baozi Manhua: chapter image pagination (#12646)
This commit is contained in:
parent
a9a32bc6ac
commit
adc8fdafb8
|
@ -1,3 +1,7 @@
|
|||
## 1.3.10 (2022-07-20)
|
||||
|
||||
- 适配章节分页
|
||||
|
||||
## 1.3.9 (2022-07-12)
|
||||
|
||||
- 修复章节图片解析
|
||||
|
|
|
@ -5,7 +5,7 @@ ext {
|
|||
extName = 'Baozi Manhua'
|
||||
pkgNameSuffix = 'zh.baozimanhua'
|
||||
extClass = '.Baozi'
|
||||
extVersionCode = 9
|
||||
extVersionCode = 10
|
||||
}
|
||||
|
||||
apply from: "$rootDir/common.gradle"
|
||||
|
|
|
@ -21,7 +21,9 @@ import okhttp3.Request
|
|||
import okhttp3.Response
|
||||
import org.jsoup.nodes.Document
|
||||
import org.jsoup.nodes.Element
|
||||
import org.jsoup.select.Evaluator
|
||||
import rx.Observable
|
||||
import rx.Single
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import java.text.SimpleDateFormat
|
||||
|
@ -122,11 +124,27 @@ class Baozi : ParsedHttpSource(), ConfigurableSource {
|
|||
}
|
||||
}
|
||||
|
||||
override fun pageListParse(document: Document): List<Page> {
|
||||
return document.select(".comic-contain amp-img").mapIndexed { index, element ->
|
||||
Page(index, imageUrl = element.attr("src"))
|
||||
}
|
||||
}
|
||||
override fun fetchPageList(chapter: SChapter): Observable<List<Page>> = Single.create<List<Page>> {
|
||||
val pageList = ArrayList<Page>(0)
|
||||
var url = baseUrl + chapter.url
|
||||
var pageCount = 0
|
||||
var i = 0
|
||||
do {
|
||||
val document = client.newCall(GET(url, headers)).execute().asJsoup()
|
||||
if (i == 0) {
|
||||
pageCount = document.selectFirst(Evaluator.Class("comic-text__amp"))
|
||||
?.run { text().substringAfter('/').toInt() } ?: break
|
||||
pageList.ensureCapacity(pageCount)
|
||||
}
|
||||
document.select(".comic-contain amp-img").mapTo(pageList) { element ->
|
||||
Page(i++, imageUrl = element.attr("src"))
|
||||
}
|
||||
url = document.selectFirst(Evaluator.Id("next-chapter"))?.attr("href") ?: ""
|
||||
} while (i < pageCount)
|
||||
it.onSuccess(pageList)
|
||||
}.toObservable()
|
||||
|
||||
override fun pageListParse(document: Document) = throw UnsupportedOperationException("Not used.")
|
||||
|
||||
override fun imageUrlParse(document: Document) = throw UnsupportedOperationException("Not used.")
|
||||
|
||||
|
|
Loading…
Reference in New Issue