mirror of
https://github.com/hexated/cloudstream-extensions-hexated.git
synced 2024-08-15 00:03:22 +00:00
fix
This commit is contained in:
parent
e3681935de
commit
1040dd6731
2 changed files with 45 additions and 48 deletions
|
@ -2202,26 +2202,38 @@ object SoraExtractor : SoraStream() {
|
||||||
subtitleCallback: (SubtitleFile) -> Unit,
|
subtitleCallback: (SubtitleFile) -> Unit,
|
||||||
callback: (ExtractorLink) -> Unit,
|
callback: (ExtractorLink) -> Unit,
|
||||||
) {
|
) {
|
||||||
val media =
|
val id = imdbId?.removePrefix("tt")
|
||||||
app.get("$cinemaTvAPI/v1/${if (season == null) "movies" else "shows"}?filters[q]=$title")
|
val slug = title?.createSlug()
|
||||||
.parsedSafe<CinemaTvResponse>()?.items?.find {
|
val url = if (season == null) {
|
||||||
it.imdb_id?.removePrefix("tt")
|
"$cinemaTvAPI/movies/play/$id-$slug-$year"
|
||||||
.equals(imdbId?.removePrefix("tt")) || (it.title.equals(
|
|
||||||
title,
|
|
||||||
true
|
|
||||||
) && it.year == year)
|
|
||||||
} ?: return
|
|
||||||
|
|
||||||
val mediaId = if (season == null) {
|
|
||||||
media.id_movie
|
|
||||||
} else {
|
} else {
|
||||||
app.get("$cinemaTvAPI/v1/shows?expand=episodes&id=${media.id_show}")
|
"$cinemaTvAPI/shows/play/$id-$slug-$year"
|
||||||
.parsedSafe<CinemaTvResponse>()?.episodes?.find { it.episode == episode && it.season == season }?.id
|
}
|
||||||
} ?: return
|
|
||||||
|
|
||||||
val sources =
|
val headers = mapOf(
|
||||||
app.get("$cinemaTvAPI/v1/${if (season == null) "movies" else "episodes"}/view?expand=streams,subtitles&id=$mediaId")
|
"x-requested-with" to "XMLHttpRequest",
|
||||||
.parsedSafe<CinemaTvResponse>()
|
)
|
||||||
|
val doc = app.get(url, headers = headers).document
|
||||||
|
val script = doc.selectFirst("script:containsData(hash:)")?.data()
|
||||||
|
val hash = Regex("hash:\\s*['\"](\\S+)['\"]").find(script ?: return)?.groupValues?.get(1)
|
||||||
|
val expires = Regex("expires:\\s*(\\d+)").find(script)?.groupValues?.get(1)
|
||||||
|
val episodeId = (if (season == null) {
|
||||||
|
"""id_movie:\s*(\d+)"""
|
||||||
|
} else {
|
||||||
|
"""episode:\s*['"]$episode['"],[\n\s]+id_episode:\s*(\d+),[\n\s]+season:\s*['"]$season['"]"""
|
||||||
|
}).let { it.toRegex().find(script)?.groupValues?.get(1) }
|
||||||
|
|
||||||
|
val videoUrl = if (season == null) {
|
||||||
|
"$cinemaTvAPI/api/v1/security/movie-access?id_movie=$episodeId&hash=$hash&expires=$expires"
|
||||||
|
} else {
|
||||||
|
"$cinemaTvAPI/api/v1/security/episode-access?id_episode=$episodeId&hash=$hash&expires=$expires"
|
||||||
|
}
|
||||||
|
|
||||||
|
val sources = app.get(
|
||||||
|
videoUrl,
|
||||||
|
referer = url,
|
||||||
|
headers = headers
|
||||||
|
).parsedSafe<CinemaTvResponse>()
|
||||||
|
|
||||||
sources?.streams?.mapKeys { source ->
|
sources?.streams?.mapKeys { source ->
|
||||||
callback.invoke(
|
callback.invoke(
|
||||||
|
@ -2229,18 +2241,19 @@ object SoraExtractor : SoraStream() {
|
||||||
"CinemaTv",
|
"CinemaTv",
|
||||||
"CinemaTv",
|
"CinemaTv",
|
||||||
source.value,
|
source.value,
|
||||||
"",
|
"$cinemaTvAPI/",
|
||||||
getQualityFromName(source.key),
|
getQualityFromName(source.key),
|
||||||
true
|
true
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
sources?.subtitles?.map {
|
sources?.subtitles?.map { sub ->
|
||||||
|
val file = sub.file.toString()
|
||||||
subtitleCallback.invoke(
|
subtitleCallback.invoke(
|
||||||
SubtitleFile(
|
SubtitleFile(
|
||||||
it.language ?: return@map,
|
sub.language ?: return@map,
|
||||||
fixUrl(it.url ?: return@map, cinemaTvAPI)
|
if (file.startsWith("[")) return@map else fixUrl(file, cinemaTvAPI),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -191,32 +191,6 @@ data class JikanResponse(
|
||||||
@JsonProperty("data") val data: JikanData? = null,
|
@JsonProperty("data") val data: JikanData? = null,
|
||||||
)
|
)
|
||||||
|
|
||||||
data class CinemaTvResponse(
|
|
||||||
@JsonProperty("items") val items: ArrayList<Items>? = arrayListOf(),
|
|
||||||
@JsonProperty("episodes") val episodes: ArrayList<Episodes>? = arrayListOf(),
|
|
||||||
@JsonProperty("streams") val streams: HashMap<String, String>? = null,
|
|
||||||
@JsonProperty("subtitles") val subtitles: ArrayList<Subtitles>? = arrayListOf(),
|
|
||||||
) {
|
|
||||||
data class Items(
|
|
||||||
@JsonProperty("id_movie") val id_movie: Int? = null,
|
|
||||||
@JsonProperty("id_show") val id_show: Int? = null,
|
|
||||||
@JsonProperty("title") val title: String? = null,
|
|
||||||
@JsonProperty("year") val year: Int? = null,
|
|
||||||
@JsonProperty("imdb_id") val imdb_id: String? = null,
|
|
||||||
)
|
|
||||||
|
|
||||||
data class Episodes(
|
|
||||||
@JsonProperty("id") val id: Int? = null,
|
|
||||||
@JsonProperty("season") val season: Int? = null,
|
|
||||||
@JsonProperty("episode") val episode: Int? = null,
|
|
||||||
)
|
|
||||||
|
|
||||||
data class Subtitles(
|
|
||||||
@JsonProperty("language") val language: String? = null,
|
|
||||||
@JsonProperty("url") val url: String? = null,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
data class VidsrctoResult(
|
data class VidsrctoResult(
|
||||||
@JsonProperty("id") val id: String? = null,
|
@JsonProperty("id") val id: String? = null,
|
||||||
@JsonProperty("title") val title: String? = null,
|
@JsonProperty("title") val title: String? = null,
|
||||||
|
@ -486,4 +460,14 @@ data class AoneroomResponse(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
data class CinemaTvResponse(
|
||||||
|
@JsonProperty("streams") val streams: HashMap<String, String>? = null,
|
||||||
|
@JsonProperty("subtitles") val subtitles: ArrayList<Subtitles>? = arrayListOf(),
|
||||||
|
) {
|
||||||
|
data class Subtitles(
|
||||||
|
@JsonProperty("language") val language: String? = null,
|
||||||
|
@JsonProperty("file") val file: Any? = null,
|
||||||
|
)
|
||||||
}
|
}
|
Loading…
Reference in a new issue