Retry calls to Last.FM without MBIDs when if returns artist invalid (#1138)

* Call Last.FM's getInfo again without mbid when artist is not found

* Call Last.FM's getSimilar again without mbid when artist is not found

* Call Last.FM's getTopTracks again without mbid when artist is not found
This commit is contained in:
Deluan Quintão
2021-05-27 20:53:24 -04:00
committed by GitHub
parent 4e0177ee53
commit 89b12b34be
12 changed files with 288 additions and 112 deletions
+19
View File
@@ -0,0 +1,19 @@
package tests
import "net/http"
type FakeHttpClient struct {
Res http.Response
Err error
SavedRequest *http.Request
RequestCount int
}
func (c *FakeHttpClient) Do(req *http.Request) (*http.Response, error) {
c.RequestCount++
c.SavedRequest = req
if c.Err != nil {
return nil, c.Err
}
return &c.Res, nil
}
+1
View File
@@ -0,0 +1 @@
{"error":3,"message":"Invalid Method - No method with that name in this package","links":[]}
+1
View File
@@ -0,0 +1 @@
{"error":6,"message":"The artist you supplied could not be found","links":[]}
+1
View File
@@ -0,0 +1 @@
{"artist":{"name":"[unknown]","mbid":"5dfdca28-9ddc-4853-933c-8bc97d87beec","url":"https://www.last.fm/music/%5Bunknown%5D","image":[{"#text":"https://lastfm.freetls.fastly.net/i/u/34s/2a96cbd8b46e442fc41c2b86b821562f.png","size":"small"},{"#text":"https://lastfm.freetls.fastly.net/i/u/64s/2a96cbd8b46e442fc41c2b86b821562f.png","size":"medium"},{"#text":"https://lastfm.freetls.fastly.net/i/u/174s/2a96cbd8b46e442fc41c2b86b821562f.png","size":"large"},{"#text":"https://lastfm.freetls.fastly.net/i/u/300x300/2a96cbd8b46e442fc41c2b86b821562f.png","size":"extralarge"},{"#text":"https://lastfm.freetls.fastly.net/i/u/300x300/2a96cbd8b46e442fc41c2b86b821562f.png","size":"mega"},{"#text":"https://lastfm.freetls.fastly.net/i/u/300x300/2a96cbd8b46e442fc41c2b86b821562f.png","size":""}],"streamable":"0","ontour":"0","stats":{"listeners":"2774837","playcount":"137106224"},"similar":{"artist":[]},"tags":{"tag":[{"name":"mysterious","url":"https://www.last.fm/tag/mysterious"},{"name":"mistagged artist","url":"https://www.last.fm/tag/mistagged+artist"},{"name":"unknown","url":"https://www.last.fm/tag/unknown"},{"name":"rock","url":"https://www.last.fm/tag/rock"},{"name":"Soundtrack","url":"https://www.last.fm/tag/Soundtrack"}]},"bio":{"links":{"link":{"#text":"","rel":"original","href":"https://last.fm/music/%5Bunknown%5D/+wiki"}},"published":"10 Feb 2006, 20:25","summary":"[unknown] is a standard artist name used at MusicBrainz for indicating where an artist name is lacking or not provided.\n\n--\n\nFor the short-lived visual-kei band, see \n\n--\n\nThere are other artists with this or a similar spelling, usually their scrobbles will be filtered when submitted unless they are whitelisted. <a href=\"https://www.last.fm/music/%5Bunknown%5D\">Read more on Last.fm</a>","content":"[unknown] is a standard artist name used at MusicBrainz for indicating where an artist name is lacking or not provided.\n\n--\n\nFor the short-lived visual-kei band, see \n\n--\n\nThere are other artists with this or a similar spelling, usually their scrobbles will be filtered when submitted unless they are whitelisted. <a href=\"https://www.last.fm/music/%5Bunknown%5D\">Read more on Last.fm</a>. User-contributed text is available under the Creative Commons By-SA License; additional terms may apply."}}}
+1
View File
@@ -0,0 +1 @@
{"similarartists":{"artist":[],"@attr":{"artist":"[unknown]"}}}
File diff suppressed because one or more lines are too long