Fix baozi
This commit is contained in:
Creepler13 2025-03-15 06:56:44 +01:00 committed by Draff
parent 1c3e40c5dc
commit a4cd04699c
No known key found for this signature in database
GPG Key ID: E8A89F3211677653
2 changed files with 31 additions and 10 deletions

View File

@ -1,7 +1,7 @@
ext { ext {
extName = 'Baozi Manhua' extName = 'Baozi Manhua'
extClass = '.Baozi' extClass = '.Baozi'
extVersionCode = 24 extVersionCode = 25
} }
apply from: "$rootDir/common.gradle" apply from: "$rootDir/common.gradle"

View File

@ -1,6 +1,7 @@
package eu.kanade.tachiyomi.extension.zh.baozimanhua package eu.kanade.tachiyomi.extension.zh.baozimanhua
import android.content.SharedPreferences import android.content.SharedPreferences
import androidx.preference.CheckBoxPreference
import androidx.preference.ListPreference import androidx.preference.ListPreference
import androidx.preference.PreferenceScreen import androidx.preference.PreferenceScreen
import com.github.stevenyomi.baozibanner.BaoziBanner import com.github.stevenyomi.baozibanner.BaoziBanner
@ -141,16 +142,18 @@ class Baozi : ParsedHttpSource(), ConfigurableSource {
} }
override fun fetchPageList(chapter: SChapter): Observable<List<Page>> = Observable.fromCallable { override fun fetchPageList(chapter: SChapter): Observable<List<Page>> = Observable.fromCallable {
val pathToUrl = LinkedHashMap<String, String>() val urls = mutableListOf<String>()
var request = GET(baseUrl + chapter.url, headers).newBuilder()
.tag(RedirectDomainInterceptor.Tag::class, RedirectDomainInterceptor.Tag()).build() var chapterUrl = baseUrl + chapter.url
if (preferences.getBoolean(QUICK_PAGES_PREF, true)) {
chapterUrl = quickPageUrl(chapterUrl)
}
var request = GET(chapterUrl, headers).newBuilder().build()
while (true) { while (true) {
val document = client.newCall(request).execute().asJsoup() val document = client.newCall(request).execute().asJsoup()
for (element in document.select(".comic-contain amp-img")) { urls.addAll(document.select(".comic-contain amp-img").map { it.absUrl("src") })
val imageUrl = element.attr("data-src")
val path = imageUrl.substring(imageUrl.indexOf('/', startIndex = 8)) // Skip "https://"
pathToUrl[path] = imageUrl
}
val url = document.selectFirst(Evaluator.Id("next-chapter")) val url = document.selectFirst(Evaluator.Id("next-chapter"))
?.takeIf { ?.takeIf {
val text = it.text() val text = it.text()
@ -158,11 +161,20 @@ class Baozi : ParsedHttpSource(), ConfigurableSource {
} }
?.attr("href") ?.attr("href")
?: break ?: break
request = GET(url, headers) request = GET(url, headers)
} }
pathToUrl.values.mapIndexed { index, imageUrl -> Page(index, imageUrl = imageUrl) } urls.mapIndexed { index, imageUrl -> Page(index, imageUrl = imageUrl) }
} }
private fun quickPageUrl(url: String): String =
baseUrl.toHttpUrl().newBuilder().apply {
val chapUrl = url.toHttpUrl()
addPathSegments("/comic/chapter")
chapUrl.queryParameter("comic_id")?.let { addPathSegment(it) }
addPathSegment("${chapUrl.queryParameter("section_slot")}_${chapUrl.queryParameter("chapter_slot")}.html")
}.build().toString()
override fun imageRequest(page: Page): Request { override fun imageRequest(page: Page): Request {
val url = page.imageUrl!!.replace(".baozicdn.com", ".baozimh.com") val url = page.imageUrl!!.replace(".baozicdn.com", ".baozimh.com")
return GET(url, headers) return GET(url, headers)
@ -268,6 +280,13 @@ class Baozi : ParsedHttpSource(), ConfigurableSource {
entryValues = arrayOf(CHAPTER_ORDER_DISABLED, CHAPTER_ORDER_ENABLED, CHAPTER_ORDER_AGGRESSIVE) entryValues = arrayOf(CHAPTER_ORDER_DISABLED, CHAPTER_ORDER_ENABLED, CHAPTER_ORDER_AGGRESSIVE)
setDefaultValue(CHAPTER_ORDER_DISABLED) setDefaultValue(CHAPTER_ORDER_DISABLED)
}.let { screen.addPreference(it) } }.let { screen.addPreference(it) }
CheckBoxPreference(screen.context).apply {
key = QUICK_PAGES_PREF
title = "Quick Pages/快速页面"
summary = "跳过页面上的重定向。五月休息。(对不起,必须使用翻译器)"
setDefaultValue(true)
}.let { screen.addPreference(it) }
} }
companion object { companion object {
@ -300,5 +319,7 @@ class Baozi : ParsedHttpSource(), ConfigurableSource {
private const val CHAPTER_ORDER_AGGRESSIVE = "2" private const val CHAPTER_ORDER_AGGRESSIVE = "2"
private val DATE_FORMAT by lazy { SimpleDateFormat("yyyy年MM月dd日", Locale.ENGLISH) } private val DATE_FORMAT by lazy { SimpleDateFormat("yyyy年MM月dd日", Locale.ENGLISH) }
private const val QUICK_PAGES_PREF = "QUICK_PAGES"
} }
} }