mirror of
https://github.com/crunchy-labs/crunchy-cli.git
synced 2026-01-21 04:02:00 -06:00
Added support for beta urls in EpisodeStructure.GetEpisodeByURL(...)
This commit is contained in:
parent
20cdb64f54
commit
8587cd44ac
1 changed files with 13 additions and 0 deletions
|
|
@ -501,6 +501,19 @@ func (es *EpisodeStructure) GetEpisodeByFormat(format *crunchyroll.Format) (*cru
|
|||
func (es *EpisodeStructure) GetEpisodeByURL(url string) (*crunchyroll.Episode, error) {
|
||||
_, title, episodeNumber, _, ok := crunchyroll.ParseEpisodeURL(url)
|
||||
if !ok {
|
||||
if episodeid, ok := crunchyroll.ParseBetaEpisodeURL(url); ok {
|
||||
episodes, err := es.Episodes()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, episode := range episodes {
|
||||
if episode.ID == episodeid {
|
||||
return episode, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil, errors.New("invalid url")
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue