Skip to content

Commit

Permalink
Fix no-results output
Browse files Browse the repository at this point in the history
  • Loading branch information
blha303 committed Nov 17, 2014
1 parent 7bb00d1 commit a67c3de
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions plugins/spotify.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ def spotify(inp):
try:
data = http.get_json("https://api.spotify.com/v1/search", type="track", limit="1", q=inp.strip())
item = data["tracks"]["items"][0]
except IndexError:
return "Could not find track: no results."
except Exception as e:
return "Could not get information: {}".format(e)
return format_track(item)
Expand All @@ -69,6 +71,8 @@ def spotify_album(inp):
try:
data = http.get_json("https://api.spotify.com/v1/search", type="album", limit="1", q=inp.strip())
item = data["albums"]["items"][0]
except IndexError:
return "Could not find track: no results."
except Exception as e:
return "Could not get information: {}".format(e)
return format_album(item)
Expand All @@ -84,6 +88,8 @@ def spotify_artist(inp):
try:
data = http.get_json("https://api.spotify.com/v1/search", type="artist", limit="1", q=inp.strip())
item = data["artists"]["items"][0]
except IndexError:
return "Could not find track: no results."
except Exception as e:
return "Could not get information: {}".format(e)
return format_artist(item)
Expand Down

0 comments on commit a67c3de

Please sign in to comment.