Skip to content

Commit

Permalink
Comick: Better first cover selection (#6399)
Browse files Browse the repository at this point in the history
* Better first cover selection

* Reformat

* Deduplication of conditions
  • Loading branch information
BrutuZ authored and cuong-tran committed Dec 1, 2024
1 parent f06dcdf commit c4cc715
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/all/comickfun/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ext {
kmkVersionCode = 1
extName = 'Comick'
extClass = '.ComickFactory'
extVersionCode = 49
extVersionCode = 50
isNsfw = true
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,17 +399,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<Covers>().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<Covers>().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,
)
}
Expand Down Expand Up @@ -491,9 +490,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}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ class Comic(
@SerialName("md_comic_md_genres") val mdGenres: List<MdGenres>,
@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")
Expand Down

0 comments on commit c4cc715

Please sign in to comment.