Skip to content

Commit

Permalink
fix(pt/anitube): Fixed source (#181)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dark25 authored Jan 8, 2025
1 parent 3cf964b commit fda81d1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/pt/anitube/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ext {
extName = 'Anitube'
extClass = '.Anitube'
extVersionCode = 19
extVersionCode = 20
}

apply from: "$rootDir/common.gradle"
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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\"")
Expand All @@ -173,7 +184,7 @@ class AnitubeExtractor(
authCode =
client.newCall(
GET(
"$ADS_URL/?token=$publicidade",
"$ADS_URL?token=$publicidade",
headers = newHeaders,
),
)
Expand Down Expand Up @@ -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"
}
}

0 comments on commit fda81d1

Please sign in to comment.