diff --git a/pkg/models/unified.go b/pkg/models/unified.go index 2c274bd..f8ce2a5 100644 --- a/pkg/models/unified.go +++ b/pkg/models/unified.go @@ -43,6 +43,31 @@ type UnifiedContent struct { Revenue *int64 `json:"revenue"` IMDbID string `json:"imdbId"` ExternalIDs UnifiedExternalIDs `json:"externalIds"` + // For TV shows + Seasons []UnifiedSeason `json:"seasons,omitempty"` +} + +type UnifiedSeason struct { + ID string `json:"id"` + SourceID string `json:"sourceId"` + Name string `json:"name"` + SeasonNumber int `json:"seasonNumber"` + EpisodeCount int `json:"episodeCount"` + ReleaseDate string `json:"releaseDate"` + PosterURL string `json:"posterUrl"` + Episodes []UnifiedEpisode `json:"episodes,omitempty"` +} + +type UnifiedEpisode struct { + ID string `json:"id"` + SourceID string `json:"sourceId"` + Name string `json:"name"` + EpisodeNumber int `json:"episodeNumber"` + SeasonNumber int `json:"seasonNumber"` + AirDate string `json:"airDate"` + Duration int `json:"duration"` + Description string `json:"description"` + StillURL string `json:"stillUrl"` } type UnifiedSearchItem struct { diff --git a/pkg/services/unified_mapper.go b/pkg/services/unified_mapper.go index 3700beb..51abbaf 100644 --- a/pkg/services/unified_mapper.go +++ b/pkg/services/unified_mapper.go @@ -125,7 +125,7 @@ func MapTMDBTVToUnified(tv *models.TVShow, external *models.ExternalIDs) *models duration = tv.EpisodeRunTime[0] } - return &models.UnifiedContent{ + unified := &models.UnifiedContent{ ID: strconv.Itoa(tv.ID), SourceID: "tmdb_" + strconv.Itoa(tv.ID), Title: tv.Name, @@ -148,6 +148,24 @@ func MapTMDBTVToUnified(tv *models.TVShow, external *models.ExternalIDs) *models IMDbID: imdb, ExternalIDs: ext, } + + // Map seasons basic info + if len(tv.Seasons) > 0 { + unified.Seasons = make([]models.UnifiedSeason, 0, len(tv.Seasons)) + for _, s := range tv.Seasons { + unified.Seasons = append(unified.Seasons, models.UnifiedSeason{ + ID: strconv.Itoa(s.ID), + SourceID: "tmdb_" + strconv.Itoa(s.ID), + Name: s.Name, + SeasonNumber: s.SeasonNumber, + EpisodeCount: s.EpisodeCount, + ReleaseDate: s.AirDate, + PosterURL: BuildTMDBImageURL(s.PosterPath, "w500"), + }) + } + } + + return unified } func MapTMDBMultiToUnifiedItems(m *models.MultiSearchResponse) []models.UnifiedSearchItem {