Skip to content

Commit

Permalink
Next Airing episode support in Trakt meta provider (recloudstream#1072)
Browse files Browse the repository at this point in the history
  • Loading branch information
KingLucius authored May 21, 2024
1 parent db2bf5e commit e697bf7
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.net.Uri
import com.lagradost.cloudstream3.*
import com.fasterxml.jackson.annotation.JsonAlias
import com.fasterxml.jackson.annotation.JsonProperty
import com.lagradost.cloudstream3.APIHolder.unixTimeMS
import com.lagradost.cloudstream3.LoadResponse.Companion.addImdbId
import com.lagradost.cloudstream3.LoadResponse.Companion.addTMDbId
import com.lagradost.cloudstream3.LoadResponse.Companion.addTrailer
Expand Down Expand Up @@ -166,6 +167,7 @@ open class TraktProvider : MainAPI() {
val episodes = mutableListOf<Episode>()
val seasons = parseJson<List<Seasons>>(resSeasons)
val seasonsNames = mutableListOf<SeasonData>()
var nextAir: NextAiring? = null

seasons.forEach { season ->

Expand Down Expand Up @@ -215,6 +217,13 @@ open class TraktProvider : MainAPI() {
description = episode.overview,
).apply {
this.addDate(episode.firstAired)
if (nextAir == null && this.date != null && this.date!! > unixTimeMS) {
nextAir = NextAiring(
episode = this.episode!!,
unixTime = this.date!!.div(1000L),
season = if (this.season == 1) null else this.season,
)
}
}
)
}
Expand All @@ -240,6 +249,7 @@ open class TraktProvider : MainAPI() {
this.actors = actors
this.comingSoon = isUpcoming(mediaDetails.released)
//posterHeaders
this.nextAiring = nextAir
this.seasonNames = seasonsNames
this.backgroundPosterUrl = getOriginalWidthImageUrl(backDropUrl)
this.contentRating = mediaDetails.certification
Expand Down

0 comments on commit e697bf7

Please sign in to comment.