request converted image from server if format is not supported (#1453)

This commit is contained in:
Gauthier 2019-09-07 11:12:54 +08:00 committed by Eugene
parent ed870c659f
commit 926ba3c6ce
3 changed files with 11 additions and 3 deletions

View File

@ -5,7 +5,7 @@ ext {
appName = 'Tachiyomi: Komga'
pkgNameSuffix = 'all.komga'
extClass = '.Komga'
extVersionCode = 1
extVersionCode = 2
libVersion = '1.2'
}

View File

@ -73,7 +73,12 @@ open class Komga : ConfigurableSource, HttpSource() {
override fun pageListParse(response: Response): List<Page> {
val pages = gson.fromJson<List<PageDto>>(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")
}
}

View File

@ -20,5 +20,6 @@ data class BookMetadataDto(
data class PageDto(
val number: Int,
val fileName: String
val fileName: String,
val mediaType: String
)