mirror of
https://github.com/crunchy-labs/crunchy-cli.git
synced 2026-01-21 12:12:00 -06:00
Added caching
This commit is contained in:
parent
0e8738a304
commit
a5d9696c9c
5 changed files with 72 additions and 1 deletions
10
stream.go
10
stream.go
|
|
@ -11,6 +11,8 @@ import (
|
|||
type Stream struct {
|
||||
crunchy *Crunchyroll
|
||||
|
||||
children []*Format
|
||||
|
||||
HardsubLocale LOCALE
|
||||
AudioLocale LOCALE
|
||||
Subtitles []*Subtitle
|
||||
|
|
@ -35,6 +37,10 @@ func StreamsFromID(crunchy *Crunchyroll, id string) ([]*Stream, error) {
|
|||
|
||||
// Formats returns all formats which are available for the stream
|
||||
func (s *Stream) Formats() ([]*Format, error) {
|
||||
if s.children != nil {
|
||||
return s.children, nil
|
||||
}
|
||||
|
||||
resp, err := s.crunchy.Client.Get(s.streamURL)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
@ -57,6 +63,10 @@ func (s *Stream) Formats() ([]*Format, error) {
|
|||
Subtitles: s.Subtitles,
|
||||
})
|
||||
}
|
||||
|
||||
if s.crunchy.cache {
|
||||
s.children = formats
|
||||
}
|
||||
return formats, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue