Skip to content

Commit

Permalink
fix(pt/animeplayer): Fix popular anime, anime details and episode lis…
Browse files Browse the repository at this point in the history
…t pages (#3271)
  • Loading branch information
Claudemirovsky authored May 28, 2024
1 parent c3f60e0 commit 69e1f18
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/pt/animeplayer/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ ext {
extClass = '.AnimePlayer'
themePkg = 'dooplay'
baseUrl = 'https://animeplayer.com.br'
overrideVersionCode = 2
overrideVersionCode = 3
isNsfw = true
}

apply from: "$rootDir/common.gradle"

dependencies {
implementation(project(":lib:blogger-extractor"))
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
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
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",
Expand All @@ -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<SEpisode> {
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<SEpisode> {
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")
Expand All @@ -33,7 +96,7 @@ class AnimePlayer : DooPlay(
override fun videoListParse(response: Response): List<Video> {
val playerUrl = response.asJsoup()
.selectFirst("div.playex iframe")
?.attr("abs:src")
?.absUrl("src")
?.toHttpUrlOrNull()
?: return emptyList()

Expand All @@ -43,4 +106,7 @@ class AnimePlayer : DooPlay(

// ============================== Filters ===============================
override fun genresListSelector() = "ul.genres a"

// ============================= Utilities ==============================
override val animeMenuSelector = "div.pag_episodes div.item a[href] i.icon-bars"
}

0 comments on commit 69e1f18

Please sign in to comment.