Removed FindVideo & FindEpisode; added FindVideoByName & FindEpisodeByName

This commit is contained in:
bytedream 2022-01-17 13:44:48 +01:00
parent 87f57bacfc
commit 6b2d7c6e27

View file

@ -280,11 +280,11 @@ func (c *Crunchyroll) Search(query string, limit uint) (s []*Series, m []*Movie,
return s, m, nil
}
// FindVideo finds a Video (Season or Movie) by a crunchyroll link
// e.g. https://www.crunchyroll.com/darling-in-the-franxx
func (c *Crunchyroll) FindVideo(seriesUrl string) (Video, error) {
if series, ok := ParseVideoURL(seriesUrl); ok {
s, m, err := c.Search(series, 1)
// 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.
func (c *Crunchyroll) FindVideoByName(seriesName string) (Video, error) {
s, m, err := c.Search(seriesName, 1)
if err != nil {
return nil, err
}
@ -297,14 +297,11 @@ func (c *Crunchyroll) FindVideo(seriesUrl string) (Video, error) {
return nil, errors.New("no series or movie could be found")
}
return nil, errors.New("invalid url")
}
// FindEpisode finds an episode by its crunchyroll link
// e.g. https://www.crunchyroll.com/darling-in-the-franxx/episode-1-alone-and-lonesome-759575
func (c *Crunchyroll) FindEpisode(url string) ([]*Episode, error) {
if series, title, _, _, ok := ParseEpisodeURL(url); ok {
video, err := c.FindVideo(fmt.Sprintf("https://www.crunchyroll.com/%s", series))
// FindEpisodeByName finds an episode by its crunchyroll series name and episode title.
// 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
}
@ -320,7 +317,7 @@ func (c *Crunchyroll) FindEpisode(url string) ([]*Episode, error) {
return nil, err
}
for _, episode := range episodes {
if episode.SlugTitle == title {
if episode.SlugTitle == episodeTitle {
matchingEpisodes = append(matchingEpisodes, episode)
}
}
@ -328,9 +325,6 @@ func (c *Crunchyroll) FindEpisode(url string) ([]*Episode, error) {
return matchingEpisodes, nil
}
return nil, errors.New("invalid url")
}
// MatchEpisode tries to extract the crunchyroll series name and title out of the given url
//
// Deprecated: Use ParseEpisodeURL instead