From b177f2057e5dce39629edb12f97d0459c3465260 Mon Sep 17 00:00:00 2001 From: Edgard Date: Mon, 3 Jun 2024 21:57:35 -0300 Subject: [PATCH] chore: More fixes --- .../tachiyomi/animeextension/pt/doramogo/AnimeQ.kt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/pt/animeq/src/eu/kanade/tachiyomi/animeextension/pt/doramogo/AnimeQ.kt b/src/pt/animeq/src/eu/kanade/tachiyomi/animeextension/pt/doramogo/AnimeQ.kt index 6eddc97e20..d31bbc8f50 100644 --- a/src/pt/animeq/src/eu/kanade/tachiyomi/animeextension/pt/doramogo/AnimeQ.kt +++ b/src/pt/animeq/src/eu/kanade/tachiyomi/animeextension/pt/doramogo/AnimeQ.kt @@ -208,7 +208,7 @@ class AnimeQ : ConfigurableAnimeSource, ParsedAnimeHttpSource() { return sortedWith( compareBy( { it.quality.contains(quality) }, - { Regex("""(\d+)p""").find(it.quality)?.groupValues?.get(1)?.toIntOrNull() ?: 0 }, + { REGEX_QUALITY.find(it.quality)?.groupValues?.get(1)?.toIntOrNull() ?: 0 }, ), ).reversed() } @@ -229,14 +229,15 @@ class AnimeQ : ConfigurableAnimeSource, ParsedAnimeHttpSource() { return when { statusString?.trim() == "Em lançamento" -> SAnime.ONGOING statusString?.trim() == "Em Andamento" -> SAnime.ONGOING - statusString?.trim()?.let { Regex("\\d").matches(it) } == true -> SAnime.COMPLETED + statusString?.trim()?.let { REGEX_NUMBER.matches(it) } == true -> SAnime.COMPLETED else -> SAnime.UNKNOWN } } private fun Element.getInfo(key: String): String? { return selectFirst("div.boxAnimeSobreLinha:has(b:contains($key))")?.run { - ownText() + text() + .substringAfter(":") .trim() .takeUnless { it.isBlank() || it == "???" } } @@ -248,6 +249,9 @@ class AnimeQ : ConfigurableAnimeSource, ParsedAnimeHttpSource() { } companion object { + private val REGEX_QUALITY by lazy { Regex("""(\d+)p""") } + private val REGEX_NUMBER by lazy { Regex("""\d+""") } + private const val PREF_QUALITY_KEY = "preferred_quality" private const val PREF_QUALITY_TITLE = "Qualidade preferida" private const val PREF_QUALITY_DEFAULT = "720p"