Skip to content

Commit

Permalink
chore(lyrics): expose Genius FromGeniusURL method
Browse files Browse the repository at this point in the history
  • Loading branch information
streambinder committed Nov 24, 2023
1 parent 03e943b commit 5099b87
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions lyrics/genius.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,10 @@ func (composer genius) search(track *entity.Track, ctxs ...context.Context) ([]b
track, context.WithValue(ctx, contextValueLabel(contextValueLabelMainArtist), true))
}

return composer.fromGeniusURL(url, ctx)
return composer.FromGeniusURL(url, ctx)
}

func (composer genius) fromGeniusURL(url string, ctx context.Context) ([]byte, error) {
func (composer genius) FromGeniusURL(url string, ctx context.Context) ([]byte, error) {
request, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)
if err != nil {
return nil, err
Expand All @@ -139,7 +139,7 @@ func (composer genius) fromGeniusURL(url string, ctx context.Context) ([]byte, e

if response.StatusCode == 429 {
util.SleepUntilRetry(response.Header)
return composer.fromGeniusURL(url, ctx)
return composer.FromGeniusURL(url, ctx)
} else if response.StatusCode != 200 {
return nil, errors.New("cannot fetch lyrics on genius: " + response.Status)
}
Expand Down
2 changes: 1 addition & 1 deletion lyrics/genius_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ func TestGeniusLyricsNewRequestFailure(t *testing.T) {
}).Reset()

// testing
assert.EqualError(t, util.ErrOnly(genius{}.fromGeniusURL("http://genius.com/test", context.Background())), "ko")
assert.EqualError(t, util.ErrOnly(genius{}.FromGeniusURL("http://genius.com/test", context.Background())), "ko")
}

func TestGeniusLyricsNewRequestContextCanceled(t *testing.T) {
Expand Down

0 comments on commit 5099b87

Please sign in to comment.