Skip to content

Commit

Permalink
Merge pull request #58 from Dark25/AnimesGames
Browse files Browse the repository at this point in the history
Fix(pt/AnimesGames): update image
  • Loading branch information
Dark25 authored Aug 31, 2024
2 parents 509bae3 + ae74036 commit d3b2a33
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/pt/animesgames/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ext {
extName = 'Animes Games'
extClass = '.AnimesGames'
extVersionCode = 4
extVersionCode = 5
}

apply from: "$rootDir/common.gradle"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class AnimesGames : ParsedAnimeHttpSource() {
override fun latestUpdatesFromElement(element: Element) = SAnime.create().apply {
setUrlWithoutDomain(element.attr("href"))
title = element.selectFirst("div.tituloEP")!!.text()
thumbnail_url = element.selectFirst("img")?.attr("data-lazy-src")
thumbnail_url = element.selectFirst("img")?.getImageUrl()
}

override fun latestUpdatesNextPageSelector() = "ol.pagination > a:contains(>)"
Expand Down Expand Up @@ -144,7 +144,7 @@ class AnimesGames : ParsedAnimeHttpSource() {
override fun searchAnimeFromElement(element: Element) = SAnime.create().apply {
setUrlWithoutDomain(element.attr("href"))
title = element.selectFirst("div.tituloAnime")!!.text()
thumbnail_url = element.selectFirst("img")!!.attr("src")
thumbnail_url = element.selectFirst("img")!!.getImageUrl()
}

override fun searchAnimeNextPageSelector(): String? {
Expand All @@ -159,7 +159,7 @@ class AnimesGames : ParsedAnimeHttpSource() {
title = content.selectFirst("section > h1")!!.text()
.removePrefix("Assistir ")
.removeSuffix("Temporada Online")
thumbnail_url = content.selectFirst("img")?.attr("data-lazy-src")
thumbnail_url = content.selectFirst("img")?.getImageUrl()
description = content.select("section.sinopseEp p").eachText().joinToString("\n")

val infos = content.selectFirst("div.info > ol")!!
Expand Down Expand Up @@ -201,8 +201,8 @@ class AnimesGames : ParsedAnimeHttpSource() {
private val bloggerExtractor by lazy { BloggerExtractor(client) }
override fun videoListParse(response: Response): List<Video> {
val doc = response.asJsoup()
val url = doc.selectFirst("div#player iframe")
?.attr("src")
val url = doc.selectFirst("div.Link > a")
?.attr("href")
?: return emptyList()

val playerDoc = client.newCall(GET(url, headers)).execute()
Expand Down Expand Up @@ -273,6 +273,19 @@ class AnimesGames : ParsedAnimeHttpSource() {
.getOrNull() ?: 0L
}

/**
* Tries to get the image url via various possible attributes.
* Taken from Tachiyomi's Madara multisrc.
*/
protected open fun Element.getImageUrl(): String? {
return when {
hasAttr("data-src") -> attr("abs:data-src")
hasAttr("data-lazy-src") -> attr("abs:data-lazy-src")
hasAttr("srcset") -> attr("abs:srcset").substringBefore(" ")
else -> attr("abs:src")
}.substringBefore("?resize")
}

companion object {
const val PREFIX_SEARCH = "id:"

Expand Down

0 comments on commit d3b2a33

Please sign in to comment.