mirror of
https://github.com/crunchy-labs/crunchy-cli.git
synced 2026-01-21 04:02:00 -06:00
Deprecated find video and optimized find episode (as result of #22)
This commit is contained in:
parent
e2f42493ac
commit
2e9ce3cf52
1 changed files with 18 additions and 10 deletions
|
|
@ -306,6 +306,10 @@ func (c *Crunchyroll) Search(query string, limit uint) (s []*Series, m []*Movie,
|
|||
// FindVideoByName finds a Video (Season or Movie) by its name.
|
||||
// Use this in combination with ParseVideoURL and hand over the corresponding results
|
||||
// to this function.
|
||||
//
|
||||
// Deprecated: Use Search instead. The first result sometimes isn't the correct one
|
||||
// so this function is inaccurate in some cases.
|
||||
// See https://github.com/ByteDream/crunchyroll-go/issues/22 for more information.
|
||||
func (c *Crunchyroll) FindVideoByName(seriesName string) (Video, error) {
|
||||
s, m, err := c.Search(seriesName, 1)
|
||||
if err != nil {
|
||||
|
|
@ -324,16 +328,18 @@ func (c *Crunchyroll) FindVideoByName(seriesName string) (Video, error) {
|
|||
// Use this in combination with ParseEpisodeURL and hand over the corresponding results
|
||||
// to this function.
|
||||
func (c *Crunchyroll) FindEpisodeByName(seriesName, episodeTitle string) ([]*Episode, error) {
|
||||
video, err := c.FindVideoByName(seriesName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
seasons, err := video.(*Series).Seasons()
|
||||
series, _, err := c.Search(seriesName, 5)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var matchingEpisodes []*Episode
|
||||
for _, s := range series {
|
||||
seasons, err := s.Seasons()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, season := range seasons {
|
||||
episodes, err := season.Episodes()
|
||||
if err != nil {
|
||||
|
|
@ -345,6 +351,8 @@ func (c *Crunchyroll) FindEpisodeByName(seriesName, episodeTitle string) ([]*Epi
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return matchingEpisodes, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue