mirror of
https://github.com/hexated/cloudstream-extensions-hexated.git
synced 2024-08-15 00:03:22 +00:00
fixed Loklok
This commit is contained in:
parent
ba5f3bef57
commit
7ee31320ed
2 changed files with 17 additions and 12 deletions
|
@ -1,5 +1,5 @@
|
||||||
// use an integer for version numbers
|
// use an integer for version numbers
|
||||||
version = 14
|
version = 15
|
||||||
|
|
||||||
|
|
||||||
cloudstream {
|
cloudstream {
|
||||||
|
|
|
@ -7,7 +7,6 @@ import com.lagradost.cloudstream3.LoadResponse.Companion.addMalId
|
||||||
import com.lagradost.cloudstream3.utils.*
|
import com.lagradost.cloudstream3.utils.*
|
||||||
import com.lagradost.cloudstream3.utils.AppUtils.parseJson
|
import com.lagradost.cloudstream3.utils.AppUtils.parseJson
|
||||||
import com.lagradost.cloudstream3.utils.AppUtils.toJson
|
import com.lagradost.cloudstream3.utils.AppUtils.toJson
|
||||||
import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson
|
|
||||||
import com.lagradost.nicehttp.RequestBodyTypes
|
import com.lagradost.nicehttp.RequestBodyTypes
|
||||||
import okhttp3.MediaType.Companion.toMediaTypeOrNull
|
import okhttp3.MediaType.Companion.toMediaTypeOrNull
|
||||||
import okhttp3.RequestBody.Companion.toRequestBody
|
import okhttp3.RequestBody.Companion.toRequestBody
|
||||||
|
@ -25,10 +24,10 @@ class Loklok : MainAPI() {
|
||||||
TvType.AsianDrama,
|
TvType.AsianDrama,
|
||||||
)
|
)
|
||||||
|
|
||||||
private val headers = mapOf(
|
private val headers = mutableMapOf(
|
||||||
"lang" to "en",
|
"lang" to "en",
|
||||||
"versioncode" to "11",
|
"versioncode" to "32",
|
||||||
"clienttype" to "ios_jike_default"
|
"clienttype" to "android_tem3",
|
||||||
)
|
)
|
||||||
|
|
||||||
// no license found
|
// no license found
|
||||||
|
@ -132,6 +131,8 @@ class Loklok : MainAPI() {
|
||||||
headers = headers
|
headers = headers
|
||||||
).parsedSafe<Load>()?.data ?: throw ErrorLoadingException("Invalid Json Reponse")
|
).parsedSafe<Load>()?.data ?: throw ErrorLoadingException("Invalid Json Reponse")
|
||||||
|
|
||||||
|
headers["deviceid"] = getDevideId(16)
|
||||||
|
|
||||||
val episodes = res.episodeVo?.map { eps ->
|
val episodes = res.episodeVo?.map { eps ->
|
||||||
val definition = eps.definitionList?.map {
|
val definition = eps.definitionList?.map {
|
||||||
Definition(
|
Definition(
|
||||||
|
@ -218,13 +219,10 @@ class Loklok : MainAPI() {
|
||||||
val res = parseJson<UrlEpisode>(data)
|
val res = parseJson<UrlEpisode>(data)
|
||||||
|
|
||||||
res.definitionList?.apmap { video ->
|
res.definitionList?.apmap { video ->
|
||||||
val body = """[{"category":${res.category},"contentId":"${res.id}","episodeId":${res.epId},"definition":"${video.code}"}]""".toRequestBody(RequestBodyTypes.JSON.toMediaTypeOrNull())
|
val json = app.get(
|
||||||
val response = app.post(
|
"$apiUrl/media/previewInfo?category=${res.category}&contentId=${res.id}&episodeId=${res.epId}&definition=${video.code}",
|
||||||
"$apiUrl/media/bathGetplayInfo",
|
|
||||||
requestBody = body,
|
|
||||||
headers = headers,
|
headers = headers,
|
||||||
).text
|
).parsedSafe<PreviewResponse>()?.data
|
||||||
val json = tryParseJson<PreviewResponse>(response)?.data?.firstOrNull()
|
|
||||||
callback.invoke(
|
callback.invoke(
|
||||||
ExtractorLink(
|
ExtractorLink(
|
||||||
this.name,
|
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 {
|
private suspend fun getTracker(title: String?, type: String?, year: Int?): Tracker {
|
||||||
val res = app.get("https://api.consumet.org/meta/anilist/$title")
|
val res = app.get("https://api.consumet.org/meta/anilist/$title")
|
||||||
.parsedSafe<AniSearch>()?.results?.find { media ->
|
.parsedSafe<AniSearch>()?.results?.find { media ->
|
||||||
|
@ -329,7 +334,7 @@ class Loklok : MainAPI() {
|
||||||
)
|
)
|
||||||
|
|
||||||
data class PreviewResponse(
|
data class PreviewResponse(
|
||||||
@JsonProperty("data") val data: ArrayList<PreviewVideos>? = arrayListOf(),
|
@JsonProperty("data") val data: PreviewVideos? = null,
|
||||||
)
|
)
|
||||||
|
|
||||||
data class PreviewVideos(
|
data class PreviewVideos(
|
||||||
|
|
Loading…
Reference in a new issue