feat(lastfm): autocorrect artist and album name misspellings when fetching info
closes #472
This commit is contained in:
@@ -52,6 +52,7 @@ func (c *Client) ArtistGetInfo(artistName string) (Artist, error) {
|
||||
params.Add("method", "artist.getInfo")
|
||||
params.Add("api_key", apiKey)
|
||||
params.Add("artist", artistName)
|
||||
params.Add("autocorrect", "1")
|
||||
|
||||
resp, err := c.makeRequest(http.MethodGet, params)
|
||||
if err != nil {
|
||||
@@ -72,6 +73,7 @@ func (c *Client) AlbumGetInfo(artistName, albumName string) (Album, error) {
|
||||
params.Add("api_key", apiKey)
|
||||
params.Add("artist", artistName)
|
||||
params.Add("album", albumName)
|
||||
params.Add("autocorrect", "1")
|
||||
|
||||
resp, err := c.makeRequest(http.MethodGet, params)
|
||||
if err != nil {
|
||||
|
||||
@@ -23,7 +23,7 @@ func TestArtistGetInfo(t *testing.T) {
|
||||
client := lastfm.NewClientCustom(
|
||||
mockclient.New(t, func(w http.ResponseWriter, r *http.Request) {
|
||||
require.Equal(t, http.MethodGet, r.Method)
|
||||
require.Equal(t, url.Values{"method": []string{"artist.getInfo"}, "api_key": []string{"apiKey1"}, "artist": []string{"Artist 1"}}, r.URL.Query())
|
||||
require.Equal(t, url.Values{"method": []string{"artist.getInfo"}, "api_key": []string{"apiKey1"}, "artist": []string{"Artist 1"}, "autocorrect": []string{"1"}}, r.URL.Query())
|
||||
|
||||
require.Equal(t, "/2.0/", r.URL.Path)
|
||||
require.Equal(t, lastfm.BaseURL, "https://"+r.Host+r.URL.Path)
|
||||
@@ -106,6 +106,7 @@ func TestArtistGetInfoClientRequestFails(t *testing.T) {
|
||||
"method": []string{"artist.getInfo"},
|
||||
"api_key": []string{"apiKey1"},
|
||||
"artist": []string{"Artist 1"},
|
||||
"autocorrect": []string{"1"},
|
||||
}, r.URL.Query())
|
||||
|
||||
require.Equal(t, "/2.0/", r.URL.Path)
|
||||
|
||||
Reference in New Issue
Block a user