From bf613eea22be9b9a77c75e9ddf185ff10d8013d6 Mon Sep 17 00:00:00 2001 From: Gabe Cook Date: Wed, 30 Aug 2023 18:20:18 -0500 Subject: [PATCH] feat: Add SponsorBlock and YouTube query debug logs --- internal/sponsorblock/query.go | 2 ++ internal/youtube/youtube.go | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/sponsorblock/query.go b/internal/sponsorblock/query.go index fd204f7..ae7e203 100644 --- a/internal/sponsorblock/query.go +++ b/internal/sponsorblock/query.go @@ -8,6 +8,7 @@ import ( "errors" "fmt" "io" + "log/slog" "net/http" "net/url" "path" @@ -54,6 +55,7 @@ func QuerySegments(ctx context.Context, id string) ([]Segment, error) { u.Path = path.Join("api", "skipSegments", checksum[:4]) u.RawQuery = query.Encode() + slog.Debug("Request segments", "url", u.String()) req, err := http.NewRequest(http.MethodGet, u.String(), nil) if err != nil { return nil, err diff --git a/internal/youtube/youtube.go b/internal/youtube/youtube.go index 4ff55ec..bb5c006 100644 --- a/internal/youtube/youtube.go +++ b/internal/youtube/youtube.go @@ -4,6 +4,7 @@ import ( "context" "errors" "fmt" + "log/slog" "github.com/gabe565/castsponsorskip/internal/config" "google.golang.org/api/option" @@ -29,8 +30,10 @@ func QueryVideoId(ctx context.Context, artist, title string) (string, error) { return "", ErrNotConnected } + query := fmt.Sprintf(`%q+intitle:%q`, artist, title) + slog.Debug("Searching for video ID", "query", query) response, err := service.Search.List([]string{"id"}). - Q(fmt.Sprintf(`%q+intitle:%q`, artist, title)). + Q(query). MaxResults(1). Context(ctx). Do()