From 69e1f1870432afc0e0c7dfa7e8c95066805c1cb4 Mon Sep 17 00:00:00 2001 From: Claudemirovsky <63046606+Claudemirovsky@users.noreply.github.com> Date: Tue, 28 May 2024 10:15:15 +0000 Subject: [PATCH] fix(pt/animeplayer): Fix popular anime, anime details and episode list pages (#3271) --- src/pt/animeplayer/build.gradle | 4 +- .../pt/animeplayer/AnimePlayer.kt | 72 ++++++++++++++++++- 2 files changed, 71 insertions(+), 5 deletions(-) diff --git a/src/pt/animeplayer/build.gradle b/src/pt/animeplayer/build.gradle index bc9e7d377c..092e328b0c 100644 --- a/src/pt/animeplayer/build.gradle +++ b/src/pt/animeplayer/build.gradle @@ -3,7 +3,7 @@ ext { extClass = '.AnimePlayer' themePkg = 'dooplay' baseUrl = 'https://animeplayer.com.br' - overrideVersionCode = 2 + overrideVersionCode = 3 isNsfw = true } @@ -11,4 +11,4 @@ apply from: "$rootDir/common.gradle" dependencies { implementation(project(":lib:blogger-extractor")) -} \ No newline at end of file +} diff --git a/src/pt/animeplayer/src/eu/kanade/tachiyomi/animeextension/pt/animeplayer/AnimePlayer.kt b/src/pt/animeplayer/src/eu/kanade/tachiyomi/animeextension/pt/animeplayer/AnimePlayer.kt index ad215f553c..9abfe09714 100644 --- a/src/pt/animeplayer/src/eu/kanade/tachiyomi/animeextension/pt/animeplayer/AnimePlayer.kt +++ b/src/pt/animeplayer/src/eu/kanade/tachiyomi/animeextension/pt/animeplayer/AnimePlayer.kt @@ -1,5 +1,7 @@ package eu.kanade.tachiyomi.animeextension.pt.animeplayer +import eu.kanade.tachiyomi.animesource.model.SAnime +import eu.kanade.tachiyomi.animesource.model.SEpisode import eu.kanade.tachiyomi.animesource.model.Video import eu.kanade.tachiyomi.lib.bloggerextractor.BloggerExtractor import eu.kanade.tachiyomi.multisrc.dooplay.DooPlay @@ -7,6 +9,8 @@ import eu.kanade.tachiyomi.network.GET import eu.kanade.tachiyomi.util.asJsoup import okhttp3.HttpUrl.Companion.toHttpUrlOrNull import okhttp3.Response +import org.jsoup.nodes.Document +import org.jsoup.nodes.Element class AnimePlayer : DooPlay( "pt-BR", @@ -15,14 +19,73 @@ class AnimePlayer : DooPlay( ) { // ============================== Popular =============================== - override fun popularAnimeSelector() = "div#featured-titles article div.poster" + override fun popularAnimeSelector() = "div#archive-content article div.poster" override fun popularAnimeRequest(page: Int) = GET("$baseUrl/animes/") + override fun popularAnimeNextPageSelector() = "a > i#nextpagination" + // =============================== Latest =============================== override val latestUpdatesPath = "episodios" - override fun latestUpdatesNextPageSelector() = "a > i#nextpagination" + override fun latestUpdatesNextPageSelector() = popularAnimeNextPageSelector() + + // =========================== Anime Details ============================ + override fun animeDetailsParse(document: Document) = SAnime.create().apply { + val doc = getRealAnimeDoc(document) + val content = doc.selectFirst("div#contenedor > div.data")!! + doc.selectFirst("div.sheader div.poster > img")!!.let { + thumbnail_url = it.getImageUrl() + title = it.attr("alt").ifEmpty { + content.selectFirst("div.data > h1")!!.text() + } + } + + genre = content.select("div.sgeneros > a") + .eachText() + .joinToString() + } + + // ============================== Episodes ============================== + override fun episodeListParse(response: Response): List { + val doc = getRealAnimeDoc(response.asJsoup()) + val seasonList = doc.select(seasonListSelector) + return if (seasonList.size < 1) { + SEpisode.create().apply { + setUrlWithoutDomain(doc.location()) + episode_number = 1F + name = episodeMovieText + }.let(::listOf) + } else { + seasonList.flatMap(::getSeasonEpisodes) + } + } + + override fun getSeasonEpisodes(season: Element): List { + val seasonName = season.selectFirst("span.title")!!.text() + return season.select(episodeListSelector()).mapNotNull { element -> + try { + episodeFromElement(element, seasonName) + } catch (e: Throwable) { + e.printStackTrace() + null + } + } + } + + override fun episodeFromElement(element: Element): SEpisode = throw UnsupportedOperationException() + + override fun episodeFromElement(element: Element, seasonName: String) = SEpisode.create().apply { + val epNum = element.selectFirst("div.episodiotitle p")!!.text() + .trim() + .let(episodeNumberRegex::find) + ?.groupValues + ?.last() ?: "0" + val href = element.selectFirst("a[href]")!! + episode_number = epNum.toFloatOrNull() ?: 0F + name = "$seasonName x Episódio $epNum" + setUrlWithoutDomain(href.absUrl("href")) + } // ============================ Video Links ============================= override val prefQualityValues = arrayOf("360p", "720p") @@ -33,7 +96,7 @@ class AnimePlayer : DooPlay( override fun videoListParse(response: Response): List