Fix japscan pagecount loading (fallback added) (#14122)
This commit is contained in:
parent
86562fc2cb
commit
e12605507a
|
@ -156,14 +156,14 @@ class Hiveworks : ParsedHttpSource() {
|
|||
|
||||
override fun fetchMangaDetails(manga: SManga): Observable<SManga> {
|
||||
val url = manga.url
|
||||
return client.newCall(GET(baseUrl, headers)) //Bypasses mangaDetailsRequest
|
||||
return client.newCall(GET(baseUrl, headers)) // Bypasses mangaDetailsRequest
|
||||
.asObservableSuccess()
|
||||
.map { response ->
|
||||
mangaDetailsParse(response, url).apply { initialized = true }
|
||||
}
|
||||
}
|
||||
|
||||
override fun mangaDetailsRequest(manga: SManga) = GET(manga.url, headers) //Used to open proper page in webview
|
||||
override fun mangaDetailsRequest(manga: SManga) = GET(manga.url, headers) // Used to open proper page in webview
|
||||
override fun mangaDetailsParse(document: Document): SManga = throw Exception("Not Used")
|
||||
private fun mangaDetailsParse(response: Response, url: String): SManga {
|
||||
val document = response.asJsoup()
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package eu.kanade.tachiyomi.extension.en.ninehentai
|
||||
|
||||
import android.util.Log
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
import eu.kanade.tachiyomi.network.POST
|
||||
import eu.kanade.tachiyomi.network.asObservableSuccess
|
||||
|
|
|
@ -303,7 +303,7 @@ class Readcomiconline : ConfigurableSource, ParsedHttpSource() {
|
|||
var images = ${json.encodeToJsonElement(urls)};
|
||||
beau(images);
|
||||
images;
|
||||
""".trimIndent()
|
||||
""".trimIndent()
|
||||
(it.evaluate(script) as Array<Any>).map { it as String }.toList()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ ext {
|
|||
extName = 'Japscan'
|
||||
pkgNameSuffix = 'fr.japscan'
|
||||
extClass = '.Japscan'
|
||||
extVersionCode = 33
|
||||
extVersionCode = 34
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
|
|
@ -351,8 +351,26 @@ class Japscan : ConfigurableSource, ParsedHttpSource() {
|
|||
Log.d("japscan", "ZJS at $zjsurl")
|
||||
val zjs = client.newCall(GET(baseUrl + zjsurl, headers)).execute().body!!.string()
|
||||
Log.d("japscan", "webtoon, netdumping initiated")
|
||||
|
||||
val pagesElement = document.getElementById("pages")
|
||||
var pagecount = pagesElement.getElementsByTag("option").size
|
||||
|
||||
Log.d("japscan", "fallback $pagecount")
|
||||
|
||||
if (pagecount == 0) {
|
||||
Log.d("japscan", "pagecount not found, fallback 1")
|
||||
val element = document.select(".card:first-child .card-body p").toString()
|
||||
|
||||
val regex = """Pages<\/span>: ([0-9]+)<\/p>""".toRegex()
|
||||
val matchResult = regex.find(element)
|
||||
|
||||
val (pagecountFromRegex) = matchResult!!.destructured
|
||||
|
||||
pagecount = pagecountFromRegex.toInt()
|
||||
|
||||
Log.d("japscan", "fallback pagecount with regex, result: $pagecount")
|
||||
}
|
||||
|
||||
val pages = ArrayList<Page>()
|
||||
val handler = Handler(Looper.getMainLooper())
|
||||
val checkNew = ArrayList<String>(pagecount)
|
||||
|
@ -379,6 +397,7 @@ class Japscan : ConfigurableSource, ParsedHttpSource() {
|
|||
webview.webViewClient = object : WebViewClient() {
|
||||
override fun onPageFinished(view: WebView, url: String?) {
|
||||
if (pagecount === 0) {
|
||||
Log.d("japscan", "pagecount not found, fallback 2")
|
||||
Log.d("japscan", "dynamic page count detected, loading it through JS")
|
||||
super.onPageFinished(view, url)
|
||||
view.evaluateJavascript(
|
||||
|
|
|
@ -172,7 +172,7 @@ class Nekopost : ParsedHttpSource() {
|
|||
|
||||
override fun popularMangaRequest(page: Int): Request {
|
||||
if (page <= 1) existingProject.clear()
|
||||
//API has a bug that sometime it returns null on first page
|
||||
// API has a bug that sometime it returns null on first page
|
||||
return GET("$latestMangaEndpoint/${if (firstPageNulled) page else page - 1 }", headers)
|
||||
}
|
||||
|
||||
|
@ -194,7 +194,7 @@ class Nekopost : ParsedHttpSource() {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
firstPageNulled = true //API has a bug that sometime it returns null on first page
|
||||
firstPageNulled = true // API has a bug that sometime it returns null on first page
|
||||
return MangasPage(emptyList(), hasNextPage = false)
|
||||
}
|
||||
|
||||
|
|
|
@ -87,7 +87,6 @@ class Niceoppai : ParsedHttpSource() {
|
|||
}
|
||||
|
||||
MangasPage(mangas, false)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue