fixed Loklok

This commit is contained in:
hexated 2022-12-09 21:08:31 +07:00
parent e9d716663c
commit 5bec47b3b2
2 changed files with 48 additions and 45 deletions

View file

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

View file

@ -2,13 +2,13 @@ package com.hexated
import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.annotation.JsonProperty
import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.*
import com.lagradost.cloudstream3.mvvm.safeApiCall 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.ExtractorLink import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson
import com.lagradost.cloudstream3.utils.SubtitleHelper import com.lagradost.nicehttp.RequestBodyTypes
import com.lagradost.cloudstream3.utils.getQualityFromName import okhttp3.MediaType.Companion.toMediaTypeOrNull
import kotlinx.coroutines.delay import okhttp3.RequestBody.Companion.toRequestBody
class Loklok : MainAPI() { class Loklok : MainAPI() {
override var name = "Loklok" override var name = "Loklok"
@ -188,27 +188,27 @@ class Loklok : MainAPI() {
val res = parseJson<UrlEpisode>(data) val res = parseJson<UrlEpisode>(data)
res.definitionList?.apmap { video -> val video = res.definitionList?.map {
safeApiCall { MetaData(res.category, res.id, res.epId, it.code)
delay(500) } ?: return false
app.get(
"$apiUrl/media/previewInfo?category=${res.category}&contentId=${res.id}&episodeId=${res.epId}&definition=${video.code}", val json = app.post(
headers = headers "$apiUrl/media/bathGetplayInfo",
).parsedSafe<Video>()?.data.let { link -> requestBody = video.toJson().toRequestBody(RequestBodyTypes.JSON.toMediaTypeOrNull()),
headers = headers,
).text
tryParseJson<PreviewResponse>(json)?.data?.map { link ->
callback.invoke( callback.invoke(
ExtractorLink( ExtractorLink(
this.name, this.name,
this.name, this.name,
link?.mediaUrl ?: return@let, link.mediaUrl ?: return@map null,
"", "",
getQualityFromName(video.description), getQuality(link.currentDefinition ?: ""),
isM3u8 = true, isM3u8 = true,
headers = headers
) )
) )
} }
}
}
res.subtitlingList?.map { sub -> res.subtitlingList?.map { sub ->
subtitleCallback.invoke( subtitleCallback.invoke(
@ -222,6 +222,16 @@ class Loklok : MainAPI() {
return true return true
} }
private fun getQuality(quality: String): Int {
return when (quality) {
"GROOT_FD" -> Qualities.P360.value
"GROOT_LD" -> Qualities.P480.value
"GROOT_SD" -> Qualities.P720.value
"GROOT_HD" -> Qualities.P1080.value
else -> Qualities.Unknown.value
}
}
data class UrlData( data class UrlData(
val id: Any? = null, val id: Any? = null,
val category: Int? = null, val category: Int? = null,
@ -246,12 +256,20 @@ class Loklok : MainAPI() {
val subtitlingList: List<Subtitling>? = arrayListOf(), val subtitlingList: List<Subtitling>? = arrayListOf(),
) )
data class VideoData( data class MetaData(
@JsonProperty("mediaUrl") val mediaUrl: String? = null, val category: Int? = null,
val contentId: Any? = null,
val episodeId: Int? = null,
val definition: String? = null,
) )
data class Video( data class PreviewResponse(
@JsonProperty("data") val data: VideoData? = null, @JsonProperty("data") val data: ArrayList<PreviewVideos>? = arrayListOf(),
)
data class PreviewVideos(
@JsonProperty("mediaUrl") val mediaUrl: String? = null,
@JsonProperty("currentDefinition") val currentDefinition: String? = null,
) )
data class SubtitlingList( data class SubtitlingList(
@ -288,21 +306,6 @@ class Loklok : MainAPI() {
@JsonProperty("data") val data: MediaDetail? = null, @JsonProperty("data") val data: MediaDetail? = null,
) )
data class MediaSearch(
@JsonProperty("id") val id: String? = null,
@JsonProperty("domainType") val domainType: Int? = null,
@JsonProperty("name") val name: String? = null,
@JsonProperty("coverVerticalUrl") val coverVerticalUrl: String? = null,
)
data class Result(
@JsonProperty("result") val result: ArrayList<MediaSearch>? = arrayListOf(),
)
data class Search(
@JsonProperty("pageProps") val pageProps: Result? = null,
)
data class Media( data class Media(
@JsonProperty("id") val id: Any? = null, @JsonProperty("id") val id: Any? = null,
@JsonProperty("category") val category: Int? = null, @JsonProperty("category") val category: Int? = null,