From 660f07ff57642ca6c87bd0854baa974dade5bab8 Mon Sep 17 00:00:00 2001 From: ArjixWasTaken <53124886+ArjixWasTaken@users.noreply.github.com> Date: Sun, 24 Oct 2021 19:52:35 +0300 Subject: [PATCH] decrypt gogoanime links to skip the download redirect --- .../animeproviders/GogoanimeProvider.kt | 43 +++++++++++++++---- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/GogoanimeProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/GogoanimeProvider.kt index 2f14b8dd..403c06d5 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/GogoanimeProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/GogoanimeProvider.kt @@ -205,6 +205,28 @@ class GogoanimeProvider : MainAPI() { ) } + private val garbages = listOf( + "URASDGHUSRFSJGYfdsffsderFStewthsfSFtrfte", + "AdeqwrwedffryretgsdFrsftrsvfsfsr", + "werFrefdsfrersfdsrfer36343534", + "AawehyfcghysfdsDGDYdgdsf", + "wstdgdsgtert", + "Adrefsd", + "sdf" + ) + + private fun decryptRedirect(uri: String): String { + val isGogoCdn = Regex("""download\.php\?url=([^?&/]+)""").find(uri) + if (isGogoCdn?.destructured == null) return uri + + var encryptedUrl = isGogoCdn.destructured.component1() + garbages.forEach { + encryptedUrl = encryptedUrl.replace(it, "") + } + + return base64Decode(encryptedUrl + "=".repeat(encryptedUrl.length % 4)) + } + private fun extractVideos(uri: String): List { val html = get(uri).text val doc = Jsoup.parse(html) @@ -212,36 +234,39 @@ class GogoanimeProvider : MainAPI() { val iframe = "https:" + doc.selectFirst("div.play-video > iframe").attr("src") val link = iframe.replace("streaming.php", "download") - val page = get(link, headers = mapOf("Referer" to iframe)) + val page = get(link, referer=iframe, cacheTime = 0) val pageDoc = Jsoup.parse(page.text) - return pageDoc.select(".dowload > a").pmap { + val qualities = ArrayList() + + pageDoc.select(".dowload > a").pmap { if (it.hasAttr("download")) { val qual = if (it.text() .contains("HDP") ) "1080" else qualityRegex.find(it.text())?.destructured?.component1().toString() - listOf( + qualities.add( ExtractorLink( "Gogoanime", if (qual == "null") "Gogoanime" else "Gogoanime - " + qual + "p", - it.attr("href"), + decryptRedirect(it.attr("href")), page.url, getQualityFromName(qual), - it.attr("href").contains(".m3u8") + it.attr("href").contains(".m3u8"), + mapOf("Referer" to it.attr("href")) ) ) } else { val url = it.attr("href") - val extractorLinks = ArrayList() for (api in extractorApis) { if (url.startsWith(api.mainUrl)) { - extractorLinks.addAll(api.getSafeUrl(url) ?: listOf()) + qualities.addAll(api.getSafeUrl(url) ?: listOf()) break } } - extractorLinks } - }.flatten() + } + println("GOGO: ${qualities.size}, $qualities") + return qualities } override fun loadLinks(