From f95d63fe4420cc0454d0464ab90b668549bb409b Mon Sep 17 00:00:00 2001 From: bapeey <90949336+bapeey@users.noreply.github.com> Date: Thu, 7 Dec 2023 08:38:04 -0500 Subject: [PATCH] Manhwa-Latino: Fix downloads (#19211) * Fix downloads * IDE Lint --- .../madara/manhwalatino/src/ManhwaLatino.kt | 23 +++++++++++++++++++ .../multisrc/madara/MadaraGenerator.kt | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/multisrc/overrides/madara/manhwalatino/src/ManhwaLatino.kt b/multisrc/overrides/madara/manhwalatino/src/ManhwaLatino.kt index 6e256c8e0..89924f572 100644 --- a/multisrc/overrides/madara/manhwalatino/src/ManhwaLatino.kt +++ b/multisrc/overrides/madara/manhwalatino/src/ManhwaLatino.kt @@ -2,6 +2,9 @@ package eu.kanade.tachiyomi.extension.es.manhwalatino import eu.kanade.tachiyomi.multisrc.madara.Madara import eu.kanade.tachiyomi.source.model.SChapter +import okhttp3.MediaType.Companion.toMediaTypeOrNull +import okhttp3.OkHttpClient +import okhttp3.ResponseBody.Companion.toResponseBody import org.jsoup.nodes.Element import java.text.SimpleDateFormat import java.util.Locale @@ -12,6 +15,26 @@ class ManhwaLatino : Madara( "es", SimpleDateFormat("dd/MM/yyyy", Locale("es")), ) { + + override val client: OkHttpClient = super.client.newBuilder() + .addInterceptor { chain -> + val request = chain.request() + val headers = request.headers.newBuilder() + .removeAll("Accept-Encoding") + .build() + val response = chain.proceed(request.newBuilder().headers(headers).build()) + if (response.headers("Content-Type").contains("application/octet-stream") && response.request.url.toString().endsWith(".jpg")) { + val orgBody = response.body.bytes() + val newBody = orgBody.toResponseBody("image/jpeg".toMediaTypeOrNull()) + response.newBuilder() + .body(newBody) + .build() + } else { + response + } + } + .build() + override val useNewChapterEndpoint = true override val chapterUrlSelector = "div.mini-letters > a" diff --git a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/madara/MadaraGenerator.kt b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/madara/MadaraGenerator.kt index 5f6dfd71a..c36cfca8a 100644 --- a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/madara/MadaraGenerator.kt +++ b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/madara/MadaraGenerator.kt @@ -330,7 +330,7 @@ class MadaraGenerator : ThemeSourceGenerator { SingleLang("ManhuaUS", "https://manhuaus.com", "en", overrideVersionCode = 5), SingleLang("ManhuaZone", "https://manhuazone.org", "en", overrideVersionCode = 1), SingleLang("Manhwa Raw", "https://manhwaraw.com", "ko", isNsfw = true, overrideVersionCode = 1), - SingleLang("Manhwa-Latino", "https://manhwa-latino.com", "es", isNsfw = true, className = "ManhwaLatino", overrideVersionCode = 6), + SingleLang("Manhwa-Latino", "https://manhwa-latino.com", "es", isNsfw = true, className = "ManhwaLatino", overrideVersionCode = 7), SingleLang("Manhwa-raw", "https://manhwa-raw.com", "all", isNsfw = true, className = "ManhwaDashRaw", overrideVersionCode = 1), SingleLang("Manhwa18.app", "https://manhwa18.app", "en", isNsfw = true, className = "Manhwa18app"), SingleLang("Manhwa18.org", "https://manhwa18.org", "en", isNsfw = true, className = "Manhwa18Org", overrideVersionCode = 2),