MangaDex: Fix fallback url (#18685)

* Fix fallback url

* Use chain.proceed instead newCall

* Use dropWhile

* Handle data-saver
This commit is contained in:
bapeey 2023-10-23 21:07:16 -05:00 committed by GitHub
parent 52d81f2bca
commit 10f75db080
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

View File

@ -6,7 +6,7 @@ ext {
extName = 'MangaDex'
pkgNameSuffix = 'all.mangadex'
extClass = '.MangaDexFactory'
extVersionCode = 190
extVersionCode = 191
isNsfw = true
}

View File

@ -2,7 +2,6 @@ package eu.kanade.tachiyomi.extension.all.mangadex
import android.util.Log
import eu.kanade.tachiyomi.extension.all.mangadex.dto.ImageReportDto
import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.network.POST
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
@ -68,10 +67,15 @@ class MdAtHomeReportInterceptor(
Log.e("MangaDex", "Error connecting to MD@Home node, fallback to uploads server")
val fallbackUrl = MDConstants.cdnUrl.toHttpUrl().newBuilder()
.addPathSegments(originalRequest.url.pathSegments.joinToString("/"))
.addPathSegments(originalRequest.url.pathSegments.dropWhile{ it != "data" && it != "data-saver" }.joinToString("/"))
.build()
return client.newCall(GET(fallbackUrl, headers)).execute()
val fallbackRequest = originalRequest.newBuilder()
.url(fallbackUrl)
.headers(headers)
.build()
return chain.proceed(fallbackRequest)
}
companion object {