diff --git a/src/pt/otakuanimes/build.gradle b/src/pt/otakuanimes/build.gradle index cba7bfa460..6420730f09 100644 --- a/src/pt/otakuanimes/build.gradle +++ b/src/pt/otakuanimes/build.gradle @@ -1,7 +1,7 @@ ext { extName = 'OtakuAnimes' extClass = '.OtakuAnimes' - extVersionCode = 1 + extVersionCode = 2 isNsfw = true } diff --git a/src/pt/otakuanimes/src/eu/kanade/tachiyomi/animeextension/pt/otakuanimes/OtakuAnimes.kt b/src/pt/otakuanimes/src/eu/kanade/tachiyomi/animeextension/pt/otakuanimes/OtakuAnimes.kt index cd5b6ca7ed..cde366c756 100644 --- a/src/pt/otakuanimes/src/eu/kanade/tachiyomi/animeextension/pt/otakuanimes/OtakuAnimes.kt +++ b/src/pt/otakuanimes/src/eu/kanade/tachiyomi/animeextension/pt/otakuanimes/OtakuAnimes.kt @@ -49,7 +49,7 @@ class OtakuAnimes : ConfigurableAnimeSource, ParsedAnimeHttpSource() { override fun popularAnimeFromElement(element: Element) = SAnime.create().apply { setUrlWithoutDomain(element.attr("href")) title = element.selectFirst("div.aniNome")!!.text().trim() - thumbnail_url = element.selectFirst("img")?.attr("data-lazy-src") + thumbnail_url = element.selectFirst("img")?.getImageUrl() } override fun popularAnimeNextPageSelector() = null @@ -111,7 +111,7 @@ class OtakuAnimes : ConfigurableAnimeSource, ParsedAnimeHttpSource() { return SAnime.create().apply { setUrlWithoutDomain(doc.location()) title = doc.selectFirst("div.animeFirstContainer h1")!!.text() - thumbnail_url = doc.selectFirst("div.animeCapa img")?.attr("data-lazy-src") + thumbnail_url = doc.selectFirst("div.animeCapa img")?.getImageUrl() description = doc.selectFirst("div.animeSecondContainer > p")?.text() genre = doc.select("ul.animeGen li").eachText()?.joinToString(", ") } @@ -222,6 +222,19 @@ class OtakuAnimes : ConfigurableAnimeSource, ParsedAnimeHttpSource() { return document } + /** + * 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 = "path:" private val REGEX_QUALITY by lazy { Regex("""(\d+)p""") }