mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
metaproviders: use new* methods
This commit is contained in:
parent
2fc279f4ae
commit
70190f79c0
3 changed files with 88 additions and 57 deletions
|
@ -1,17 +1,47 @@
|
||||||
package com.lagradost.cloudstream3.metaproviders
|
package com.lagradost.cloudstream3.metaproviders
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty
|
import com.fasterxml.jackson.annotation.JsonProperty
|
||||||
import com.lagradost.cloudstream3.*
|
import com.lagradost.cloudstream3.Actor
|
||||||
|
import com.lagradost.cloudstream3.ErrorLoadingException
|
||||||
|
import com.lagradost.cloudstream3.HomePageList
|
||||||
|
import com.lagradost.cloudstream3.HomePageResponse
|
||||||
|
import com.lagradost.cloudstream3.LoadResponse
|
||||||
import com.lagradost.cloudstream3.LoadResponse.Companion.addActors
|
import com.lagradost.cloudstream3.LoadResponse.Companion.addActors
|
||||||
import com.lagradost.cloudstream3.LoadResponse.Companion.addImdbId
|
import com.lagradost.cloudstream3.LoadResponse.Companion.addImdbId
|
||||||
import com.lagradost.cloudstream3.LoadResponse.Companion.addTrailer
|
import com.lagradost.cloudstream3.LoadResponse.Companion.addTrailer
|
||||||
|
import com.lagradost.cloudstream3.MainAPI
|
||||||
|
import com.lagradost.cloudstream3.MainPageRequest
|
||||||
|
import com.lagradost.cloudstream3.MovieLoadResponse
|
||||||
|
import com.lagradost.cloudstream3.MovieSearchResponse
|
||||||
|
import com.lagradost.cloudstream3.ProviderType
|
||||||
|
import com.lagradost.cloudstream3.SearchResponse
|
||||||
|
import com.lagradost.cloudstream3.TvSeriesLoadResponse
|
||||||
|
import com.lagradost.cloudstream3.TvSeriesSearchResponse
|
||||||
|
import com.lagradost.cloudstream3.TvType
|
||||||
|
import com.lagradost.cloudstream3.argamap
|
||||||
|
import com.lagradost.cloudstream3.newEpisode
|
||||||
|
import com.lagradost.cloudstream3.newHomePageResponse
|
||||||
|
import com.lagradost.cloudstream3.newMovieLoadResponse
|
||||||
|
import com.lagradost.cloudstream3.newMovieSearchResponse
|
||||||
|
import com.lagradost.cloudstream3.newTvSeriesLoadResponse
|
||||||
|
import com.lagradost.cloudstream3.newTvSeriesSearchResponse
|
||||||
import com.lagradost.cloudstream3.utils.AppUtils.toJson
|
import com.lagradost.cloudstream3.utils.AppUtils.toJson
|
||||||
import com.uwetrottmann.tmdb2.Tmdb
|
import com.uwetrottmann.tmdb2.Tmdb
|
||||||
import com.uwetrottmann.tmdb2.entities.*
|
import com.uwetrottmann.tmdb2.entities.AppendToResponse
|
||||||
|
import com.uwetrottmann.tmdb2.entities.BaseMovie
|
||||||
|
import com.uwetrottmann.tmdb2.entities.BaseTvShow
|
||||||
|
import com.uwetrottmann.tmdb2.entities.CastMember
|
||||||
|
import com.uwetrottmann.tmdb2.entities.ContentRating
|
||||||
|
import com.uwetrottmann.tmdb2.entities.Movie
|
||||||
|
import com.uwetrottmann.tmdb2.entities.ReleaseDate
|
||||||
|
import com.uwetrottmann.tmdb2.entities.ReleaseDatesResult
|
||||||
|
import com.uwetrottmann.tmdb2.entities.TvSeason
|
||||||
|
import com.uwetrottmann.tmdb2.entities.TvShow
|
||||||
|
import com.uwetrottmann.tmdb2.entities.Videos
|
||||||
import com.uwetrottmann.tmdb2.enumerations.AppendToResponseItem
|
import com.uwetrottmann.tmdb2.enumerations.AppendToResponseItem
|
||||||
import com.uwetrottmann.tmdb2.enumerations.VideoType
|
import com.uwetrottmann.tmdb2.enumerations.VideoType
|
||||||
import retrofit2.awaitResponse
|
import retrofit2.awaitResponse
|
||||||
import java.util.*
|
import java.util.Calendar
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* episode and season starting from 1
|
* episode and season starting from 1
|
||||||
|
@ -54,36 +84,37 @@ open class TmdbProvider : MainAPI() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun BaseTvShow.toSearchResponse(): TvSeriesSearchResponse {
|
private fun BaseTvShow.toSearchResponse(): TvSeriesSearchResponse {
|
||||||
return TvSeriesSearchResponse(
|
return newTvSeriesSearchResponse(
|
||||||
this.name ?: this.original_name,
|
name = this.name ?: this.original_name,
|
||||||
getUrl(id, true),
|
url = getUrl(id, true),
|
||||||
apiName,
|
type = TvType.TvSeries,
|
||||||
TvType.TvSeries,
|
fix = false
|
||||||
getImageUrl(this.poster_path),
|
) {
|
||||||
this.first_air_date?.let {
|
this.id = this@toSearchResponse.id
|
||||||
|
this.posterUrl = getImageUrl(poster_path)
|
||||||
|
this.year = first_air_date?.let {
|
||||||
Calendar.getInstance().apply {
|
Calendar.getInstance().apply {
|
||||||
time = it
|
time = it
|
||||||
}.get(Calendar.YEAR)
|
}.get(Calendar.YEAR)
|
||||||
},
|
}
|
||||||
null,
|
}
|
||||||
this.id
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun BaseMovie.toSearchResponse(): MovieSearchResponse {
|
private fun BaseMovie.toSearchResponse(): MovieSearchResponse {
|
||||||
return MovieSearchResponse(
|
return newMovieSearchResponse(
|
||||||
this.title ?: this.original_title,
|
name = this.title ?: this.original_title,
|
||||||
getUrl(id, false),
|
url = getUrl(id, false),
|
||||||
apiName,
|
type = TvType.Movie,
|
||||||
TvType.TvSeries,
|
fix = false
|
||||||
getImageUrl(this.poster_path),
|
) {
|
||||||
this.release_date?.let {
|
this.id = this@toSearchResponse.id
|
||||||
|
this.posterUrl = getImageUrl(poster_path)
|
||||||
|
this.year = release_date?.let {
|
||||||
Calendar.getInstance().apply {
|
Calendar.getInstance().apply {
|
||||||
time = it
|
time = it
|
||||||
}.get(Calendar.YEAR)
|
}.get(Calendar.YEAR)
|
||||||
},
|
}
|
||||||
this.id,
|
}
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun List<CastMember?>?.toActors(): List<Pair<Actor, String?>>? {
|
private fun List<CastMember?>?.toActors(): List<Pair<Actor, String?>>? {
|
||||||
|
@ -99,34 +130,36 @@ open class TmdbProvider : MainAPI() {
|
||||||
val episodes = this.seasons?.filter { !disableSeasonZero || (it.season_number ?: 0) != 0 }
|
val episodes = this.seasons?.filter { !disableSeasonZero || (it.season_number ?: 0) != 0 }
|
||||||
?.mapNotNull { season ->
|
?.mapNotNull { season ->
|
||||||
season.episodes?.map { episode ->
|
season.episodes?.map { episode ->
|
||||||
Episode(
|
newEpisode(
|
||||||
TmdbLink(
|
TmdbLink(
|
||||||
episode.external_ids?.imdb_id ?: this.external_ids?.imdb_id,
|
episode.external_ids?.imdb_id ?: this.external_ids?.imdb_id,
|
||||||
this.id,
|
this.id,
|
||||||
episode.episode_number,
|
episode.episode_number,
|
||||||
episode.season_number,
|
episode.season_number,
|
||||||
this.name ?: this.original_name,
|
this.name ?: this.original_name,
|
||||||
).toJson(),
|
).toJson()
|
||||||
episode.name,
|
) {
|
||||||
episode.season_number,
|
this.name = episode.name
|
||||||
episode.episode_number,
|
this.season = episode.season_number
|
||||||
getImageUrl(episode.still_path),
|
this.episode = episode.episode_number
|
||||||
episode.rating,
|
this.rating = episode.rating
|
||||||
episode.overview,
|
this.description = episode.overview
|
||||||
episode.air_date?.time,
|
this.date = episode.air_date?.time
|
||||||
)
|
this.posterUrl = getImageUrl(episode.still_path)
|
||||||
|
}
|
||||||
} ?: (1..(season.episode_count ?: 1)).map { episodeNum ->
|
} ?: (1..(season.episode_count ?: 1)).map { episodeNum ->
|
||||||
Episode(
|
newEpisode(
|
||||||
episode = episodeNum,
|
TmdbLink(
|
||||||
data = TmdbLink(
|
|
||||||
this.external_ids?.imdb_id,
|
this.external_ids?.imdb_id,
|
||||||
this.id,
|
this.id,
|
||||||
episodeNum,
|
episodeNum,
|
||||||
season.season_number,
|
season.season_number,
|
||||||
this.name ?: this.original_name,
|
this.name ?: this.original_name,
|
||||||
).toJson(),
|
).toJson()
|
||||||
season = season.season_number
|
) {
|
||||||
)
|
this.episode = episodeNum
|
||||||
|
this.season = season.season_number
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}?.flatten() ?: listOf()
|
}?.flatten() ?: listOf()
|
||||||
|
|
||||||
|
@ -242,7 +275,7 @@ open class TmdbProvider : MainAPI() {
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
return HomePageResponse(
|
return newHomePageResponse(
|
||||||
listOf(
|
listOf(
|
||||||
// HomePageList("Popular Series", popularSeries),
|
// HomePageList("Popular Series", popularSeries),
|
||||||
// HomePageList("Popular Movies", popularMovies),
|
// HomePageList("Popular Movies", popularMovies),
|
||||||
|
@ -368,9 +401,7 @@ open class TmdbProvider : MainAPI() {
|
||||||
val details = tmdb.tvService().tv(id, "en-US").awaitResponse().body()
|
val details = tmdb.tvService().tv(id, "en-US").awaitResponse().body()
|
||||||
loadFromImdb(it, details?.seasons ?: listOf())
|
loadFromImdb(it, details?.seasons ?: listOf())
|
||||||
?: loadFromTmdb(id, details?.seasons ?: listOf())
|
?: loadFromTmdb(id, details?.seasons ?: listOf())
|
||||||
} else {
|
} else fromImdb
|
||||||
fromImdb
|
|
||||||
}
|
|
||||||
|
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
@ -387,4 +418,4 @@ open class TmdbProvider : MainAPI() {
|
||||||
it.movie?.toSearchResponse() ?: it.tvShow?.toSearchResponse()
|
it.movie?.toSearchResponse() ?: it.tvShow?.toSearchResponse()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -25,6 +25,7 @@ import com.lagradost.cloudstream3.app
|
||||||
import com.lagradost.cloudstream3.base64Decode
|
import com.lagradost.cloudstream3.base64Decode
|
||||||
import com.lagradost.cloudstream3.mainPageOf
|
import com.lagradost.cloudstream3.mainPageOf
|
||||||
import com.lagradost.cloudstream3.mvvm.logError
|
import com.lagradost.cloudstream3.mvvm.logError
|
||||||
|
import com.lagradost.cloudstream3.newEpisode
|
||||||
import com.lagradost.cloudstream3.newHomePageResponse
|
import com.lagradost.cloudstream3.newHomePageResponse
|
||||||
import com.lagradost.cloudstream3.newMovieLoadResponse
|
import com.lagradost.cloudstream3.newMovieLoadResponse
|
||||||
import com.lagradost.cloudstream3.newMovieSearchResponse
|
import com.lagradost.cloudstream3.newMovieSearchResponse
|
||||||
|
@ -228,16 +229,15 @@ open class TraktProvider : MainAPI() {
|
||||||
).toJson()
|
).toJson()
|
||||||
|
|
||||||
episodes.add(
|
episodes.add(
|
||||||
Episode(
|
newEpisode(linkData.toJson()) {
|
||||||
data = linkData.toJson(),
|
this.name = episode.title
|
||||||
name = episode.title,
|
this.season = episode.season
|
||||||
season = episode.season,
|
this.episode = episode.number
|
||||||
episode = episode.number,
|
this.description = episode.overview
|
||||||
posterUrl = fixPath(episode.images?.screenshot?.firstOrNull()),
|
this.runTime = episode.runtime
|
||||||
rating = episode.rating?.times(10)?.roundToInt(),
|
this.posterUrl = fixPath(episode.images?.screenshot?.firstOrNull())
|
||||||
description = episode.overview,
|
this.rating = episode.rating?.times(10)?.roundToInt()
|
||||||
runTime = episode.runtime
|
|
||||||
).apply {
|
|
||||||
this.addDate(episode.firstAired, "yyyy-MM-dd'T'HH:mm:ss.SSSXXX")
|
this.addDate(episode.firstAired, "yyyy-MM-dd'T'HH:mm:ss.SSSXXX")
|
||||||
if (nextAir == null && this.date != null && this.date!! > unixTimeMS && this.season != 0) {
|
if (nextAir == null && this.date != null && this.date!! > unixTimeMS && this.season != 0) {
|
||||||
nextAir = NextAiring(
|
nextAir = NextAiring(
|
||||||
|
|
|
@ -978,7 +978,7 @@ data class TvSeriesSearchResponse(
|
||||||
override var type: TvType? = null,
|
override var type: TvType? = null,
|
||||||
|
|
||||||
override var posterUrl: String? = null,
|
override var posterUrl: String? = null,
|
||||||
val year: Int? = null,
|
var year: Int? = null,
|
||||||
val episodes: Int? = null,
|
val episodes: Int? = null,
|
||||||
override var id: Int? = null,
|
override var id: Int? = null,
|
||||||
override var quality: SearchQuality? = null,
|
override var quality: SearchQuality? = null,
|
||||||
|
@ -2002,4 +2002,4 @@ enum class TrackerType {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue