-
Notifications
You must be signed in to change notification settings - Fork 260
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(pt/vizer): Update baseUrl, fix episode list, add WarezCDN extract…
…or (#3036)
- Loading branch information
1 parent
d6da1c9
commit b85bc9a
Showing
4 changed files
with
125 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
src/pt/vizer/src/eu/kanade/tachiyomi/animeextension/pt/vizer/extractors/WarezExtractor.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package eu.kanade.tachiyomi.animeextension.pt.vizer.extractors | ||
|
||
import android.util.Base64 | ||
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 okhttp3.FormBody | ||
import okhttp3.Headers | ||
import okhttp3.HttpUrl.Companion.toHttpUrl | ||
import okhttp3.OkHttpClient | ||
|
||
class WarezExtractor(private val client: OkHttpClient, private val headers: Headers) { | ||
|
||
fun videosFromUrl(url: String, lang: String): List<Video> { | ||
val doc = client.newCall(GET(url, headers)).execute().asJsoup() | ||
val httpUrl = doc.location().toHttpUrl() | ||
val videoId = httpUrl.queryParameter("id") ?: return emptyList() | ||
val script = doc.selectFirst("script:containsData(allowanceKey)")?.data() | ||
?: return emptyList() | ||
val key = script.substringAfter("allowanceKey").substringAfter('"').substringBefore('"') | ||
val cdn = script.substringAfter("cdnListing").substringAfter('[').substringBefore(']') | ||
.split(',') | ||
.random() | ||
|
||
val body = FormBody.Builder() | ||
.add("getVideo", videoId) | ||
.add("key", key) | ||
.build() | ||
|
||
val host = "https://" + httpUrl.host | ||
val reqHeaders = headers.newBuilder() | ||
.set("Origin", host) | ||
.set("Referer", url) | ||
.set("X-Requested-With", "XMLHttpRequest") | ||
.build() | ||
|
||
val req = client.newCall(POST("$host/player/functions.php", reqHeaders, body)).execute() | ||
val id = req.body.string().substringAfter("id\":\"", "").substringBefore('"', "") | ||
.ifBlank { return emptyList() } | ||
val decrypted = decryptorium(id) | ||
val videoUrl = "https://workerproxy.warezcdn.workers.dev/?url=https://cloclo$cdn.cloud.mail.ru/weblink/view/$decrypted" | ||
return listOf(Video(videoUrl, "WarezCDN - $lang", videoUrl, headers)) | ||
} | ||
|
||
private fun decryptorium(enc: String): String { | ||
val b64dec = String(Base64.decode(enc, Base64.DEFAULT)).trim() | ||
val start = b64dec.reversed().dropLast(5) | ||
val end = b64dec.substring(0, 5) | ||
return start + end | ||
} | ||
} |