mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
applied the requested changes
This commit is contained in:
parent
2ae5f4963f
commit
d490f4073b
1 changed files with 24 additions and 15 deletions
|
@ -5,6 +5,8 @@ import khttp.structures.cookie.CookieJar
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty
|
import com.fasterxml.jackson.annotation.JsonProperty
|
||||||
import com.fasterxml.jackson.module.kotlin.readValue
|
import com.fasterxml.jackson.module.kotlin.readValue
|
||||||
import com.lagradost.cloudstream3.utils.ExtractorLink
|
import com.lagradost.cloudstream3.utils.ExtractorLink
|
||||||
|
import com.lagradost.cloudstream3.mvvm.normalSafeApiCall
|
||||||
|
import com.lagradost.cloudstream3.utils.getQualityFromName
|
||||||
import org.jsoup.Jsoup
|
import org.jsoup.Jsoup
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import kotlin.collections.ArrayList
|
import kotlin.collections.ArrayList
|
||||||
|
@ -30,10 +32,10 @@ class AnimePaheProvider : MainAPI() {
|
||||||
}
|
}
|
||||||
val YTSM = "ysmm = '([^']+)".toRegex()
|
val YTSM = "ysmm = '([^']+)".toRegex()
|
||||||
|
|
||||||
val KWIK_PARAMS_RE = """\(\"(\w+)\",\d+,\"(\w+)\",(\d+),(\d+),\d+\)""".toRegex()
|
val KWIK_PARAMS_RE = Regex("""\(\"(\w+)\",\d+,\"(\w+)\",(\d+),(\d+),\d+\)""")
|
||||||
val KWIK_D_URL = "action=\"([^\"]+)\"".toRegex()
|
val KWIK_D_URL = Regex("action=\"([^\"]+)\"")
|
||||||
val KWIK_D_TOKEN = "value=\"([^\"]+)\"".toRegex()
|
val KWIK_D_TOKEN = Regex("value=\"([^\"]+)\"")
|
||||||
val YOUTUBE_VIDEO_LINK = """(^(?:https?:)?(?:\/\/)?(?:www\.)?(?:youtu\.be\/|youtube(?:\-nocookie)?\.(?:[A-Za-z]{2,4}|[A-Za-z]{2,3}\.[A-Za-z]{2})\/)(?:watch|embed\/|vi?\/)*(?:\?[\w=&]*vi?=)?[^#&\?\/]{11}.*${'$'})""".toRegex()
|
val YOUTUBE_VIDEO_LINK = Regex("""(^(?:https?:)?(?:\/\/)?(?:www\.)?(?:youtu\.be\/|youtube(?:\-nocookie)?\.(?:[A-Za-z]{2,4}|[A-Za-z]{2,3}\.[A-Za-z]{2})\/)(?:watch|embed\/|vi?\/)*(?:\?[\w=&]*vi?=)?[^#&\?\/]{11}.*${'$'})""")
|
||||||
}
|
}
|
||||||
|
|
||||||
override val mainUrl: String
|
override val mainUrl: String
|
||||||
|
@ -224,8 +226,8 @@ class AnimePaheProvider : MainAPI() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun load(url: String): LoadResponse {
|
override fun load(url: String): LoadResponse? {
|
||||||
try {
|
return normalSafeApiCall {
|
||||||
val html = khttp.get(url).text
|
val html = khttp.get(url).text
|
||||||
val doc = Jsoup.parse(html)
|
val doc = Jsoup.parse(html)
|
||||||
|
|
||||||
|
@ -240,6 +242,7 @@ class AnimePaheProvider : MainAPI() {
|
||||||
} else {
|
} else {
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
|
||||||
val episodes = generateListOfEpisodes(url) ?: ArrayList<AnimeEpisode>()
|
val episodes = generateListOfEpisodes(url) ?: ArrayList<AnimeEpisode>()
|
||||||
val year = """<strong>Aired:<\/strong>[^,]*, (\d+)""".toRegex().find(html)!!.destructured?.component1()?.toIntOrNull()
|
val year = """<strong>Aired:<\/strong>[^,]*, (\d+)""".toRegex().find(html)!!.destructured?.component1()?.toIntOrNull()
|
||||||
val status = when ("""<strong>Status:<\/strong>[^a]*a href=[\"']\/anime\/(.*?)[\"']""".toRegex().find(html)!!.destructured?.component1().toString()) {
|
val status = when ("""<strong>Status:<\/strong>[^a]*a href=[\"']\/anime\/(.*?)[\"']""".toRegex().find(html)!!.destructured?.component1().toString()) {
|
||||||
|
@ -262,7 +265,7 @@ class AnimePaheProvider : MainAPI() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return AnimeLoadResponse(
|
AnimeLoadResponse(
|
||||||
title,
|
title,
|
||||||
japTitle,
|
japTitle,
|
||||||
title.toString(),
|
title.toString(),
|
||||||
|
@ -284,10 +287,6 @@ class AnimePaheProvider : MainAPI() {
|
||||||
null,
|
null,
|
||||||
trailer
|
trailer
|
||||||
)
|
)
|
||||||
} catch (e: Exception) {
|
|
||||||
println("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")
|
|
||||||
e.printStackTrace()
|
|
||||||
throw e
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -330,7 +329,7 @@ class AnimePaheProvider : MainAPI() {
|
||||||
acc += (when(isNumber("$i")) {
|
acc += (when(isNumber("$i")) {
|
||||||
true -> "$i".toLong()
|
true -> "$i".toLong()
|
||||||
false -> "0".toLong()
|
false -> "0".toLong()
|
||||||
}) * pow(s1, n)
|
}) * Math.pow(s1.toDouble(), n.toDouble()).toInt()
|
||||||
}
|
}
|
||||||
|
|
||||||
var k = ""
|
var k = ""
|
||||||
|
@ -432,11 +431,16 @@ class AnimePaheProvider : MainAPI() {
|
||||||
|
|
||||||
var responseCode = 302
|
var responseCode = 302
|
||||||
var adflyContent: khttp.responses.Response? = null
|
var adflyContent: khttp.responses.Response? = null
|
||||||
|
var tries = 0
|
||||||
|
|
||||||
while (responseCode != 200) {
|
while (responseCode != 200 && tries < 20) {
|
||||||
adflyContent = khttp.get(khttp.get(adflyUri, cookies=cookies, allowRedirects = false).headers.getValue("location"), cookies=cookies, allowRedirects = false)
|
adflyContent = khttp.get(khttp.get(adflyUri, cookies=cookies, allowRedirects = false).headers.getValue("location"), cookies=cookies, allowRedirects = false)
|
||||||
cookies.putAll(adflyContent.cookies.toMap())
|
cookies.putAll(adflyContent.cookies.toMap())
|
||||||
responseCode = adflyContent.statusCode
|
responseCode = adflyContent.statusCode
|
||||||
|
++tries
|
||||||
|
}
|
||||||
|
if (tries > 19) {
|
||||||
|
throw Exception("Failed to bypass adfly.")
|
||||||
}
|
}
|
||||||
return decodeAdfly(YTSM.find(adflyContent?.text.toString())!!.destructured.component1())
|
return decodeAdfly(YTSM.find(adflyContent?.text.toString())!!.destructured.component1())
|
||||||
}
|
}
|
||||||
|
@ -452,8 +456,9 @@ class AnimePaheProvider : MainAPI() {
|
||||||
var content: khttp.responses.Response? = null
|
var content: khttp.responses.Response? = null
|
||||||
|
|
||||||
var code = 419
|
var code = 419
|
||||||
|
var tries = 0
|
||||||
|
|
||||||
while (code != 302) {
|
while (code != 302 && tries < 20) {
|
||||||
content = khttp.post(
|
content = khttp.post(
|
||||||
uri,
|
uri,
|
||||||
allowRedirects = false,
|
allowRedirects = false,
|
||||||
|
@ -462,6 +467,10 @@ class AnimePaheProvider : MainAPI() {
|
||||||
cookies=cookieStrToMap(fContent.headers.getValue("set-cookie").replace("path=/,", ""))
|
cookies=cookieStrToMap(fContent.headers.getValue("set-cookie").replace("path=/,", ""))
|
||||||
)
|
)
|
||||||
code = content.statusCode
|
code = content.statusCode
|
||||||
|
++tries
|
||||||
|
}
|
||||||
|
if (tries > 19) {
|
||||||
|
throw Exception("Failed to extract the stream uri from kwik.")
|
||||||
}
|
}
|
||||||
return content?.headers?.getValue("location").toString()
|
return content?.headers?.getValue("location").toString()
|
||||||
}
|
}
|
||||||
|
@ -502,7 +511,7 @@ class AnimePaheProvider : MainAPI() {
|
||||||
"KWIK - ${quality.key} [${quality.value.audio ?: "jpn"}]",
|
"KWIK - ${quality.key} [${quality.value.audio ?: "jpn"}]",
|
||||||
getStreamUrlFromKwik(quality.value.kwikAdfly),
|
getStreamUrlFromKwik(quality.value.kwikAdfly),
|
||||||
"",
|
"",
|
||||||
quality.key.toInt(),
|
getQualityFromName(quality.key),
|
||||||
false
|
false
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue