-
Notifications
You must be signed in to change notification settings - Fork 3
/
series.go
69 lines (64 loc) · 2.25 KB
/
series.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package tvdb
// Series struct store all data of an episode.
type Series struct {
Added string `json:"added"`
AddedBy int `json:"addedBy"`
AirsDayOfWeek string `json:"airsDayOfWeek"`
AirsTime string `json:"airsTime"`
Aliases []string `json:"aliases"`
Banner string `json:"banner"`
FirstAired string `json:"firstAired"`
Genre []string `json:"genre"`
ID int `json:"id"`
ImdbID string `json:"imdbId"`
LastUpdated int `json:"lastUpdated"`
Network string `json:"network"`
NetworkID string `json:"networkId"`
Overview string `json:"overview"`
Rating string `json:"rating"`
Runtime string `json:"runtime"`
SeriesID string `json:"seriesId"`
SeriesName string `json:"seriesName"`
SiteRating float32 `json:"siteRating"`
SiteRatingCount int `json:"siteRatingCount"`
Status string `json:"status"`
Zap2itID string `json:"zap2itId"`
// Slice of the series actors, filled with GetSeriesActors method.
Actors []Actor
// Slice of the series episodes, filled with GetSeriesEpisodes method.
Episodes []Episode
// Slice of the series summary, filled with GetSeriesSummary method.
Summary Summary
// Slice of the series images.
Images []Image
}
// Empty verify if the series's fields are empty and don't are filled by an api
// response.
func (s *Series) Empty() bool {
return s.ID == 0 && s.SeriesName == ""
}
// BannerURL returns the image banner url of the series.
func (s *Series) BannerURL() string {
return ImageURL(s.Banner)
}
// GetSeasonEpisodes select and returns the episodes of the series by season
// number.
func (s *Series) GetSeasonEpisodes(season int) []*Episode {
episodes := make([]*Episode, 0)
for i := range s.Episodes {
if s.Episodes[i].AiredSeason == season {
episodes = append(episodes, &s.Episodes[i])
}
}
return episodes
}
// GetEpisode select and returns a specific episode of the series by season and
// episode number.
func (s *Series) GetEpisode(season, number int) *Episode {
for i := range s.Episodes {
if s.Episodes[i].AiredSeason == season && s.Episodes[i].AiredEpisodeNumber == number {
return &s.Episodes[i]
}
}
return nil
}