fix(pt/anitube): Fixed pt/Anitube source (fix #695) #697

Merged
WebDitto merged 1 commit from fix/pt/anitube_695 into main 2025-02-20 18:36:13 -06:00
2 changed files with 12 additions and 5 deletions

View file

@ -1,7 +1,7 @@
ext {
extName = 'Anitube'
extClass = '.Anitube'
extVersionCode = 22
extVersionCode = 23
}
apply from: "$rootDir/common.gradle"

View file

@ -30,10 +30,14 @@ class AnitubeExtractor(
private fun checkVideoExists(url: String): VideoExists {
try {
val newHeaders = headers.newBuilder()
.set("Connection", "close")
.build()
val request = Request.Builder()
.head()
.url(url)
.headers(headers)
.headers(newHeaders)
.build()
val response = client.newCall(request).execute()
@ -44,6 +48,8 @@ class AnitubeExtractor(
if (e.message?.contains("Unexpected status line") == true) {
return VideoExists(true, 200)
}
} catch (e: Exception) {
Log.d(tag, "Failed to check video, error: ${e.message}")
}
return VideoExists(false, 404)
@ -108,7 +114,7 @@ class AnitubeExtractor(
.body.string()
val adsUrl = body.let {
Regex("""urlToFetch\s*=\s*['"]([^'"]+)['"]""")
Regex("""(?:urlToFetch|ADS_URL)\s*=\s*['"]([^'"]+)['"]""")
.find(it)?.groups?.get(1)?.value
?: ""
}
@ -123,7 +129,7 @@ class AnitubeExtractor(
// Try default url
Log.e(tag, "Failed to get the ADS URL, trying the default")
return "https://s4.cdnpc.net/vite-bundle/main.css?version=v93"
return "https://widgets.outbrain.com/outbrain.js"
}
private fun getAuthCode(serverUrl: String, thumbUrl: String, link: String): String {
@ -212,6 +218,7 @@ class AnitubeExtractor(
val serverUrl = doc.selectFirst("meta[itemprop=contentURL]")!!
.attr("content")
.replace("cdn1", "cdn3")
.replace("cdn80", "cdn8")
val thumbUrl = doc.selectFirst("meta[itemprop=thumbnailUrl]")!!
.attr("content")
val type = serverUrl.split("/").get(3)
@ -249,7 +256,7 @@ class AnitubeExtractor(
companion object {
private const val PREF_AUTHCODE_KEY = "authcode"
private const val ADS_URL = "https://ads.anitube.vip/adblock.php"
private const val ADS_URL = "https://ads.anitube.vip/adblockturbo.php"
private const val SITE_URL = "https://www.anitube.vip/playerricas.php"
}
}