Fix CatManga broken chapters (#9437)
This commit is contained in:
parent
ececeb7d93
commit
7bbd88cfa8
|
@ -6,7 +6,7 @@ ext {
|
||||||
extName = 'CatManga'
|
extName = 'CatManga'
|
||||||
pkgNameSuffix = "en.catmanga"
|
pkgNameSuffix = "en.catmanga"
|
||||||
extClass = '.CatManga'
|
extClass = '.CatManga'
|
||||||
extVersionCode = 5
|
extVersionCode = 6
|
||||||
}
|
}
|
||||||
|
|
||||||
apply from: "$rootDir/common.gradle"
|
apply from: "$rootDir/common.gradle"
|
||||||
|
|
|
@ -13,8 +13,10 @@ import eu.kanade.tachiyomi.util.asJsoup
|
||||||
import kotlinx.serialization.ExperimentalSerializationApi
|
import kotlinx.serialization.ExperimentalSerializationApi
|
||||||
import kotlinx.serialization.decodeFromString
|
import kotlinx.serialization.decodeFromString
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
|
import kotlinx.serialization.json.boolean
|
||||||
import kotlinx.serialization.json.decodeFromJsonElement
|
import kotlinx.serialization.json.decodeFromJsonElement
|
||||||
import kotlinx.serialization.json.jsonObject
|
import kotlinx.serialization.json.jsonObject
|
||||||
|
import kotlinx.serialization.json.jsonPrimitive
|
||||||
import okhttp3.Request
|
import okhttp3.Request
|
||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
import org.jsoup.nodes.Document
|
import org.jsoup.nodes.Document
|
||||||
|
@ -118,12 +120,22 @@ class CatManga : HttpSource() {
|
||||||
return MangasPage(mangas, false)
|
return MangasPage(mangas, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun pageListParse(response: Response): List<Page> {
|
override fun fetchPageList(chapter: SChapter): Observable<List<Page>> {
|
||||||
val jsonElement = response.asJsoup()
|
return client.newCall(pageListRequest(chapter))
|
||||||
.getDataJsonObject()["props"]!!
|
.asObservableSuccess()
|
||||||
.jsonObject["pageProps"]!!
|
.map {
|
||||||
.jsonObject["pages"]!!
|
val doc = it.asJsoup().getDataJsonObject()
|
||||||
return json.decodeFromJsonElement<List<String>>(jsonElement).mapIndexed { index, s -> Page(index, "", s) }
|
val pages = if (doc["isFallback"]!!.jsonPrimitive.boolean) {
|
||||||
|
val buildId = doc["buildId"]!!.jsonPrimitive.content
|
||||||
|
val directRequest = GET("$baseUrl/_next/data/$buildId/${chapter.url}.json")
|
||||||
|
val directResponse = client.newCall(directRequest).execute()
|
||||||
|
json.parseToJsonElement(directResponse.body!!.string())
|
||||||
|
} else {
|
||||||
|
doc["props"]!!
|
||||||
|
}.jsonObject["pageProps"]!!.jsonObject["pages"]!!
|
||||||
|
json.decodeFromJsonElement<List<String>>(pages)
|
||||||
|
.mapIndexed { index, s -> Page(index, "", s) }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -138,6 +150,10 @@ class CatManga : HttpSource() {
|
||||||
return if (toInt().toFloat() == this) toInt().toString() else toString()
|
return if (toInt().toFloat() == this) toInt().toString() else toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun pageListParse(response: Response): List<Page> {
|
||||||
|
throw UnsupportedOperationException("Not used.")
|
||||||
|
}
|
||||||
|
|
||||||
override fun latestUpdatesRequest(page: Int): Request {
|
override fun latestUpdatesRequest(page: Int): Request {
|
||||||
throw UnsupportedOperationException("Not used.")
|
throw UnsupportedOperationException("Not used.")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue