From 926ba3c6cea441038282e023b20b487706b0d4f7 Mon Sep 17 00:00:00 2001 From: Gauthier Date: Sat, 7 Sep 2019 11:12:54 +0800 Subject: [PATCH] request converted image from server if format is not supported (#1453) --- src/all/komga/build.gradle | 2 +- .../src/eu/kanade/tachiyomi/extension/all/komga/Komga.kt | 9 ++++++++- .../eu/kanade/tachiyomi/extension/all/komga/dto/Dto.kt | 3 ++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/all/komga/build.gradle b/src/all/komga/build.gradle index 5d412a16a..1265ae482 100644 --- a/src/all/komga/build.gradle +++ b/src/all/komga/build.gradle @@ -5,7 +5,7 @@ ext { appName = 'Tachiyomi: Komga' pkgNameSuffix = 'all.komga' extClass = '.Komga' - extVersionCode = 1 + extVersionCode = 2 libVersion = '1.2' } diff --git a/src/all/komga/src/eu/kanade/tachiyomi/extension/all/komga/Komga.kt b/src/all/komga/src/eu/kanade/tachiyomi/extension/all/komga/Komga.kt index 3af5b3ba4..9f397b12f 100644 --- a/src/all/komga/src/eu/kanade/tachiyomi/extension/all/komga/Komga.kt +++ b/src/all/komga/src/eu/kanade/tachiyomi/extension/all/komga/Komga.kt @@ -73,7 +73,12 @@ open class Komga : ConfigurableSource, HttpSource() { override fun pageListParse(response: Response): List { val pages = gson.fromJson>(response.body()?.charStream()!!) return pages.map { - val url = "${response.request().url()}/${it.number}" + val url = "${response.request().url()}/${it.number}" + + if (!supportedImageTypes.contains(it.mediaType)) { + "?convert=png" + } else { + "" + } Page( index = it.number - 1, imageUrl = url @@ -177,5 +182,7 @@ open class Komga : ConfigurableSource, HttpSource() { private const val USERNAME_DEFAULT = "" private const val PASSWORD_TITLE = "Password" private const val PASSWORD_DEFAULT = "" + + private val supportedImageTypes = listOf("image/jpeg", "image/png", "image/gif", "image/webp") } } diff --git a/src/all/komga/src/eu/kanade/tachiyomi/extension/all/komga/dto/Dto.kt b/src/all/komga/src/eu/kanade/tachiyomi/extension/all/komga/dto/Dto.kt index 144270fa7..d7b283f5d 100644 --- a/src/all/komga/src/eu/kanade/tachiyomi/extension/all/komga/dto/Dto.kt +++ b/src/all/komga/src/eu/kanade/tachiyomi/extension/all/komga/dto/Dto.kt @@ -20,5 +20,6 @@ data class BookMetadataDto( data class PageDto( val number: Int, - val fileName: String + val fileName: String, + val mediaType: String )