From dd15a3d7e518e60872b9737db79bc75e33d42d9c Mon Sep 17 00:00:00 2001 From: hexated Date: Mon, 13 Feb 2023 16:17:07 +0700 Subject: [PATCH] loklok: moved cdn --- Loklok/build.gradle.kts | 2 +- Loklok/src/main/kotlin/com/hexated/Loklok.kt | 17 ++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Loklok/build.gradle.kts b/Loklok/build.gradle.kts index e3bf2933..65e18c29 100644 --- a/Loklok/build.gradle.kts +++ b/Loklok/build.gradle.kts @@ -1,5 +1,5 @@ // use an integer for version numbers -version = 15 +version = 16 cloudstream { diff --git a/Loklok/src/main/kotlin/com/hexated/Loklok.kt b/Loklok/src/main/kotlin/com/hexated/Loklok.kt index a9782061..e0213287 100644 --- a/Loklok/src/main/kotlin/com/hexated/Loklok.kt +++ b/Loklok/src/main/kotlin/com/hexated/Loklok.kt @@ -131,7 +131,7 @@ class Loklok : MainAPI() { headers = headers ).parsedSafe()?.data ?: throw ErrorLoadingException("Invalid Json Reponse") - headers["deviceid"] = getDevideId(16) + headers["deviceid"] = getDevideId() val episodes = res.episodeVo?.map { eps -> val definition = eps.definitionList?.map { @@ -219,10 +219,13 @@ class Loklok : MainAPI() { val res = parseJson(data) res.definitionList?.apmap { video -> - val json = app.get( - "$apiUrl/media/previewInfo?category=${res.category}&contentId=${res.id}&episodeId=${res.epId}&definition=${video.code}", - headers = headers, - ).parsedSafe()?.data + val body = + """[{"category":${res.category},"contentId":"${res.id}","episodeId":${res.epId},"definition":"${video.code}"}]""".toRequestBody( + RequestBodyTypes.JSON.toMediaTypeOrNull() + ) + val json = + app.post("$apiUrl/media/bathGetplayInfo", requestBody = body, headers = headers) + .parsedSafe()?.data?.firstOrNull() callback.invoke( ExtractorLink( this.name, @@ -257,7 +260,7 @@ class Loklok : MainAPI() { } } - private fun getDevideId(length: Int): String { + private fun getDevideId(length: Int = 16): String { val allowedChars = ('a'..'f') + ('0'..'9') return (1..length) .map { allowedChars.random() } @@ -334,7 +337,7 @@ class Loklok : MainAPI() { ) data class PreviewResponse( - @JsonProperty("data") val data: PreviewVideos? = null, + @JsonProperty("data") val data: ArrayList? = arrayListOf(), ) data class PreviewVideos(