fixed SoraDetail
This commit is contained in:
parent
b3e7abe930
commit
7f4ecec6e0
|
@ -1,5 +1,5 @@
|
||||||
// use an integer for version numbers
|
// use an integer for version numbers
|
||||||
version = 34
|
version = 35
|
||||||
|
|
||||||
|
|
||||||
cloudstream {
|
cloudstream {
|
||||||
|
|
|
@ -78,14 +78,6 @@ open class SoraStream : TmdbProvider() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getActorRole(t: String?): ActorRole {
|
|
||||||
return when (t) {
|
|
||||||
"Acting" -> ActorRole.Main
|
|
||||||
else -> ActorRole.Background
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
fun getStatus(t: String?): ShowStatus {
|
fun getStatus(t: String?): ShowStatus {
|
||||||
return when (t) {
|
return when (t) {
|
||||||
"Returning Series" -> ShowStatus.Ongoing
|
"Returning Series" -> ShowStatus.Ongoing
|
||||||
|
@ -99,15 +91,6 @@ open class SoraStream : TmdbProvider() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun checkMainServer() {
|
|
||||||
val check = app.get(mainServerAPI)
|
|
||||||
mainServerAPI = if (check.isSuccessful) {
|
|
||||||
mainServerAPI
|
|
||||||
} else {
|
|
||||||
base64DecodeAPI("cHA=LmE=ZWw=cmM=dmU=Ny4=bjQ=cmE=aHQ=YW4=a2g=ZS0=dmk=bW8=eC0=bWk=cmU=Ly8=czo=dHA=aHQ=")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override val mainPage = mainPageOf(
|
override val mainPage = mainPageOf(
|
||||||
"$tmdbAPI/tv/airing_today?api_key=$apiKey®ion=&page=" to "Airing Today TV Shows",
|
"$tmdbAPI/tv/airing_today?api_key=$apiKey®ion=&page=" to "Airing Today TV Shows",
|
||||||
"$tmdbAPI/movie/popular?api_key=$apiKey®ion=&page=" to "Popular Movies",
|
"$tmdbAPI/movie/popular?api_key=$apiKey®ion=&page=" to "Popular Movies",
|
||||||
|
@ -175,38 +158,34 @@ open class SoraStream : TmdbProvider() {
|
||||||
|
|
||||||
override suspend fun load(url: String): LoadResponse? {
|
override suspend fun load(url: String): LoadResponse? {
|
||||||
val data = parseJson<Data>(url)
|
val data = parseJson<Data>(url)
|
||||||
|
val type = getType(data.type)
|
||||||
|
val resUrl = if(type == TvType.Movie) {
|
||||||
|
"$tmdbAPI/movie/${data.id}?api_key=$apiKey&append_to_response=credits,external_ids,videos,recommendations"
|
||||||
|
} else {
|
||||||
|
"$tmdbAPI/tv/${data.id}?api_key=$apiKey&append_to_response=credits,external_ids,videos,recommendations"
|
||||||
|
}
|
||||||
|
val res = app.get(resUrl).parsedSafe<MediaDetail>() ?: throw ErrorLoadingException("Invalid Json Response")
|
||||||
|
|
||||||
val buildId =
|
|
||||||
app.get("$mainAPI/").text.substringAfterLast("\"buildId\":\"").substringBefore("\",")
|
|
||||||
val responses =
|
|
||||||
app.get("$mainAPI/_next/data/$buildId/${data.type}/${data.id}.json?id=${data.id}")
|
|
||||||
.parsedSafe<Detail>()?.pageProps
|
|
||||||
?: throw ErrorLoadingException("Invalid Json Response")
|
|
||||||
val res = responses.result ?: return null
|
|
||||||
val title = res.title ?: res.name ?: return null
|
val title = res.title ?: res.name ?: return null
|
||||||
val poster = getOriImageUrl(res.backdropPath)
|
val poster = getOriImageUrl(res.backdropPath)
|
||||||
val orgTitle = res.originalTitle ?: res.originalName ?: return null
|
val orgTitle = res.originalTitle ?: res.originalName ?: return null
|
||||||
val type = getType(data.type)
|
|
||||||
val year = (res.releaseDate ?: res.firstAirDate)?.split("-")?.first()?.toIntOrNull()
|
val year = (res.releaseDate ?: res.firstAirDate)?.split("-")?.first()?.toIntOrNull()
|
||||||
val genres = res.genres?.mapNotNull { it.name }
|
val genres = res.genres?.mapNotNull { it.name }
|
||||||
val show =
|
val show = if (genres?.contains("Animation") == true && res.original_language == "ja") "Anime" else "Series/Movies"
|
||||||
if (genres?.contains("Animation") == true && res.original_language == "ja") "Anime" else "Series/Movies"
|
|
||||||
|
|
||||||
val actors = responses.cast?.mapNotNull { cast ->
|
val actors = res.credits?.cast?.mapNotNull { cast ->
|
||||||
ActorData(
|
ActorData(
|
||||||
Actor(
|
Actor(
|
||||||
cast.name ?: cast.originalName ?: return@mapNotNull null,
|
cast.name ?: cast.originalName ?: return@mapNotNull null,
|
||||||
getImageUrl(cast.profilePath)
|
getImageUrl(cast.profilePath)
|
||||||
),
|
),
|
||||||
getActorRole(cast.knownForDepartment)
|
roleString = cast.character
|
||||||
)
|
)
|
||||||
} ?: return null
|
} ?: return null
|
||||||
val recommendations =
|
val recommendations = res.recommendations?.results?.mapNotNull { media -> media.toSearchResponse() }
|
||||||
responses.recommandations?.mapNotNull { media -> media.toSearchResponse() }
|
|
||||||
|
|
||||||
val trailer =
|
val trailer = res.videos?.results?.map { "https://www.youtube.com/watch?v=${it.key}" }
|
||||||
responses.result.videos?.results?.map { "https://www.youtube.com/watch?v=${it.key}" }
|
?.randomOrNull()
|
||||||
?.randomOrNull()
|
|
||||||
|
|
||||||
return if (type == TvType.TvSeries) {
|
return if (type == TvType.TvSeries) {
|
||||||
val episodes = mutableListOf<Episode>()
|
val episodes = mutableListOf<Episode>()
|
||||||
|
@ -217,7 +196,7 @@ open class SoraStream : TmdbProvider() {
|
||||||
episodes.add(Episode(
|
episodes.add(Episode(
|
||||||
LinkData(
|
LinkData(
|
||||||
data.id,
|
data.id,
|
||||||
responses.imdbId,
|
res.external_ids?.imdb_id,
|
||||||
data.type,
|
data.type,
|
||||||
eps.seasonNumber,
|
eps.seasonNumber,
|
||||||
eps.episodeNumber,
|
eps.episodeNumber,
|
||||||
|
@ -261,7 +240,7 @@ open class SoraStream : TmdbProvider() {
|
||||||
TvType.Movie,
|
TvType.Movie,
|
||||||
LinkData(
|
LinkData(
|
||||||
data.id,
|
data.id,
|
||||||
responses.imdbId,
|
res.external_ids?.imdb_id,
|
||||||
data.type,
|
data.type,
|
||||||
title = title,
|
title = title,
|
||||||
year = year,
|
year = year,
|
||||||
|
@ -563,6 +542,19 @@ open class SoraStream : TmdbProvider() {
|
||||||
@JsonProperty("results") val results: ArrayList<Trailers>? = arrayListOf(),
|
@JsonProperty("results") val results: ArrayList<Trailers>? = arrayListOf(),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
data class ExternalIds(
|
||||||
|
@JsonProperty("imdb_id") val imdb_id: String? = null,
|
||||||
|
@JsonProperty("tvdb_id") val tvdb_id: String? = null,
|
||||||
|
)
|
||||||
|
|
||||||
|
data class Credits(
|
||||||
|
@JsonProperty("cast") val cast: ArrayList<Cast>? = arrayListOf(),
|
||||||
|
)
|
||||||
|
|
||||||
|
data class ResultsRecommendations(
|
||||||
|
@JsonProperty("results") val results: ArrayList<Media>? = arrayListOf(),
|
||||||
|
)
|
||||||
|
|
||||||
data class MediaDetail(
|
data class MediaDetail(
|
||||||
@JsonProperty("id") val id: Int? = null,
|
@JsonProperty("id") val id: Int? = null,
|
||||||
@JsonProperty("imdb_id") val imdbId: String? = null,
|
@JsonProperty("imdb_id") val imdbId: String? = null,
|
||||||
|
@ -580,20 +572,18 @@ open class SoraStream : TmdbProvider() {
|
||||||
@JsonProperty("genres") val genres: ArrayList<Genres>? = arrayListOf(),
|
@JsonProperty("genres") val genres: ArrayList<Genres>? = arrayListOf(),
|
||||||
@JsonProperty("seasons") val seasons: ArrayList<Seasons>? = arrayListOf(),
|
@JsonProperty("seasons") val seasons: ArrayList<Seasons>? = arrayListOf(),
|
||||||
@JsonProperty("videos") val videos: ResultsTrailer? = null,
|
@JsonProperty("videos") val videos: ResultsTrailer? = null,
|
||||||
|
@JsonProperty("external_ids") val external_ids: ExternalIds? = null,
|
||||||
)
|
@JsonProperty("credits") val credits: Credits? = null,
|
||||||
|
@JsonProperty("recommendations") val recommendations: ResultsRecommendations? = null,
|
||||||
data class PageProps(
|
|
||||||
@JsonProperty("id") val id: String? = null,
|
|
||||||
@JsonProperty("imdb") val imdbId: String? = null,
|
|
||||||
@JsonProperty("result") val result: MediaDetail? = null,
|
|
||||||
@JsonProperty("recommandations") val recommandations: ArrayList<Media>? = arrayListOf(),
|
|
||||||
@JsonProperty("cast") val cast: ArrayList<Cast>? = arrayListOf(),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
data class Detail(
|
// data class PageProps(
|
||||||
@JsonProperty("pageProps") val pageProps: PageProps? = null,
|
// @JsonProperty("id") val id: String? = null,
|
||||||
)
|
// @JsonProperty("imdb") val imdbId: String? = null,
|
||||||
|
// @JsonProperty("result") val result: MediaDetail? = null,
|
||||||
|
// @JsonProperty("recommandations") val recommandations: ArrayList<Media>? = arrayListOf(),
|
||||||
|
// @JsonProperty("cast") val cast: ArrayList<Cast>? = arrayListOf(),
|
||||||
|
// )
|
||||||
|
|
||||||
data class EmbedJson(
|
data class EmbedJson(
|
||||||
@JsonProperty("type") val type: String? = null,
|
@JsonProperty("type") val type: String? = null,
|
||||||
|
|
Loading…
Reference in New Issue