MangaDex: Fix fallback url (#18685)
* Fix fallback url * Use chain.proceed instead newCall * Use dropWhile * Handle data-saver
This commit is contained in:
parent
52d81f2bca
commit
10f75db080
|
@ -6,7 +6,7 @@ ext {
|
||||||
extName = 'MangaDex'
|
extName = 'MangaDex'
|
||||||
pkgNameSuffix = 'all.mangadex'
|
pkgNameSuffix = 'all.mangadex'
|
||||||
extClass = '.MangaDexFactory'
|
extClass = '.MangaDexFactory'
|
||||||
extVersionCode = 190
|
extVersionCode = 191
|
||||||
isNsfw = true
|
isNsfw = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@ package eu.kanade.tachiyomi.extension.all.mangadex
|
||||||
|
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import eu.kanade.tachiyomi.extension.all.mangadex.dto.ImageReportDto
|
import eu.kanade.tachiyomi.extension.all.mangadex.dto.ImageReportDto
|
||||||
import eu.kanade.tachiyomi.network.GET
|
|
||||||
import eu.kanade.tachiyomi.network.POST
|
import eu.kanade.tachiyomi.network.POST
|
||||||
import kotlinx.serialization.encodeToString
|
import kotlinx.serialization.encodeToString
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
|
@ -68,10 +67,15 @@ class MdAtHomeReportInterceptor(
|
||||||
Log.e("MangaDex", "Error connecting to MD@Home node, fallback to uploads server")
|
Log.e("MangaDex", "Error connecting to MD@Home node, fallback to uploads server")
|
||||||
|
|
||||||
val fallbackUrl = MDConstants.cdnUrl.toHttpUrl().newBuilder()
|
val fallbackUrl = MDConstants.cdnUrl.toHttpUrl().newBuilder()
|
||||||
.addPathSegments(originalRequest.url.pathSegments.joinToString("/"))
|
.addPathSegments(originalRequest.url.pathSegments.dropWhile{ it != "data" && it != "data-saver" }.joinToString("/"))
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
return client.newCall(GET(fallbackUrl, headers)).execute()
|
val fallbackRequest = originalRequest.newBuilder()
|
||||||
|
.url(fallbackUrl)
|
||||||
|
.headers(headers)
|
||||||
|
.build()
|
||||||
|
|
||||||
|
return chain.proceed(fallbackRequest)
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
Loading…
Reference in New Issue