mirror of
https://gitlab.com/foxixus/neomovies-api.git
synced 2025-10-27 17:38:51 +05:00
feat(unified): add seasons to unified content and map TMDB seasons
This commit is contained in:
@@ -43,6 +43,31 @@ type UnifiedContent struct {
|
|||||||
Revenue *int64 `json:"revenue"`
|
Revenue *int64 `json:"revenue"`
|
||||||
IMDbID string `json:"imdbId"`
|
IMDbID string `json:"imdbId"`
|
||||||
ExternalIDs UnifiedExternalIDs `json:"externalIds"`
|
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 {
|
type UnifiedSearchItem struct {
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ func MapTMDBTVToUnified(tv *models.TVShow, external *models.ExternalIDs) *models
|
|||||||
duration = tv.EpisodeRunTime[0]
|
duration = tv.EpisodeRunTime[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
return &models.UnifiedContent{
|
unified := &models.UnifiedContent{
|
||||||
ID: strconv.Itoa(tv.ID),
|
ID: strconv.Itoa(tv.ID),
|
||||||
SourceID: "tmdb_" + strconv.Itoa(tv.ID),
|
SourceID: "tmdb_" + strconv.Itoa(tv.ID),
|
||||||
Title: tv.Name,
|
Title: tv.Name,
|
||||||
@@ -148,6 +148,24 @@ func MapTMDBTVToUnified(tv *models.TVShow, external *models.ExternalIDs) *models
|
|||||||
IMDbID: imdb,
|
IMDbID: imdb,
|
||||||
ExternalIDs: ext,
|
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 {
|
func MapTMDBMultiToUnifiedItems(m *models.MultiSearchResponse) []models.UnifiedSearchItem {
|
||||||
|
|||||||
Reference in New Issue
Block a user