通常,spotipy需要跟踪ID作为要传递的参数,以便返回曲目名称.
假设我有两个列表,不是从Spotify API获得的:
艺术家
[u'Moses Sumney', u'Cherry Glazerr', u'Danny Brown', u'NxWorries']
Run Code Online (Sandbox Code Playgroud)
和他们各自的歌曲:
轨道
[u'Lonely World', u"Told You I'd Be With the Guys", u'Really Doe [ft. Kendrick Lamar, Ab-Soul, and Earl Sweatshirt]', u'Lyk Dis']
Run Code Online (Sandbox Code Playgroud)是否有可能以相反的方式做到并获得跟踪ID?
Spotipy.search()正是您所寻找的.
import spotipy
sp = spotipy.Spotify()
artist= 'Moses Sumney'
track= 'Lonely World'
track_id = sp.search(q='artist:' + artist + ' track:' + track, type='track')
Run Code Online (Sandbox Code Playgroud)
这将返回与查询匹配的歌曲列表,具体取决于搜索的精确程度取决于返回的结果数量.
| 归档时间: |
|
| 查看次数: |
885 次 |
| 最近记录: |