From 7be803d485ca88994b1169b24e6c5adf88236c36 Mon Sep 17 00:00:00 2001 From: bytedream Date: Wed, 18 May 2022 21:54:31 +0200 Subject: [PATCH] Add extended error message if account is non-premium --- url.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/url.go b/url.go index 0f5bb25..86874eb 100644 --- a/url.go +++ b/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