Added support for Spotify album and artist links.
This commit is contained in:
parent
6538541ec7
commit
9185e7c8d5
1 changed files with 8 additions and 2 deletions
|
@ -11,7 +11,13 @@ spotify_re = (r'(open\.spotify\.com\/(track|album|artist|user)\/'
|
||||||
@hook.regex(*spotify_re)
|
@hook.regex(*spotify_re)
|
||||||
def spotify_url(match):
|
def spotify_url(match):
|
||||||
spotify_type = match.group(2)
|
spotify_type = match.group(2)
|
||||||
|
print spotify_type
|
||||||
spotify_id = match.group(3)
|
spotify_id = match.group(3)
|
||||||
url = gateway.format(spotify_type, spotify_id)
|
url = gateway.format(spotify_type, spotify_id)
|
||||||
track = spotimeta.lookup(url)
|
data = spotimeta.lookup(url)
|
||||||
return "{} - {}".format(track["result"]["artist"]["name"], track["result"]["name"])
|
if spotify_type == "track":
|
||||||
|
return "Spotify Track: {} - {}".format(data["result"]["artist"]["name"], data["result"]["name"])
|
||||||
|
elif spotify_type == "artist":
|
||||||
|
return "Spotify Artist: {}".format(data["result"]["name"])
|
||||||
|
elif spotify_type == "album":
|
||||||
|
return "Spotify Album: {} - {}".format(data["result"]["artist"]["name"], data["result"]["name"])
|
Reference in a new issue