refactor: unexport internal identifiers and fix naming nits
This commit is contained in:
@@ -7,7 +7,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
neturl "net/url"
|
||||
"net/url"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -38,7 +38,7 @@ func fetchBPM(ctx context.Context, httpClient *http.Client, artist, title, durat
|
||||
func findTrackURL(ctx context.Context, httpClient *http.Client, artist, title, duration string) (string, error) {
|
||||
const rootURL = "https://songbpm.com"
|
||||
|
||||
values := neturl.Values{}
|
||||
values := url.Values{}
|
||||
values.Add("query", fmt.Sprintf("%s %s", artist, title))
|
||||
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodPost, rootURL+"/searches", bytes.NewBufferString(values.Encode()))
|
||||
@@ -109,8 +109,8 @@ func findTrackURL(ctx context.Context, httpClient *http.Client, artist, title, d
|
||||
return rootURL + matchURL, nil
|
||||
}
|
||||
|
||||
func fetchBPMPage(ctx context.Context, httpClient *http.Client, url string) (string, error) {
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)
|
||||
func fetchBPMPage(ctx context.Context, httpClient *http.Client, pageURL string) (string, error) {
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, pageURL, nil)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
@@ -57,8 +57,8 @@ func fetchGenre(ctx context.Context, httpClient *http.Client, artist, title stri
|
||||
return formatTags(filtered), nil
|
||||
}
|
||||
|
||||
func fetchGenrePage(ctx context.Context, httpClient *http.Client, url string) (*goquery.Document, error) {
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)
|
||||
func fetchGenrePage(ctx context.Context, httpClient *http.Client, pageURL string) (*goquery.Document, error) {
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, pageURL, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ type metadataResult struct {
|
||||
warnings []string
|
||||
}
|
||||
|
||||
func fetchMetadata(httpClient *http.Client, ctx context.Context, track *deezer.Track, opts Options) metadataResult {
|
||||
func fetchMetadata(ctx context.Context, httpClient *http.Client, track *deezer.Track, opts Options) metadataResult {
|
||||
if !opts.BPM && !opts.Genre {
|
||||
return metadataResult{}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ func (d *Downloader) downloadTrack(ctx context.Context, resource deezer.Resource
|
||||
|
||||
metadataChan := make(chan metadataResult, 1)
|
||||
go func() {
|
||||
metadataChan <- fetchMetadata(d.deezerClient.Session.HTTPClient, ctx, track, opts)
|
||||
metadataChan <- fetchMetadata(ctx, d.deezerClient.Session.HTTPClient, track, opts)
|
||||
}()
|
||||
|
||||
dlCtx, cancel := context.WithTimeout(ctx, opts.Timeout)
|
||||
|
||||
Reference in New Issue
Block a user