diff --git a/src/id/mangatale/build.gradle b/src/id/mangatale/build.gradle index e8db20776..8886a0ae5 100644 --- a/src/id/mangatale/build.gradle +++ b/src/id/mangatale/build.gradle @@ -3,7 +3,7 @@ ext { extClass = '.MangaTale' themePkg = 'mangathemesia' baseUrl = 'https://mangatale.co' - overrideVersionCode = 2 + overrideVersionCode = 3 } apply from: "$rootDir/common.gradle" diff --git a/src/id/mangatale/src/eu/kanade/tachiyomi/extension/id/mangatale/MangaTale.kt b/src/id/mangatale/src/eu/kanade/tachiyomi/extension/id/mangatale/MangaTale.kt index b6d9a7d0b..6db374ba6 100644 --- a/src/id/mangatale/src/eu/kanade/tachiyomi/extension/id/mangatale/MangaTale.kt +++ b/src/id/mangatale/src/eu/kanade/tachiyomi/extension/id/mangatale/MangaTale.kt @@ -2,13 +2,30 @@ package eu.kanade.tachiyomi.extension.id.mangatale import eu.kanade.tachiyomi.multisrc.mangathemesia.MangaThemesia import eu.kanade.tachiyomi.network.interceptor.rateLimit +import okhttp3.MediaType.Companion.toMediaType import okhttp3.OkHttpClient +import okhttp3.ResponseBody.Companion.toResponseBody import org.jsoup.nodes.Document class MangaTale : MangaThemesia("MangaTale", "https://mangatale.co", "id") { override val client: OkHttpClient = super.client.newBuilder() .rateLimit(20, 5) + .addInterceptor { chain -> + val response = chain.proceed(chain.request()) + val mime = response.headers["Content-Type"] + if (response.isSuccessful) { + if (mime != "application/octet-stream") { + return@addInterceptor response + } + // Fix image content type + val type = IMG_CONTENT_TYPE.toMediaType() + val body = response.body.bytes().toResponseBody(type) + return@addInterceptor response.newBuilder().body(body) + .header("Content-Type", IMG_CONTENT_TYPE).build() + } + response + } .build() override val seriesTitleSelector = ".ts-breadcrumb li:last-child span" @@ -16,4 +33,8 @@ class MangaTale : MangaThemesia("MangaTale", "https://mangatale.co", "id") { override fun mangaDetailsParse(document: Document) = super.mangaDetailsParse(document).apply { thumbnail_url = document.selectFirst(seriesThumbnailSelector)?.imgAttr() } + + companion object { + private const val IMG_CONTENT_TYPE = "image/jpeg" + } }