Setsu Scans: Fix some more pages not loading (#590)

This commit is contained in:
Johannes Jöns 2024-01-24 19:04:13 +00:00 committed by Draff
parent ae32103858
commit e3362fd497
2 changed files with 29 additions and 2 deletions

View File

@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.extension.en.setsuscans
import eu.kanade.tachiyomi.multisrc.madara.Madara
import eu.kanade.tachiyomi.network.interceptor.rateLimit
import eu.kanade.tachiyomi.source.model.MangasPage
import okhttp3.Interceptor
import okhttp3.Response
class SetsuScans : Madara(
@ -17,7 +18,6 @@ class SetsuScans : Madara(
if (url.host == "i0.wp.com") {
val newUrl = url.newBuilder()
.removeAllQueryParameters("fit")
.removeAllQueryParameters("ssl")
.build()
return@addNetworkInterceptor chain.proceed(
@ -29,9 +29,36 @@ class SetsuScans : Madara(
return@addNetworkInterceptor chain.proceed(request)
}
.addInterceptor(::handleFailedImages)
.rateLimit(2)
.build()
private fun handleFailedImages(chain: Interceptor.Chain): Response {
val response: Response = chain.proceed(chain.request())
val url = response.request.url
if (url.host == "i0.wp.com" && response.code == 404) {
val ssl = response.request.url.queryParameter("ssl")
var newUrl = url.newBuilder()
.removeAllQueryParameters("ssl")
if (ssl.isNullOrBlank()) {
newUrl = newUrl.addQueryParameter("ssl", "0")
} else if (ssl.toInt() >= 5) {
return response
} else if (ssl.toInt() == 0) {
newUrl = newUrl.addQueryParameter("ssl", "2")
} else if (ssl.toInt() >= 2) {
newUrl = newUrl.addQueryParameter("ssl", (ssl.toInt() + 1).toString())
}
val newRequest = chain.request().newBuilder()
.url(newUrl.build())
.build()
return client.newCall(newRequest).execute()
}
return response
}
override val useNewChapterEndpoint = true
override fun searchPage(page: Int): String {

View File

@ -436,7 +436,7 @@ class MadaraGenerator : ThemeSourceGenerator {
SingleLang("Scan Hentai Menu", "https://scan.hentai.menu", "fr", isNsfw = true, overrideVersionCode = 1),
SingleLang("Scantrad-VF", "https://scantrad-vf.co", "fr", className = "ScantradVF"),
SingleLang("Sdl scans", "https://sdlscans.com", "es", className = "SdlScans"),
SingleLang("Setsu Scans", "https://setsuscans.com", "en", overrideVersionCode = 1),
SingleLang("Setsu Scans", "https://setsuscans.com", "en", overrideVersionCode = 2),
SingleLang("Shadowtrad", "https://shadowtrad.net", "fr"),
SingleLang("ShavelProiection", "https://www.shavelproiection.com", "it", true),
SingleLang("Shayami", "https://shayami.com", "es"),