From fda81d15be0ac687587ddd60fbc5ef1d97547db0 Mon Sep 17 00:00:00 2001 From: Dark25 Date: Wed, 8 Jan 2025 22:52:29 +0100 Subject: [PATCH] fix(pt/anitube): Fixed source (#181) --- src/pt/anitube/build.gradle | 2 +- .../pt/anitube/extractors/AnitubeExtractor.kt | 27 +++++++++++++------ 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/pt/anitube/build.gradle b/src/pt/anitube/build.gradle index a468f926da..519039b01d 100644 --- a/src/pt/anitube/build.gradle +++ b/src/pt/anitube/build.gradle @@ -1,7 +1,7 @@ ext { extName = 'Anitube' extClass = '.Anitube' - extVersionCode = 19 + extVersionCode = 20 } apply from: "$rootDir/common.gradle" diff --git a/src/pt/anitube/src/eu/kanade/tachiyomi/animeextension/pt/anitube/extractors/AnitubeExtractor.kt b/src/pt/anitube/src/eu/kanade/tachiyomi/animeextension/pt/anitube/extractors/AnitubeExtractor.kt index 6c96aad91a..25276c01e2 100644 --- a/src/pt/anitube/src/eu/kanade/tachiyomi/animeextension/pt/anitube/extractors/AnitubeExtractor.kt +++ b/src/pt/anitube/src/eu/kanade/tachiyomi/animeextension/pt/anitube/extractors/AnitubeExtractor.kt @@ -6,7 +6,7 @@ import eu.kanade.tachiyomi.animesource.model.Video import eu.kanade.tachiyomi.network.GET import eu.kanade.tachiyomi.network.POST import eu.kanade.tachiyomi.util.asJsoup -import eu.kanade.tachiyomi.util.parallelMapNotNullBlocking +import eu.kanade.tachiyomi.util.parallelCatchingFlatMapBlocking import okhttp3.FormBody import okhttp3.Headers import okhttp3.HttpUrl.Companion.toHttpUrl @@ -77,6 +77,17 @@ class AnitubeExtractor( return getAdsUrl(serverUrl, thumbUrl, newLink, newHeaders) } + if (docLink.data().contains("window.location.href = redirectUrl")) { + val newLink = docLink.data() + .substringAfter("redirectUrl = `") + .substringBefore("`") + .replace("\${token}", finalLink.toHttpUrl().queryParameter("t") ?: "") + val newHeaders = linkHeaders.newBuilder().set("Referer", finalLink).build() + Log.d(tag, "Following javascript redirection to $newLink") + + return getAdsUrl(serverUrl, thumbUrl, newLink, newHeaders) + } + val referer: String = docLink.location() ?: link Log.d(tag, "Final URL: $referer") @@ -112,7 +123,7 @@ class AnitubeExtractor( // Try default url Log.e(tag, "Failed to get the ADS URL, trying the default") - return "https://www.popads.net/js/adblock.js" + return "https://s4.cdnpc.net/vite-bundle/main.css?version=v93" } private fun getAuthCode(serverUrl: String, thumbUrl: String, link: String): String { @@ -154,7 +165,7 @@ class AnitubeExtractor( .build() val publicidade = - client.newCall(POST("$ADS_URL/", headers = newHeaders, body = body)) + client.newCall(POST(ADS_URL, headers = newHeaders, body = body)) .execute() .body.string() .substringAfter("\"publicidade\"") @@ -173,7 +184,7 @@ class AnitubeExtractor( authCode = client.newCall( GET( - "$ADS_URL/?token=$publicidade", + "$ADS_URL?token=$publicidade", headers = newHeaders, ), ) @@ -226,19 +237,19 @@ class AnitubeExtractor( var quality = "$quality - Anitube" } } - .parallelMapNotNullBlocking { + .parallelCatchingFlatMapBlocking { if (!checkVideoExists(it.url).exists) { Log.d(tag, "Video not exists: ${it.url.substringBefore("?")}") - return@parallelMapNotNullBlocking null + return@parallelCatchingFlatMapBlocking emptyList() } - Video(it.url, it.quality, it.url, headers = headers) + listOf(Video(it.url, it.quality, it.url, headers = headers)) } .reversed() } companion object { private const val PREF_AUTHCODE_KEY = "authcode" - private const val ADS_URL = "https://ads.anitube.vip" + private const val ADS_URL = "https://ads.anitube.vip/adblock.php" private const val SITE_URL = "https://www.anitube.vip/playerricas.php" } }