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
e9d716663c
commit
5bec47b3b2
2 changed files with 48 additions and 45 deletions
|
@ -1,5 +1,5 @@
|
|||
// use an integer for version numbers
|
||||
version = 9
|
||||
version = 10
|
||||
|
||||
|
||||
cloudstream {
|
||||
|
|
|
@ -2,13 +2,13 @@ package com.hexated
|
|||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty
|
||||
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.toJson
|
||||
import com.lagradost.cloudstream3.utils.ExtractorLink
|
||||
import com.lagradost.cloudstream3.utils.SubtitleHelper
|
||||
import com.lagradost.cloudstream3.utils.getQualityFromName
|
||||
import kotlinx.coroutines.delay
|
||||
import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson
|
||||
import com.lagradost.nicehttp.RequestBodyTypes
|
||||
import okhttp3.MediaType.Companion.toMediaTypeOrNull
|
||||
import okhttp3.RequestBody.Companion.toRequestBody
|
||||
|
||||
class Loklok : MainAPI() {
|
||||
override var name = "Loklok"
|
||||
|
@ -188,27 +188,27 @@ class Loklok : MainAPI() {
|
|||
|
||||
val res = parseJson<UrlEpisode>(data)
|
||||
|
||||
res.definitionList?.apmap { video ->
|
||||
safeApiCall {
|
||||
delay(500)
|
||||
app.get(
|
||||
"$apiUrl/media/previewInfo?category=${res.category}&contentId=${res.id}&episodeId=${res.epId}&definition=${video.code}",
|
||||
headers = headers
|
||||
).parsedSafe<Video>()?.data.let { link ->
|
||||
val video = res.definitionList?.map {
|
||||
MetaData(res.category, res.id, res.epId, it.code)
|
||||
} ?: return false
|
||||
|
||||
val json = app.post(
|
||||
"$apiUrl/media/bathGetplayInfo",
|
||||
requestBody = video.toJson().toRequestBody(RequestBodyTypes.JSON.toMediaTypeOrNull()),
|
||||
headers = headers,
|
||||
).text
|
||||
tryParseJson<PreviewResponse>(json)?.data?.map { link ->
|
||||
callback.invoke(
|
||||
ExtractorLink(
|
||||
this.name,
|
||||
this.name,
|
||||
link?.mediaUrl ?: return@let,
|
||||
link.mediaUrl ?: return@map null,
|
||||
"",
|
||||
getQualityFromName(video.description),
|
||||
getQuality(link.currentDefinition ?: ""),
|
||||
isM3u8 = true,
|
||||
headers = headers
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
res.subtitlingList?.map { sub ->
|
||||
subtitleCallback.invoke(
|
||||
|
@ -222,6 +222,16 @@ class Loklok : MainAPI() {
|
|||
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(
|
||||
val id: Any? = null,
|
||||
val category: Int? = null,
|
||||
|
@ -246,12 +256,20 @@ class Loklok : MainAPI() {
|
|||
val subtitlingList: List<Subtitling>? = arrayListOf(),
|
||||
)
|
||||
|
||||
data class VideoData(
|
||||
@JsonProperty("mediaUrl") val mediaUrl: String? = null,
|
||||
data class MetaData(
|
||||
val category: Int? = null,
|
||||
val contentId: Any? = null,
|
||||
val episodeId: Int? = null,
|
||||
val definition: String? = null,
|
||||
)
|
||||
|
||||
data class Video(
|
||||
@JsonProperty("data") val data: VideoData? = null,
|
||||
data class PreviewResponse(
|
||||
@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(
|
||||
|
@ -288,21 +306,6 @@ class Loklok : MainAPI() {
|
|||
@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(
|
||||
@JsonProperty("id") val id: Any? = null,
|
||||
@JsonProperty("category") val category: Int? = null,
|
||||
|
|
Loading…
Reference in a new issue