Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
imper1aldev committed Apr 8, 2024
1 parent f4a9a99 commit a809806
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,12 @@ class Jkanime : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
return languages.firstOrNull { it.first == this }?.second ?: ""
}

private fun getVideoLinks(document: Document): MutableList<Pair<String, String>> {
private fun getVideoLinks(document: Document): List<Pair<String, String>> {
val servers = mutableListOf<Pair<String, String>>()
val scriptServers = document.selectFirst("script:containsData(var video = [];)")!!
val scriptServers = document.selectFirst("script:containsData(var video = [];)")?.data() ?: return emptyList()

val jsServer = scriptServers.data().substringAfter("var remote = '").substringBefore("'")
val jsPath = scriptServers.data().substringAfter("= remote+'").substringBefore("'")
val jsServer = scriptServers.substringAfter("var remote = '").substringBefore("'")
val jsPath = scriptServers.substringAfter("= remote+'").substringBefore("'")
if (jsServer.isNotEmpty() && jsPath.isNotEmpty()) {
val jsLinks = client.newCall(GET(jsServer + jsPath)).execute().body.string()
.substringAfter("var servers = ").parseAs<Array<JsLinks>>().map {
Expand All @@ -151,7 +151,7 @@ class Jkanime : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
val htmlLinks = document.select("div.col-lg-12.rounded.bg-servers.text-white.p-3.mt-2 a").map {
val serverId = it.attr("data-id")
val lang = it.attr("class").substringAfter("lg_").substringBefore(" ").getLang()
val url = scriptServers.data()
val url = scriptServers
.substringAfter("video[$serverId] = '<iframe class=\"player_conte\" src=\"")
.substringBefore("\"")
.replace("/jkokru.php?u=", "http://ok.ru/videoembed/")
Expand Down Expand Up @@ -186,9 +186,9 @@ class Jkanime : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
"mixdrop" in url || "mdbekjwqa" in url -> mixDropExtractor.videosFromUrl(url, prefix = "$lang ")
"sfastwish" in url || "wishembed" in url || "streamwish" in url || "strwish" in url || "wish" in url
-> streamWishExtractor.videosFromUrl(url, videoNameGen = { "$lang StreamWish:$it" })
"stream/jkmedia" in url -> listOf(jkanimeExtractor.getDesukaFromUrl(url, "$lang ")!!)
"um2.php" in url -> listOf(jkanimeExtractor.getNozomiFromUrl(url, "$lang ")!!)
"um.php" in url -> listOf(jkanimeExtractor.getDesuFromUrl(url, "$lang ")!!)
"stream/jkmedia" in url -> jkanimeExtractor.getDesukaFromUrl(url, "$lang ")
"um2.php" in url -> jkanimeExtractor.getNozomiFromUrl(url, "$lang ")
"um.php" in url -> jkanimeExtractor.getDesuFromUrl(url, "$lang ")
else -> emptyList()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class JkanimeExtractor(
private val client: OkHttpClient,
) {

fun getNozomiFromUrl(url: String, prefix: String = ""): Video? {
fun getNozomiFromUrl(url: String, prefix: String = ""): List<Video> {
val dataKeyHeaders = Headers.Builder().add("Referer", url).build()
val doc = client.newCall(GET(url, dataKeyHeaders)).execute().asJsoup()
val dataKey = doc.select("form input[value]").attr("value")
Expand All @@ -26,30 +26,37 @@ class JkanimeExtractor(

val nozomiBody = "v=$postKey".toRequestBody("application/x-www-form-urlencoded".toMediaTypeOrNull())
val nozomiResponse = client.newCall(POST("https://jkanime.net/gsplay/api.php", body = nozomiBody)).execute()
val nozomiUrl = JSONObject(nozomiResponse.body.string()).getString("file")
if (nozomiResponse.isSuccessful && nozomiUrl.isNotBlank()) {
return Video(nozomiUrl, "${prefix}Nozomi", nozomiUrl)
}
return null
val nozomiUrl = JSONObject(nozomiResponse.body.string()).getString("file").ifBlank { return emptyList() }

return listOf(Video(nozomiUrl, "${prefix}Nozomi", nozomiUrl))
}

fun getDesuFromUrl(url: String, prefix: String = ""): Video? {
fun getDesuFromUrl(url: String, prefix: String = ""): List<Video> {
val document = client.newCall(GET(url)).execute()
val script = document.asJsoup().selectFirst("script:containsData(var parts = {)")!!.data()
val streamUrl = script.substringAfter("url: '").substringBefore("'")
if (document.isSuccessful && streamUrl.isNotBlank()) {
return Video(streamUrl, "${prefix}Desu", streamUrl)
}
return null
val streamUrl = document.asJsoup()
.selectFirst("script:containsData(var parts = {)")
?.data()?.substringAfter("url: '")
?.substringBefore("'") ?: return emptyList()

return listOf(Video(streamUrl, "${prefix}Desu", streamUrl))
}

fun getDesukaFromUrl(url: String, prefix: String = ""): Video? {
fun getDesukaFromUrl(url: String, prefix: String = ""): List<Video> {
val document = client.newCall(GET(url)).execute()
val script = document.asJsoup().selectFirst("script:containsData(new DPlayer({)")!!.data()
val streamUrl = script.substringAfter("url: '").substringBefore("'")
if (document.isSuccessful && streamUrl.isNotBlank()) {
return Video(streamUrl, "${prefix}Desuka", streamUrl)
val contentType = document.header("Content-Type") ?: ""

if (contentType.startsWith("video/")) {
val realUrl = document.networkResponse.toString()
.substringAfter("url=")
.substringBefore("}")
return listOf(Video(realUrl, "${prefix}Desuka", realUrl))
}
return null

val streamUrl = document.asJsoup()
.selectFirst("script:containsData(new DPlayer({)")
?.data()?.substringAfter("url: '")
?.substringBefore("'") ?: return emptyList()

return listOf(Video(streamUrl, "${prefix}Desuka", streamUrl))
}
}

0 comments on commit a809806

Please sign in to comment.