This commit is contained in:
Olivia 2024-01-30 23:44:18 +07:00
parent e3681935de
commit 1040dd6731
2 changed files with 45 additions and 48 deletions

View File

@ -2202,26 +2202,38 @@ object SoraExtractor : SoraStream() {
subtitleCallback: (SubtitleFile) -> Unit,
callback: (ExtractorLink) -> Unit,
) {
val media =
app.get("$cinemaTvAPI/v1/${if (season == null) "movies" else "shows"}?filters[q]=$title")
.parsedSafe<CinemaTvResponse>()?.items?.find {
it.imdb_id?.removePrefix("tt")
.equals(imdbId?.removePrefix("tt")) || (it.title.equals(
title,
true
) && it.year == year)
} ?: return
val mediaId = if (season == null) {
media.id_movie
val id = imdbId?.removePrefix("tt")
val slug = title?.createSlug()
val url = if (season == null) {
"$cinemaTvAPI/movies/play/$id-$slug-$year"
} else {
app.get("$cinemaTvAPI/v1/shows?expand=episodes&id=${media.id_show}")
.parsedSafe<CinemaTvResponse>()?.episodes?.find { it.episode == episode && it.season == season }?.id
} ?: return
"$cinemaTvAPI/shows/play/$id-$slug-$year"
}
val sources =
app.get("$cinemaTvAPI/v1/${if (season == null) "movies" else "episodes"}/view?expand=streams,subtitles&id=$mediaId")
.parsedSafe<CinemaTvResponse>()
val headers = mapOf(
"x-requested-with" to "XMLHttpRequest",
)
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 ->
callback.invoke(
@ -2229,18 +2241,19 @@ object SoraExtractor : SoraStream() {
"CinemaTv",
"CinemaTv",
source.value,
"",
"$cinemaTvAPI/",
getQualityFromName(source.key),
true
)
)
}
sources?.subtitles?.map {
sources?.subtitles?.map { sub ->
val file = sub.file.toString()
subtitleCallback.invoke(
SubtitleFile(
it.language ?: return@map,
fixUrl(it.url ?: return@map, cinemaTvAPI)
sub.language ?: return@map,
if (file.startsWith("[")) return@map else fixUrl(file, cinemaTvAPI),
)
)
}

View File

@ -191,32 +191,6 @@ data class JikanResponse(
@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(
@JsonProperty("id") val id: 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,
)
}