From 9185e7c8d5dc50925db86c28893ed3f1ea2b4f88 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Wed, 6 Feb 2013 19:34:01 +1300 Subject: [PATCH] Added support for Spotify album and artist links. --- plugins/spotify.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/plugins/spotify.py b/plugins/spotify.py index 33bf83f..83b61e1 100644 --- a/plugins/spotify.py +++ b/plugins/spotify.py @@ -11,7 +11,13 @@ spotify_re = (r'(open\.spotify\.com\/(track|album|artist|user)\/' @hook.regex(*spotify_re) def spotify_url(match): spotify_type = match.group(2) + print spotify_type spotify_id = match.group(3) url = gateway.format(spotify_type, spotify_id) - track = spotimeta.lookup(url) - return "{} - {}".format(track["result"]["artist"]["name"], track["result"]["name"]) \ No newline at end of file + data = spotimeta.lookup(url) + 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"]) \ No newline at end of file