mirror of
https://github.com/crunchy-labs/crunchy-cli.git
synced 2026-01-21 12:12:00 -06:00
Add extended error message if account is non-premium
This commit is contained in:
parent
f635bf1a2e
commit
7be803d485
1 changed files with 13 additions and 1 deletions
14
url.go
14
url.go
|
|
@ -13,6 +13,7 @@ func (c *Crunchyroll) ExtractEpisodesFromUrl(url string, audio ...LOCALE) ([]*Ep
|
|||
}
|
||||
|
||||
var eps []*Episode
|
||||
var notAvailableContinue bool
|
||||
|
||||
if series != nil {
|
||||
seasons, err := series.Seasons()
|
||||
|
|
@ -21,6 +22,12 @@ func (c *Crunchyroll) ExtractEpisodesFromUrl(url string, audio ...LOCALE) ([]*Ep
|
|||
}
|
||||
for _, season := range seasons {
|
||||
if audio != nil {
|
||||
if available, err := season.Available(); err != nil {
|
||||
return nil, err
|
||||
} else if !available {
|
||||
notAvailableContinue = true
|
||||
continue
|
||||
}
|
||||
|
||||
locale, err := season.AudioLocale()
|
||||
if err != nil {
|
||||
|
|
@ -53,6 +60,7 @@ func (c *Crunchyroll) ExtractEpisodesFromUrl(url string, audio ...LOCALE) ([]*Ep
|
|||
// if no episode streams are available, calling episode.AudioLocale
|
||||
// will result in an unwanted error
|
||||
if !episode.Available() {
|
||||
notAvailableContinue = true
|
||||
continue
|
||||
}
|
||||
locale, err := episode.AudioLocale()
|
||||
|
|
@ -77,7 +85,11 @@ func (c *Crunchyroll) ExtractEpisodesFromUrl(url string, audio ...LOCALE) ([]*Ep
|
|||
}
|
||||
|
||||
if len(eps) == 0 {
|
||||
return nil, fmt.Errorf("could not find any matching episode")
|
||||
if notAvailableContinue {
|
||||
return nil, fmt.Errorf("could not find any matching episode which is accessable with an non-premium account")
|
||||
} else {
|
||||
return nil, fmt.Errorf("could not find any matching episode")
|
||||
}
|
||||
}
|
||||
|
||||
return eps, nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue