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 episode streams are available
This commit is contained in:
parent
6c476df24e
commit
0ffae4ddda
3 changed files with 15 additions and 0 deletions
|
|
@ -112,6 +112,8 @@ func EpisodeFromID(crunchy *Crunchyroll, id string) (*Episode, error) {
|
|||
// Every episode in a season (should) have the same audio locale,
|
||||
// so if you want to get the audio locale of a season, just call
|
||||
// this method on the first episode of the season.
|
||||
// Will fail if no streams are available, thus use Available to
|
||||
// prevent any misleading errors.
|
||||
func (e *Episode) AudioLocale() (LOCALE, error) {
|
||||
streams, err := e.Streams()
|
||||
if err != nil {
|
||||
|
|
@ -120,6 +122,11 @@ func (e *Episode) AudioLocale() (LOCALE, error) {
|
|||
return streams[0].AudioLocale, nil
|
||||
}
|
||||
|
||||
// Available returns if downloadable streams for this episodes are available.
|
||||
func (e *Episode) Available() bool {
|
||||
return e.crunchy.Config.Premium || !e.IsPremiumOnly
|
||||
}
|
||||
|
||||
// GetFormat returns the format which matches the given resolution and subtitle locale.
|
||||
func (e *Episode) GetFormat(resolution string, subtitle LOCALE, hardsub bool) (*Format, error) {
|
||||
streams, err := e.Streams()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue