Baozi Manhua: fix chapter list and page list (#14198)
This commit is contained in:
parent
bb3fc7669a
commit
37ef0d1023
|
@ -1,3 +1,7 @@
|
||||||
|
## 1.3.13 (2022-11-09)
|
||||||
|
|
||||||
|
- 修复章节目录和图片分页
|
||||||
|
|
||||||
## 1.3.12 (2022-07-23)
|
## 1.3.12 (2022-07-23)
|
||||||
|
|
||||||
- 适配章节分页的重叠区域,修复图片重复、缺页的问题
|
- 适配章节分页的重叠区域,修复图片重复、缺页的问题
|
||||||
|
|
|
@ -5,7 +5,7 @@ ext {
|
||||||
extName = 'Baozi Manhua'
|
extName = 'Baozi Manhua'
|
||||||
pkgNameSuffix = 'zh.baozimanhua'
|
pkgNameSuffix = 'zh.baozimanhua'
|
||||||
extClass = '.Baozi'
|
extClass = '.Baozi'
|
||||||
extVersionCode = 12
|
extVersionCode = 13
|
||||||
}
|
}
|
||||||
|
|
||||||
apply from: "$rootDir/common.gradle"
|
apply from: "$rootDir/common.gradle"
|
||||||
|
|
|
@ -23,7 +23,6 @@ import org.jsoup.nodes.Document
|
||||||
import org.jsoup.nodes.Element
|
import org.jsoup.nodes.Element
|
||||||
import org.jsoup.select.Evaluator
|
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
|
||||||
|
@ -57,11 +56,12 @@ class Baozi : ParsedHttpSource(), ConfigurableSource {
|
||||||
|
|
||||||
override fun chapterListParse(response: Response): List<SChapter> {
|
override fun chapterListParse(response: Response): List<SChapter> {
|
||||||
val document = response.asJsoup()
|
val document = response.asJsoup()
|
||||||
return if (document.select(".l-box > .pure-g").size == 1) { // only latest chapters
|
val fullListTitle = document.selectFirst(".section-title:containsOwn(章节目录)")
|
||||||
document.select(".l-box > .pure-g > div")
|
return if (fullListTitle == null) { // only latest chapters
|
||||||
|
document.select(Evaluator.Class("comics-chapters"))
|
||||||
} else {
|
} else {
|
||||||
// chapters are listed oldest to newest in the source
|
// chapters are listed oldest to newest in the source
|
||||||
document.select(".l-box > .pure-g[id^=chapter] > div").reversed()
|
fullListTitle.parent().select(Evaluator.Class("comics-chapters")).reversed()
|
||||||
}.map { chapterFromElement(it) }.apply {
|
}.map { chapterFromElement(it) }.apply {
|
||||||
val chapterOrderPref = preferences.getString(CHAPTER_ORDER_PREF, CHAPTER_ORDER_DISABLED)
|
val chapterOrderPref = preferences.getString(CHAPTER_ORDER_PREF, CHAPTER_ORDER_DISABLED)
|
||||||
if (chapterOrderPref != CHAPTER_ORDER_DISABLED) {
|
if (chapterOrderPref != CHAPTER_ORDER_DISABLED) {
|
||||||
|
@ -132,28 +132,22 @@ class Baozi : ParsedHttpSource(), ConfigurableSource {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun fetchPageList(chapter: SChapter): Observable<List<Page>> = Single.create<List<Page>> {
|
override fun fetchPageList(chapter: SChapter): Observable<List<Page>> = Observable.fromCallable {
|
||||||
val pageNumberSelector = Evaluator.Class("comic-text__amp")
|
val pageNumberSelector = Evaluator.Class("comic-text__amp")
|
||||||
val pageList = ArrayList<Page>(0)
|
val pageList = ArrayList<Page>(0)
|
||||||
var url = baseUrl + chapter.url
|
var url = baseUrl + chapter.url
|
||||||
var pageCount = 0
|
|
||||||
var i = 0
|
var i = 0
|
||||||
do {
|
while (true) {
|
||||||
val document = client.newCall(GET(url, headers)).execute().asJsoup()
|
val document = client.newCall(GET(url, headers)).execute().asJsoup()
|
||||||
if (i == 0) {
|
|
||||||
pageCount = document.selectFirst(pageNumberSelector)
|
|
||||||
?.run { text().substringAfter('/').toInt() } ?: break
|
|
||||||
pageList.ensureCapacity(pageCount)
|
|
||||||
}
|
|
||||||
document.select(".comic-contain amp-img").dropWhile { element ->
|
document.select(".comic-contain amp-img").dropWhile { element ->
|
||||||
element.selectFirst(pageNumberSelector).text().substringBefore('/').toInt() <= i
|
element.selectFirst(pageNumberSelector).text().substringBefore('/').toInt() <= i
|
||||||
}.mapTo(pageList) { element ->
|
}.mapTo(pageList) { element ->
|
||||||
Page(i++, imageUrl = element.attr("src"))
|
Page(i++, imageUrl = element.attr("src"))
|
||||||
}
|
}
|
||||||
url = document.selectFirst(Evaluator.Id("next-chapter"))?.attr("href") ?: break
|
url = document.selectFirst(Evaluator.Id("next-chapter"))?.attr("href") ?: break
|
||||||
} while (i < pageCount)
|
}
|
||||||
it.onSuccess(pageList)
|
pageList
|
||||||
}.toObservable()
|
}
|
||||||
|
|
||||||
override fun pageListParse(document: Document) = throw UnsupportedOperationException("Not used.")
|
override fun pageListParse(document: Document) = throw UnsupportedOperationException("Not used.")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue