From ac39c57c50af61d5c32cd18ea48e52d81d6c3c16 Mon Sep 17 00:00:00 2001 From: Claudemirovsky <63046606+Claudemirovsky@users.noreply.github.com> Date: Mon, 13 Nov 2023 13:37:20 -0300 Subject: [PATCH] fix(en/hahomoe): Fix episode list in some entries (#2507) --- src/en/hahomoe/build.gradle | 2 +- .../tachiyomi/animeextension/en/hahomoe/HahoMoe.kt | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/en/hahomoe/build.gradle b/src/en/hahomoe/build.gradle index 8c0bad2775..e055ec1844 100644 --- a/src/en/hahomoe/build.gradle +++ b/src/en/hahomoe/build.gradle @@ -7,7 +7,7 @@ ext { extName = 'haho.moe' pkgNameSuffix = 'en.hahomoe' extClass = '.HahoMoe' - extVersionCode = 9 + extVersionCode = 10 libVersion = '13' containsNsfw = true } diff --git a/src/en/hahomoe/src/eu/kanade/tachiyomi/animeextension/en/hahomoe/HahoMoe.kt b/src/en/hahomoe/src/eu/kanade/tachiyomi/animeextension/en/hahomoe/HahoMoe.kt index fa816c8423..5e1ff42639 100644 --- a/src/en/hahomoe/src/eu/kanade/tachiyomi/animeextension/en/hahomoe/HahoMoe.kt +++ b/src/en/hahomoe/src/eu/kanade/tachiyomi/animeextension/en/hahomoe/HahoMoe.kt @@ -99,7 +99,7 @@ class HahoMoe : ConfigurableAnimeSource, ParsedAnimeHttpSource() { setUrlWithoutDomain(document.location()) thumbnail_url = document.selectFirst("img.cover-image.img-thumbnail")?.absUrl("src") title = document.selectFirst("li.breadcrumb-item.active")!!.text() - genre = document.select("li.genre span.value").joinToString { it.text() } + genre = document.select("li.genre span.value, div.genre-tree ul > li > a").joinToString { it.text() } description = document.selectFirst("div.card-body")?.text() author = document.select("li.production span.value").joinToString { it.text() } artist = document.selectFirst("li.group span.value")?.text() @@ -115,7 +115,7 @@ class HahoMoe : ConfigurableAnimeSource, ParsedAnimeHttpSource() { } // ============================== Episodes ============================== - override fun episodeListSelector() = "ul.episode-loop li a" + override fun episodeListSelector() = "ul.episode-loop > li > a" private fun episodeNextPageSelector() = popularAnimeNextPageSelector() @@ -132,15 +132,21 @@ class HahoMoe : ConfigurableAnimeSource, ParsedAnimeHttpSource() { .map(::episodeFromElement) .also(::addAll) } while (doc.selectFirst(episodeNextPageSelector()) != null) + + sortByDescending { it.episode_number } } } override fun episodeFromElement(element: Element) = SEpisode.create().apply { setUrlWithoutDomain(element.attr("href")) - val episodeNumberString = element.selectFirst("div.episode-number")!!.text() + val episodeNumberString = element.selectFirst("div.episode-number, div.episode-slug")?.text() ?: "Episode" episode_number = episodeNumberString.removePrefix("Episode ").toFloatOrNull() ?: 1F - name = "$episodeNumberString: " + element.selectFirst("div.episode-label")?.text().orEmpty() + val title = element.selectFirst("div.episode-label, div.episode-title")?.text() + ?.takeUnless { it.equals("No Title", true) } + ?.let { ": $it" } + .orEmpty() + name = episodeNumberString + title date_upload = element.selectFirst("div.date")?.text().orEmpty().toDate() }