fixed Loklok

This commit is contained in:
hexated 2023-02-07 20:10:00 +07:00
parent ba5f3bef57
commit 7ee31320ed
2 changed files with 17 additions and 12 deletions

View file

@ -1,5 +1,5 @@
// use an integer for version numbers
version = 14
version = 15
cloudstream {

View file

@ -7,7 +7,6 @@ import com.lagradost.cloudstream3.LoadResponse.Companion.addMalId
import com.lagradost.cloudstream3.utils.*
import com.lagradost.cloudstream3.utils.AppUtils.parseJson
import com.lagradost.cloudstream3.utils.AppUtils.toJson
import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson
import com.lagradost.nicehttp.RequestBodyTypes
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.RequestBody.Companion.toRequestBody
@ -25,10 +24,10 @@ class Loklok : MainAPI() {
TvType.AsianDrama,
)
private val headers = mapOf(
private val headers = mutableMapOf(
"lang" to "en",
"versioncode" to "11",
"clienttype" to "ios_jike_default"
"versioncode" to "32",
"clienttype" to "android_tem3",
)
// no license found
@ -132,6 +131,8 @@ class Loklok : MainAPI() {
headers = headers
).parsedSafe<Load>()?.data ?: throw ErrorLoadingException("Invalid Json Reponse")
headers["deviceid"] = getDevideId(16)
val episodes = res.episodeVo?.map { eps ->
val definition = eps.definitionList?.map {
Definition(
@ -218,13 +219,10 @@ class Loklok : MainAPI() {
val res = parseJson<UrlEpisode>(data)
res.definitionList?.apmap { video ->
val body = """[{"category":${res.category},"contentId":"${res.id}","episodeId":${res.epId},"definition":"${video.code}"}]""".toRequestBody(RequestBodyTypes.JSON.toMediaTypeOrNull())
val response = app.post(
"$apiUrl/media/bathGetplayInfo",
requestBody = body,
val json = app.get(
"$apiUrl/media/previewInfo?category=${res.category}&contentId=${res.id}&episodeId=${res.epId}&definition=${video.code}",
headers = headers,
).text
val json = tryParseJson<PreviewResponse>(response)?.data?.firstOrNull()
).parsedSafe<PreviewResponse>()?.data
callback.invoke(
ExtractorLink(
this.name,
@ -259,6 +257,13 @@ class Loklok : MainAPI() {
}
}
private fun getDevideId(length: Int): String {
val allowedChars = ('a'..'f') + ('0'..'9')
return (1..length)
.map { allowedChars.random() }
.joinToString("")
}
private suspend fun getTracker(title: String?, type: String?, year: Int?): Tracker {
val res = app.get("https://api.consumet.org/meta/anilist/$title")
.parsedSafe<AniSearch>()?.results?.find { media ->
@ -329,7 +334,7 @@ class Loklok : MainAPI() {
)
data class PreviewResponse(
@JsonProperty("data") val data: ArrayList<PreviewVideos>? = arrayListOf(),
@JsonProperty("data") val data: PreviewVideos? = null,
)
data class PreviewVideos(