Skip to content

Commit

Permalink
sora: disable SfMovies & fix CinemaTv
Browse files Browse the repository at this point in the history
  • Loading branch information
alex committed Jan 24, 2024
1 parent 92a0b49 commit a340c9e
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 59 deletions.
2 changes: 1 addition & 1 deletion SoraStream/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import org.jetbrains.kotlin.konan.properties.Properties

// use an integer for version numbers
version = 219
version = 220

android {
defaultConfig {
Expand Down
57 changes: 18 additions & 39 deletions SoraStream/src/main/kotlin/com/hexated/SoraExtractor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2337,63 +2337,42 @@ object SoraExtractor : SoraStream() {
subtitleCallback: (SubtitleFile) -> Unit,
callback: (ExtractorLink) -> Unit,
) {
val id = imdbId?.removePrefix("tt")
val slug = title.createSlug()
val url = if (season == null) {
"$cinemaTvAPI/movies/play/$id-$slug-$year"
} else {
"$cinemaTvAPI/shows/play/$id-$slug-$year"
}

val session =
"PHPSESSID=ngr4cudjrimdnhkth30ssohs0n; _csrf=a6ffd7bb7654083fce6df528225a238d0e85aa1fb885dc7638c1259ec1ba0d5ca%3A2%3A%7Bi%3A0%3Bs%3A5%3A%22_csrf%22%3Bi%3A1%3Bs%3A32%3A%22mTTLiDLjxohs-CpKk0bjRH3HdYMB9uBV%22%3B%7D; _ga=GA1.1.1195498587.1701871187; _ga_VZD7HJ3WK6=GS1.1.$unixTime.4.0.1.$unixTime.0.0.0"

val headers = mapOf(
"Cookie" to session,
"x-requested-with" to "com.wwcinematv",
)

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 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 videoUrl = if (season == null) {
"$cinemaTvAPI/api/v1/security/movie-access?id_movie=$episodeId&hash=$hash&expires=$expires"
val mediaId = if (season == null) {
media.id_movie
} else {
"$cinemaTvAPI/api/v1/security/episode-access?id_episode=$episodeId&hash=$hash&expires=$expires"
}
app.get("$cinemaTvAPI/v1/shows?expand=episodes&id=${media.id_show}")
.parsedSafe<CinemaTvResponse>()?.episodes?.find { it.episode == episode && it.season == season }?.id
} ?: return

val sources = app.get(
videoUrl,
referer = url,
headers = mapOf("X-Requested-With" to "XMLHttpRequest")
).parsedSafe<CinemaTvResponse>()
val sources = app.get("$cinemaTvAPI/v1/${if (season == null) "movies" else "episodes"}/view?expand=streams,subtitles&id=$mediaId").parsedSafe<CinemaTvResponse>()

sources?.streams?.mapKeys { source ->
callback.invoke(
ExtractorLink(
"CinemaTv",
"CinemaTv",
source.value,
"$cinemaTvAPI/",
"",
getQualityFromName(source.key),
true
)
)
}

sources?.subtitles?.map { sub ->
val file = sub.file.toString()
sources?.subtitles?.map {
subtitleCallback.invoke(
SubtitleFile(
sub.language ?: return@map,
if (file.startsWith("[")) return@map else fixUrl(file, cinemaTvAPI),
it.language ?: return@map,
fixUrl(it.url ?: return@map, cinemaTvAPI)
)
)
}
Expand Down
30 changes: 23 additions & 7 deletions SoraStream/src/main/kotlin/com/hexated/SoraParser.kt
Original file line number Diff line number Diff line change
Expand Up @@ -191,15 +191,31 @@ data class JikanResponse(
@JsonProperty("data") val data: JikanData? = null,
)

data class CinemaTvSubtitles(
@JsonProperty("language") val language: String? = null,
@JsonProperty("file") val file: Any? = 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<CinemaTvSubtitles>? = arrayListOf(),
)
@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,
Expand Down
12 changes: 6 additions & 6 deletions SoraStream/src/main/kotlin/com/hexated/SoraStream.kt
Original file line number Diff line number Diff line change
Expand Up @@ -717,12 +717,12 @@ open class SoraStream : TmdbProvider() {
callback
)
},
{
if (!res.isAnime) invokeSFMovies(
res.id, res.title, res.airedYear
?: res.year, res.season, res.episode, callback
)
},
// {
// if (!res.isAnime) invokeSFMovies(
// res.id, res.title, res.airedYear
// ?: res.year, res.season, res.episode, callback
// )
// },
// {
// invokeMMovies(res.title, res.season, res.episode, subtitleCallback, callback)
// },
Expand Down
12 changes: 6 additions & 6 deletions SoraStream/src/main/kotlin/com/hexated/SoraStreamLite.kt
Original file line number Diff line number Diff line change
Expand Up @@ -326,12 +326,12 @@ class SoraStreamLite : SoraStream() {
callback
)
},
{
if (!res.isAnime) invokeSFMovies(
res.id, res.title, res.airedYear
?: res.year, res.season, res.episode, callback
)
},
// {
// if (!res.isAnime) invokeSFMovies(
// res.id, res.title, res.airedYear
// ?: res.year, res.season, res.episode, callback
// )
// },
// {
// invokeMMovies(res.title, res.season, res.episode, subtitleCallback, callback)
// },
Expand Down

0 comments on commit a340c9e

Please sign in to comment.