Fix: Manwa.me download and read only showing 3 pages (#17970)
This commit is contained in:
parent
0cd9623459
commit
89ec0bd571
|
@ -5,7 +5,7 @@ ext {
|
||||||
extName = 'Manwa'
|
extName = 'Manwa'
|
||||||
pkgNameSuffix = 'zh.manwa'
|
pkgNameSuffix = 'zh.manwa'
|
||||||
extClass = '.Manwa'
|
extClass = '.Manwa'
|
||||||
extVersionCode = 3
|
extVersionCode = 4
|
||||||
isNsfw = true
|
isNsfw = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.extension.zh.manwa
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
|
import androidx.preference.CheckBoxPreference
|
||||||
import androidx.preference.ListPreference
|
import androidx.preference.ListPreference
|
||||||
import androidx.preference.PreferenceScreen
|
import androidx.preference.PreferenceScreen
|
||||||
import eu.kanade.tachiyomi.network.GET
|
import eu.kanade.tachiyomi.network.GET
|
||||||
|
@ -19,6 +20,8 @@ import kotlinx.serialization.json.int
|
||||||
import kotlinx.serialization.json.jsonArray
|
import kotlinx.serialization.json.jsonArray
|
||||||
import kotlinx.serialization.json.jsonObject
|
import kotlinx.serialization.json.jsonObject
|
||||||
import kotlinx.serialization.json.jsonPrimitive
|
import kotlinx.serialization.json.jsonPrimitive
|
||||||
|
import okhttp3.Cookie
|
||||||
|
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
|
||||||
import okhttp3.Interceptor
|
import okhttp3.Interceptor
|
||||||
import okhttp3.MediaType.Companion.toMediaTypeOrNull
|
import okhttp3.MediaType.Companion.toMediaTypeOrNull
|
||||||
import okhttp3.OkHttpClient
|
import okhttp3.OkHttpClient
|
||||||
|
@ -67,6 +70,8 @@ class Manwa : ParsedHttpSource(), ConfigurableSource {
|
||||||
.addNetworkInterceptor(rewriteOctetStream)
|
.addNetworkInterceptor(rewriteOctetStream)
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
|
private val baseHttpUrl = baseUrl.toHttpUrlOrNull()
|
||||||
|
|
||||||
// Popular
|
// Popular
|
||||||
override fun popularMangaRequest(page: Int) = GET("$baseUrl/rank", headers)
|
override fun popularMangaRequest(page: Int) = GET("$baseUrl/rank", headers)
|
||||||
override fun popularMangaNextPageSelector(): String? = null
|
override fun popularMangaNextPageSelector(): String? = null
|
||||||
|
@ -99,6 +104,7 @@ class Manwa : ParsedHttpSource(), ConfigurableSource {
|
||||||
val totalPage = jsonObject["total"]!!.jsonPrimitive.int
|
val totalPage = jsonObject["total"]!!.jsonPrimitive.int
|
||||||
return MangasPage(mangas, totalPage > currentPage + 15)
|
return MangasPage(mangas, totalPage > currentPage + 15)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun latestUpdatesNextPageSelector() = throw Exception("Not used")
|
override fun latestUpdatesNextPageSelector() = throw Exception("Not used")
|
||||||
override fun latestUpdatesSelector() = throw Exception("Not used")
|
override fun latestUpdatesSelector() = throw Exception("Not used")
|
||||||
override fun latestUpdatesFromElement(element: Element) = throw Exception("Not used")
|
override fun latestUpdatesFromElement(element: Element) = throw Exception("Not used")
|
||||||
|
@ -138,6 +144,7 @@ class Manwa : ParsedHttpSource(), ConfigurableSource {
|
||||||
url = element.attr("href")
|
url = element.attr("href")
|
||||||
name = element.text()
|
name = element.text()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun chapterListParse(response: Response): List<SChapter> {
|
override fun chapterListParse(response: Response): List<SChapter> {
|
||||||
return super.chapterListParse(response).reversed()
|
return super.chapterListParse(response).reversed()
|
||||||
}
|
}
|
||||||
|
@ -153,7 +160,20 @@ class Manwa : ParsedHttpSource(), ConfigurableSource {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun pageListParse(document: Document): List<Page> = mutableListOf<Page>().apply {
|
override fun pageListParse(document: Document): List<Page> = mutableListOf<Page>().apply {
|
||||||
document.select("#cp_img > .img-content > img[data-r-src]").forEachIndexed { index, it ->
|
val cssQuery = "#cp_img > div.img-content > img[data-r-src]"
|
||||||
|
val elements = document.select(cssQuery)
|
||||||
|
if (elements.size == 3) {
|
||||||
|
val darkReader = document.selectFirst("#cp_img p")
|
||||||
|
if (darkReader != null) {
|
||||||
|
if (preferences.getBoolean(AUTO_CLEAR_COOKIE_KEY, false)) {
|
||||||
|
clearCookies()
|
||||||
|
}
|
||||||
|
|
||||||
|
throw Exception(darkReader.text())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
elements.forEachIndexed { index, it ->
|
||||||
add(Page(index, "", it.attr("data-r-src")))
|
add(Page(index, "", it.attr("data-r-src")))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -168,11 +188,32 @@ class Manwa : ParsedHttpSource(), ConfigurableSource {
|
||||||
entryValues = IMAGE_HOST_ENTRY_VALUES
|
entryValues = IMAGE_HOST_ENTRY_VALUES
|
||||||
setDefaultValue(IMAGE_HOST_ENTRY_VALUES[0])
|
setDefaultValue(IMAGE_HOST_ENTRY_VALUES[0])
|
||||||
}.let { screen.addPreference(it) }
|
}.let { screen.addPreference(it) }
|
||||||
|
|
||||||
|
CheckBoxPreference(screen.context).apply {
|
||||||
|
key = AUTO_CLEAR_COOKIE_KEY
|
||||||
|
title = "自动删除 Cookie"
|
||||||
|
|
||||||
|
setDefaultValue(false)
|
||||||
|
}.let { screen.addPreference(it) }
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun clearCookies() {
|
||||||
|
if (baseHttpUrl == null) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
val cookies = client.cookieJar.loadForRequest(baseHttpUrl)
|
||||||
|
val obsoletedCookies = cookies.map {
|
||||||
|
val cookie = Cookie.parse(baseHttpUrl, "${it.name}=; Max-Age=-1")!!
|
||||||
|
cookie
|
||||||
|
}
|
||||||
|
client.cookieJar.saveFromResponse(baseHttpUrl, obsoletedCookies)
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val IMAGE_HOST_KEY = "IMG_HOST"
|
private const val IMAGE_HOST_KEY = "IMG_HOST"
|
||||||
private val IMAGE_HOST_ENTRIES = arrayOf("图源1", "图源2", "图源3")
|
private val IMAGE_HOST_ENTRIES = arrayOf("图源1", "图源2", "图源3")
|
||||||
private val IMAGE_HOST_ENTRY_VALUES = arrayOf("1", "2", "3")
|
private val IMAGE_HOST_ENTRY_VALUES = arrayOf("1", "2", "3")
|
||||||
|
|
||||||
|
private const val AUTO_CLEAR_COOKIE_KEY = "CLEAR_COOKIE"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue