Spotipy: How do I search by both artist and song
Given a song title and an artist name, I am trying to find the correct song using Spotipy. However, I do not see a way to search by both song title and artist: it's either one or the other:
sp.search(q="Money", type="track", limit=10)
sp.search(q="Pink Floyd", type="artist", limit=10)
The problem with this is that I get a bunch of irrelevant results, especially if I search by track(example: top result for money is "Rent Money" by Future not "Money" by Pink Floyd). I could extend the limit and filter out irrelevant results, but considering I'll be doing this on a large scale, I'd rather just query Spotify correctly, take the first result, and move on. Is there any way to query on both track name and artist at the same time using Spotipy?
Try looking at https://developer.spotify.com/web-api/search-item/
I think that you're misunderstanding type. I always want to return a track list so type is "track". In other words this defines the type of entities to be returned.
The query filter can be completely generic like "Money" or can be focussed to certain parameters like "artist:Floyd track:Money". This can be immensely powerful as you can look at albums, date fields, popularity and all sorts.
I commonly use let q = String.init(format:"artist:%@ track:%@",artistName,trackName)
Don't forget to %-encode the string!
链接地址: http://www.djcxy.com/p/55602.html上一篇: 查询Spotify API的结果与Web客户端中的相同查询不同
下一篇: 点子:我如何通过艺术家和歌曲进行搜索