From 10f75db0806a54b4aaf7e24447fb7eaab496bf51 Mon Sep 17 00:00:00 2001 From: bapeey <90949336+bapeey@users.noreply.github.com> Date: Mon, 23 Oct 2023 21:07:16 -0500 Subject: [PATCH] MangaDex: Fix fallback url (#18685) * Fix fallback url * Use chain.proceed instead newCall * Use dropWhile * Handle data-saver --- src/all/mangadex/build.gradle | 2 +- .../all/mangadex/MdAtHomeReportInterceptor.kt | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/all/mangadex/build.gradle b/src/all/mangadex/build.gradle index b38d9e61a..1e63414ee 100644 --- a/src/all/mangadex/build.gradle +++ b/src/all/mangadex/build.gradle @@ -6,7 +6,7 @@ ext { extName = 'MangaDex' pkgNameSuffix = 'all.mangadex' extClass = '.MangaDexFactory' - extVersionCode = 190 + extVersionCode = 191 isNsfw = true } diff --git a/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/MdAtHomeReportInterceptor.kt b/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/MdAtHomeReportInterceptor.kt index 41d2559eb..4c4bc315f 100644 --- a/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/MdAtHomeReportInterceptor.kt +++ b/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/MdAtHomeReportInterceptor.kt @@ -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 {