mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
decrypt gogoanime links to skip the download redirect
This commit is contained in:
parent
5a020ab202
commit
660f07ff57
1 changed files with 34 additions and 9 deletions
|
@ -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<ExtractorLink> {
|
private fun extractVideos(uri: String): List<ExtractorLink> {
|
||||||
val html = get(uri).text
|
val html = get(uri).text
|
||||||
val doc = Jsoup.parse(html)
|
val doc = Jsoup.parse(html)
|
||||||
|
@ -212,36 +234,39 @@ class GogoanimeProvider : MainAPI() {
|
||||||
val iframe = "https:" + doc.selectFirst("div.play-video > iframe").attr("src")
|
val iframe = "https:" + doc.selectFirst("div.play-video > iframe").attr("src")
|
||||||
val link = iframe.replace("streaming.php", "download")
|
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)
|
val pageDoc = Jsoup.parse(page.text)
|
||||||
|
|
||||||
return pageDoc.select(".dowload > a").pmap {
|
val qualities = ArrayList<ExtractorLink>()
|
||||||
|
|
||||||
|
pageDoc.select(".dowload > a").pmap {
|
||||||
if (it.hasAttr("download")) {
|
if (it.hasAttr("download")) {
|
||||||
val qual = if (it.text()
|
val qual = if (it.text()
|
||||||
.contains("HDP")
|
.contains("HDP")
|
||||||
) "1080" else qualityRegex.find(it.text())?.destructured?.component1().toString()
|
) "1080" else qualityRegex.find(it.text())?.destructured?.component1().toString()
|
||||||
listOf(
|
qualities.add(
|
||||||
ExtractorLink(
|
ExtractorLink(
|
||||||
"Gogoanime",
|
"Gogoanime",
|
||||||
if (qual == "null") "Gogoanime" else "Gogoanime - " + qual + "p",
|
if (qual == "null") "Gogoanime" else "Gogoanime - " + qual + "p",
|
||||||
it.attr("href"),
|
decryptRedirect(it.attr("href")),
|
||||||
page.url,
|
page.url,
|
||||||
getQualityFromName(qual),
|
getQualityFromName(qual),
|
||||||
it.attr("href").contains(".m3u8")
|
it.attr("href").contains(".m3u8"),
|
||||||
|
mapOf("Referer" to it.attr("href"))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
val url = it.attr("href")
|
val url = it.attr("href")
|
||||||
val extractorLinks = ArrayList<ExtractorLink>()
|
|
||||||
for (api in extractorApis) {
|
for (api in extractorApis) {
|
||||||
if (url.startsWith(api.mainUrl)) {
|
if (url.startsWith(api.mainUrl)) {
|
||||||
extractorLinks.addAll(api.getSafeUrl(url) ?: listOf())
|
qualities.addAll(api.getSafeUrl(url) ?: listOf())
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
extractorLinks
|
|
||||||
}
|
}
|
||||||
}.flatten()
|
}
|
||||||
|
println("GOGO: ${qualities.size}, $qualities")
|
||||||
|
return qualities
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun loadLinks(
|
override fun loadLinks(
|
||||||
|
|
Loading…
Reference in a new issue