Skip to content

Commit

Permalink
feat: Add SponsorBlock and YouTube query debug logs
Browse files Browse the repository at this point in the history
  • Loading branch information
gabe565 committed Aug 30, 2023
1 parent b95eeac commit bf613ee
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions internal/sponsorblock/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"errors"
"fmt"
"io"
"log/slog"
"net/http"
"net/url"
"path"
Expand Down Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion internal/youtube/youtube.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"log/slog"

"github.com/gabe565/castsponsorskip/internal/config"
"google.golang.org/api/option"
Expand All @@ -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()
Expand Down

0 comments on commit bf613ee

Please sign in to comment.