From b6d14247af02b5fed1944be2854f3ad9900503c8 Mon Sep 17 00:00:00 2001 From: bapeey <90949336+bapeey@users.noreply.github.com> Date: Fri, 21 Jun 2024 03:42:18 -0500 Subject: [PATCH] ArgosComics: Fix downloads (#3661) Fix --- src/pt/argoscomics/build.gradle | 2 +- .../extension/pt/argoscomics/ArgosComics.kt | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/pt/argoscomics/build.gradle b/src/pt/argoscomics/build.gradle index 4753f4bb2..1c5c7251b 100644 --- a/src/pt/argoscomics/build.gradle +++ b/src/pt/argoscomics/build.gradle @@ -3,7 +3,7 @@ ext { extClass = '.ArgosComics' themePkg = 'madara' baseUrl = 'https://argoscomic.com' - overrideVersionCode = 3 + overrideVersionCode = 4 } apply from: "$rootDir/common.gradle" diff --git a/src/pt/argoscomics/src/eu/kanade/tachiyomi/extension/pt/argoscomics/ArgosComics.kt b/src/pt/argoscomics/src/eu/kanade/tachiyomi/extension/pt/argoscomics/ArgosComics.kt index 892d1d1ef..db43fe516 100644 --- a/src/pt/argoscomics/src/eu/kanade/tachiyomi/extension/pt/argoscomics/ArgosComics.kt +++ b/src/pt/argoscomics/src/eu/kanade/tachiyomi/extension/pt/argoscomics/ArgosComics.kt @@ -2,6 +2,8 @@ package eu.kanade.tachiyomi.extension.pt.argoscomics import eu.kanade.tachiyomi.multisrc.madara.Madara import eu.kanade.tachiyomi.network.interceptor.rateLimit +import okhttp3.MediaType.Companion.toMediaType +import okhttp3.ResponseBody.Companion.toResponseBody import java.text.SimpleDateFormat import java.util.Locale @@ -13,6 +15,20 @@ class ArgosComics : Madara( ) { override val client = super.client.newBuilder() .rateLimit(3) + .addInterceptor { chain -> + val response = chain.proceed(chain.request()) + val mime = response.headers["Content-Type"] + if (response.isSuccessful) { + if (mime == "application/octet-stream" || mime == null) { + // Fix image content type + val type = "image/jpeg".toMediaType() + val body = response.body.bytes().toResponseBody(type) + return@addInterceptor response.newBuilder().body(body) + .header("Content-Type", "image/jpeg").build() + } + } + response + } .build() override val useLoadMoreRequest = LoadMoreStrategy.Always