From 5e94f6c7378fe806218b961af01ae28a62e1789d Mon Sep 17 00:00:00 2001 From: Gabe Cook Date: Sun, 3 Sep 2023 01:14:56 -0500 Subject: [PATCH] fix: Fix YouTube API being queried multiple times if video is not found --- internal/device/watch.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/device/watch.go b/internal/device/watch.go index 5e1c4f0..a48305c 100644 --- a/internal/device/watch.go +++ b/internal/device/watch.go @@ -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) { @@ -304,8 +306,6 @@ func (d *Device) queryVideoId(castMedia *cast.Media) error { return err } } - d.prevArtist = currArtist - d.prevTitle = currTitle } return nil }