Baozi Manhua: chapter image pagination (#12646)

This commit is contained in:
stevenyomi 2022-07-21 10:35:30 +08:00 committed by GitHub
parent a9a32bc6ac
commit adc8fdafb8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 6 deletions

View File

@ -1,3 +1,7 @@
## 1.3.10 (2022-07-20)
- 适配章节分页
## 1.3.9 (2022-07-12) ## 1.3.9 (2022-07-12)
- 修复章节图片解析 - 修复章节图片解析

View File

@ -5,7 +5,7 @@ ext {
extName = 'Baozi Manhua' extName = 'Baozi Manhua'
pkgNameSuffix = 'zh.baozimanhua' pkgNameSuffix = 'zh.baozimanhua'
extClass = '.Baozi' extClass = '.Baozi'
extVersionCode = 9 extVersionCode = 10
} }
apply from: "$rootDir/common.gradle" apply from: "$rootDir/common.gradle"

View File

@ -21,7 +21,9 @@ import okhttp3.Request
import okhttp3.Response import okhttp3.Response
import org.jsoup.nodes.Document import org.jsoup.nodes.Document
import org.jsoup.nodes.Element import org.jsoup.nodes.Element
import org.jsoup.select.Evaluator
import rx.Observable import rx.Observable
import rx.Single
import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get import uy.kohesive.injekt.api.get
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
@ -122,11 +124,27 @@ class Baozi : ParsedHttpSource(), ConfigurableSource {
} }
} }
override fun pageListParse(document: Document): List<Page> { override fun fetchPageList(chapter: SChapter): Observable<List<Page>> = Single.create<List<Page>> {
return document.select(".comic-contain amp-img").mapIndexed { index, element -> val pageList = ArrayList<Page>(0)
Page(index, imageUrl = element.attr("src")) 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.") override fun imageUrlParse(document: Document) = throw UnsupportedOperationException("Not used.")