From 3d6520cdef2db5e860a1a4d91ade21a4a3ae06f7 Mon Sep 17 00:00:00 2001 From: jack Date: Fri, 1 Dec 2023 05:19:52 +0700 Subject: [PATCH] f up kuramanime --- KuramanimeProvider/build.gradle.kts | 2 +- .../src/main/kotlin/com/hexated/Extractors.kt | 104 ++++++++++++++++++ .../kotlin/com/hexated/KuramanimeProvider.kt | 58 ++++++---- .../com/hexated/KuramanimeProviderPlugin.kt | 2 + 4 files changed, 141 insertions(+), 25 deletions(-) diff --git a/KuramanimeProvider/build.gradle.kts b/KuramanimeProvider/build.gradle.kts index e68b3715..5c147a6a 100644 --- a/KuramanimeProvider/build.gradle.kts +++ b/KuramanimeProvider/build.gradle.kts @@ -1,5 +1,5 @@ // use an integer for version numbers -version = 28 +version = 29 cloudstream { diff --git a/KuramanimeProvider/src/main/kotlin/com/hexated/Extractors.kt b/KuramanimeProvider/src/main/kotlin/com/hexated/Extractors.kt index 521502ac..e393fbc0 100644 --- a/KuramanimeProvider/src/main/kotlin/com/hexated/Extractors.kt +++ b/KuramanimeProvider/src/main/kotlin/com/hexated/Extractors.kt @@ -1,7 +1,14 @@ package com.hexated +import com.fasterxml.jackson.annotation.JsonProperty +import com.lagradost.cloudstream3.SubtitleFile +import com.lagradost.cloudstream3.app import com.lagradost.cloudstream3.extractors.Filesim import com.lagradost.cloudstream3.extractors.StreamSB +import com.lagradost.cloudstream3.utils.ExtractorApi +import com.lagradost.cloudstream3.utils.ExtractorLink +import com.lagradost.cloudstream3.utils.Qualities +import com.lagradost.cloudstream3.utils.getQualityFromName class Nyomo : StreamSB() { override var name: String = "Nyomo" @@ -11,4 +18,101 @@ class Nyomo : StreamSB() { class Streamhide : Filesim() { override var name: String = "Streamhide" override var mainUrl: String = "https://streamhide.to" +} + +open class Lbx : ExtractorApi() { + override val name = "Linkbox" + override val mainUrl = "https://lbx.to" + private val realUrl = "https://www.linkbox.to" + override val requiresReferer = true + + override suspend fun getUrl( + url: String, + referer: String?, + subtitleCallback: (SubtitleFile) -> Unit, + callback: (ExtractorLink) -> Unit + ) { + val token = Regex("""(?:/f/|/file/|\?id=)(\w+)""").find(url)?.groupValues?.get(1) + val id = app.get("$realUrl/api/file/share_out_list/?sortField=utime&sortAsc=0&pageNo=1&pageSize=50&shareToken=$token").parsedSafe()?.data?.itemId + app.get("$realUrl/api/file/detail?itemId=$id", referer = url) + .parsedSafe()?.data?.itemInfo?.resolutionList?.map { link -> + callback.invoke( + ExtractorLink( + name, + name, + link.url ?: return@map null, + "$realUrl/", + getQualityFromName(link.resolution) + ) + ) + } + } + + data class Resolutions( + @JsonProperty("url") val url: String? = null, + @JsonProperty("resolution") val resolution: String? = null, + ) + + data class ItemInfo( + @JsonProperty("resolutionList") val resolutionList: ArrayList? = arrayListOf(), + ) + + data class Data( + @JsonProperty("itemInfo") val itemInfo: ItemInfo? = null, + @JsonProperty("itemId") val itemId: String? = null, + ) + + data class Responses( + @JsonProperty("data") val data: Data? = null, + ) + +} + +open class Kuramadrive : ExtractorApi() { + override val name = "DriveKurama" + override val mainUrl = "https://kuramadrive.com" + override val requiresReferer = true + + override suspend fun getUrl( + url: String, + referer: String?, + subtitleCallback: (SubtitleFile) -> Unit, + callback: (ExtractorLink) -> Unit + ) { + val req = app.get(url, referer = referer) + val doc = req.document + + val title = doc.select("title").text() + val token = doc.select("meta[name=csrf-token]").attr("content") + val routeCheckAvl = doc.select("input#routeCheckAvl").attr("value") + + val json = app.post( + routeCheckAvl, headers = mapOf( + "X-Requested-With" to "XMLHttpRequest", + "X-CSRF-TOKEN" to token + ), + referer = url, + cookies = req.cookies + ).parsedSafe() + + callback.invoke( + ExtractorLink( + name, + name, + json?.url ?: return, + "$mainUrl/", + getIndexQuality(title), + ) + ) + } + + private fun getIndexQuality(str: String?): Int { + return Regex("(\\d{3,4})[pP]").find(str ?: "")?.groupValues?.getOrNull(1)?.toIntOrNull() + ?: Qualities.Unknown.value + } + + private data class Source( + @JsonProperty("url") val url: String, + ) + } \ No newline at end of file diff --git a/KuramanimeProvider/src/main/kotlin/com/hexated/KuramanimeProvider.kt b/KuramanimeProvider/src/main/kotlin/com/hexated/KuramanimeProvider.kt index eb8697ea..93716f94 100644 --- a/KuramanimeProvider/src/main/kotlin/com/hexated/KuramanimeProvider.kt +++ b/KuramanimeProvider/src/main/kotlin/com/hexated/KuramanimeProvider.kt @@ -200,32 +200,42 @@ class KuramanimeProvider : MainAPI() { val req = app.get(data) val res = req.document - val token = res.select("meta[name=csrf-token]").attr("content") - val auth = getAuth(data) - headers = mapOf( - "Accept" to "application/json, text/javascript, */*; q=0.01", - "Authorization" to "${auth.authHeader}", - "X-Requested-With" to "XMLHttpRequest", - "X-CSRF-TOKEN" to token - ) - cookies = req.cookies - res.select("select#changeServer option").apmap { source -> - val server = source.attr("value") - val query = auth.serverUrl?.queryParameterNames - val link = "$data?${query?.first()}=${getMisc(auth.authUrl)}&${query?.last()}=$server" - if (server.contains(Regex("(?i)kuramadrive|archive"))) { - invokeLocalSource(link, server, data, callback) - } else { - app.get( - link, - referer = data, - headers = headers, - cookies = cookies - ).document.select("div.iframe-container iframe").attr("src").let { videoUrl -> - loadExtractor(fixUrl(videoUrl), "$mainUrl/", subtitleCallback, callback) + + argamap( + { + val token = res.select("meta[name=csrf-token]").attr("content") + val auth = getAuth(data) + headers = mapOf( + "Accept" to "application/json, text/javascript, */*; q=0.01", + "Authorization" to "${auth.authHeader}", + "X-Requested-With" to "XMLHttpRequest", + "X-CSRF-TOKEN" to token + ) + cookies = req.cookies + res.select("select#changeServer option").apmap { source -> + val server = source.attr("value") + val query = auth.serverUrl?.queryParameterNames + val link = "$data?${query?.first()}=${getMisc(auth.authUrl)}&${query?.last()}=$server" + if (server.contains(Regex("(?i)kuramadrive|archive"))) { + invokeLocalSource(link, server, data, callback) + } else { + app.get( + link, + referer = data, + headers = headers, + cookies = cookies + ).document.select("div.iframe-container iframe").attr("src").let { videoUrl -> + loadExtractor(fixUrl(videoUrl), "$mainUrl/", subtitleCallback, callback) + } + } + } + }, + { + res.select("div#animeDownloadLink a").apmap { + loadExtractor(it.attr("href"), "$mainUrl/", subtitleCallback, callback) } } - } + ) return true } diff --git a/KuramanimeProvider/src/main/kotlin/com/hexated/KuramanimeProviderPlugin.kt b/KuramanimeProvider/src/main/kotlin/com/hexated/KuramanimeProviderPlugin.kt index da4282eb..77db0c6e 100644 --- a/KuramanimeProvider/src/main/kotlin/com/hexated/KuramanimeProviderPlugin.kt +++ b/KuramanimeProvider/src/main/kotlin/com/hexated/KuramanimeProviderPlugin.kt @@ -12,5 +12,7 @@ class KuramanimeProviderPlugin: Plugin() { registerMainAPI(KuramanimeProvider()) registerExtractorAPI(Nyomo()) registerExtractorAPI(Streamhide()) + registerExtractorAPI(Kuramadrive()) + registerExtractorAPI(Lbx()) } } \ No newline at end of file