mirror of
https://github.com/crunchy-labs/crunchy-cli.git
synced 2026-01-21 12:12:00 -06:00
Add available function to check if season streams are available
This commit is contained in:
parent
43be2eee14
commit
f635bf1a2e
3 changed files with 14 additions and 3 deletions
12
season.go
12
season.go
|
|
@ -70,8 +70,9 @@ func SeasonFromID(crunchy *Crunchyroll, id string) (*Season, error) {
|
|||
}
|
||||
|
||||
// AudioLocale returns the audio locale of the season.
|
||||
// Will fail if no streams are available, thus use Season.Available
|
||||
// to prevent any misleading errors.
|
||||
func (s *Season) AudioLocale() (LOCALE, error) {
|
||||
// TODO: Add a function like Episode.Available to prevent this from returning an unwanted error when the account is non-premium
|
||||
episodes, err := s.Episodes()
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
|
@ -79,6 +80,15 @@ func (s *Season) AudioLocale() (LOCALE, error) {
|
|||
return episodes[0].AudioLocale()
|
||||
}
|
||||
|
||||
// Available returns if downloadable streams for this season are available.
|
||||
func (s *Season) Available() (bool, error) {
|
||||
episodes, err := s.Episodes()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return episodes[0].Available(), nil
|
||||
}
|
||||
|
||||
// Episodes returns all episodes which are available for the season.
|
||||
func (s *Season) Episodes() (episodes []*Episode, err error) {
|
||||
if s.children != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue