From 90ffe087dbff4869c1f57ae795d1095abb9abad1 Mon Sep 17 00:00:00 2001 From: BrutuZ Date: Sat, 30 Nov 2024 15:07:05 -0300 Subject: [PATCH] Comick: Better first cover selection (#6399) * Better first cover selection * Reformat * Deduplication of conditions --- src/all/comickfun/build.gradle | 2 +- .../extension/all/comickfun/Comick.kt | 22 +++++++++---------- .../tachiyomi/extension/all/comickfun/Dto.kt | 1 + 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/all/comickfun/build.gradle b/src/all/comickfun/build.gradle index dde448e26..5a8bdceff 100644 --- a/src/all/comickfun/build.gradle +++ b/src/all/comickfun/build.gradle @@ -1,7 +1,7 @@ ext { extName = 'Comick' extClass = '.ComickFactory' - extVersionCode = 49 + extVersionCode = 50 isNsfw = true } diff --git a/src/all/comickfun/src/eu/kanade/tachiyomi/extension/all/comickfun/Comick.kt b/src/all/comickfun/src/eu/kanade/tachiyomi/extension/all/comickfun/Comick.kt index b992f7ff9..905f6570f 100644 --- a/src/all/comickfun/src/eu/kanade/tachiyomi/extension/all/comickfun/Comick.kt +++ b/src/all/comickfun/src/eu/kanade/tachiyomi/extension/all/comickfun/Comick.kt @@ -396,17 +396,16 @@ abstract class Comick( val coversUrl = "$apiUrl/comic/${mangaData.comic.slug ?: mangaData.comic.hid}/covers?tachiyomi=true" val covers = client.newCall(GET(coversUrl)).execute() - .parseAs().mdCovers.reversed().toMutableList() - if (covers.any { it.vol == "1" }) covers.retainAll { it.vol == "1" } - if ( - covers.any { it.locale == comickLang.split('-').first() } - ) { - covers.retainAll { it.locale == comickLang.split('-').first() } - } + .parseAs().mdCovers.reversed() + val firstVol = covers.filter { it.vol == "1" }.ifEmpty { covers } + val originalCovers = firstVol + .filter { mangaData.comic.isoLang.orEmpty().startsWith(it.locale.orEmpty()) } + val localCovers = firstVol + .filter { comickLang.startsWith(it.locale.orEmpty()) } return mangaData.toSManga( includeMuTags = preferences.includeMuTags, scorePosition = preferences.scorePosition, - covers = covers, + covers = localCovers.ifEmpty { originalCovers }.ifEmpty { firstVol }, groupTags = preferences.groupTags, ) } @@ -467,9 +466,10 @@ abstract class Comick( .map { it.toSChapter(mangaUrl) } } - private val publishedDateFormat = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.ENGLISH).apply { - timeZone = TimeZone.getTimeZone("UTC") - } + private val publishedDateFormat = + SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.ENGLISH).apply { + timeZone = TimeZone.getTimeZone("UTC") + } override fun getChapterUrl(chapter: SChapter): String { return "$baseUrl${chapter.url}" diff --git a/src/all/comickfun/src/eu/kanade/tachiyomi/extension/all/comickfun/Dto.kt b/src/all/comickfun/src/eu/kanade/tachiyomi/extension/all/comickfun/Dto.kt index 822e2333f..ce5462e91 100644 --- a/src/all/comickfun/src/eu/kanade/tachiyomi/extension/all/comickfun/Dto.kt +++ b/src/all/comickfun/src/eu/kanade/tachiyomi/extension/all/comickfun/Dto.kt @@ -112,6 +112,7 @@ class Comic( @SerialName("md_comic_md_genres") val mdGenres: List, @SerialName("mu_comics") val muGenres: MuComicCategories = MuComicCategories(emptyList()), @SerialName("bayesian_rating") val score: String? = null, + @SerialName("iso639_1") val isoLang: String? = null, ) { val origination = when (country) { "jp" -> Name("Manga")