Manhwa-Latino: Fix downloads (#19211)

* Fix downloads

* IDE Lint
This commit is contained in:
bapeey 2023-12-07 08:38:04 -05:00 committed by GitHub
parent 59855e8e37
commit f95d63fe44
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 1 deletions

View File

@ -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"

View File

@ -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),