Skip to content

Commit

Permalink
fix: Fix YouTube API being queried multiple times if video is not found
Browse files Browse the repository at this point in the history
  • Loading branch information
gabe565 committed Sep 3, 2023
1 parent d5123c7 commit 5e94f6c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions internal/device/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,8 @@ func (d *Device) queryVideoId(castMedia *cast.Media) error {
d.logger.Warn("Video ID not found. Please set a YouTube API key.")
} else {
d.logger.Info("Video ID not found. Searching for video on YouTube...")
d.prevArtist = currArtist
d.prevTitle = currTitle
if err := util.Retry(d.ctx, 10, 500*time.Millisecond, func(try uint) (err error) {
castMedia.Media.ContentId, err = youtube.QueryVideoId(d.ctx, currArtist, currTitle)
if errors.Is(err, youtube.ErrNoVideos) || errors.Is(err, youtube.ErrNoId) {
Expand All @@ -304,8 +306,6 @@ func (d *Device) queryVideoId(castMedia *cast.Media) error {
return err
}
}
d.prevArtist = currArtist
d.prevTitle = currTitle
}
return nil
}
Expand Down

0 comments on commit 5e94f6c

Please sign in to comment.