From dcb623cdb350322f94e2d911603af4742ae4acd9 Mon Sep 17 00:00:00 2001 From: Vetle Ledaal Date: Sun, 29 Dec 2024 07:52:28 +0100 Subject: [PATCH] Eros Scans: update domain, skip redirect on CDN (#6887) --- src/en/erosscans/build.gradle | 4 ++-- .../extension/en/erosscans/ErosScans.kt | 22 ++++++++++++++++++- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/en/erosscans/build.gradle b/src/en/erosscans/build.gradle index 624133522..508854572 100644 --- a/src/en/erosscans/build.gradle +++ b/src/en/erosscans/build.gradle @@ -2,8 +2,8 @@ ext { extName = 'Eros Scans' extClass = '.ErosScans' themePkg = 'mangathemesia' - baseUrl = 'https://tercoscans.xyz' - overrideVersionCode = 1 + baseUrl = 'https://eros-toons.xyz' + overrideVersionCode = 2 isNsfw = false } diff --git a/src/en/erosscans/src/eu/kanade/tachiyomi/extension/en/erosscans/ErosScans.kt b/src/en/erosscans/src/eu/kanade/tachiyomi/extension/en/erosscans/ErosScans.kt index ab12696e0..7d7f0d9f8 100644 --- a/src/en/erosscans/src/eu/kanade/tachiyomi/extension/en/erosscans/ErosScans.kt +++ b/src/en/erosscans/src/eu/kanade/tachiyomi/extension/en/erosscans/ErosScans.kt @@ -2,13 +2,33 @@ package eu.kanade.tachiyomi.extension.en.erosscans import eu.kanade.tachiyomi.multisrc.mangathemesia.MangaThemesia import eu.kanade.tachiyomi.network.interceptor.rateLimit +import okhttp3.HttpUrl.Companion.toHttpUrl +import okhttp3.Interceptor +import okhttp3.Response class ErosScans : MangaThemesia( "Eros Scans", - "https://tercoscans.xyz", + "https://eros-toons.xyz", "en", ) { override val client = super.client.newBuilder() + .addInterceptor(::cdnRedirectInterceptor) .rateLimit(3) .build() + + private fun cdnRedirectInterceptor(chain: Interceptor.Chain): Response { + val request = chain.request() + if (request.url.host != "erosscans.xyz") { + return chain.proceed(request) + } + + val newUrl = request.url.newBuilder() + .host(baseUrl.toHttpUrl().host) + .build() + val newRequest = request.newBuilder() + .url(newUrl) + .build() + + return chain.proceed(newRequest) + } }