File tree Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -54,6 +54,8 @@ def spotify(inp):
5454 try :
5555 data = http .get_json ("https://api.spotify.com/v1/search" , type = "track" , limit = "1" , q = inp .strip ())
5656 item = data ["tracks" ]["items" ][0 ]
57+ except IndexError :
58+ return "Could not find track: no results."
5759 except Exception as e :
5860 return "Could not get information: {}" .format (e )
5961 return format_track (item )
@@ -69,6 +71,8 @@ def spotify_album(inp):
6971 try :
7072 data = http .get_json ("https://api.spotify.com/v1/search" , type = "album" , limit = "1" , q = inp .strip ())
7173 item = data ["albums" ]["items" ][0 ]
74+ except IndexError :
75+ return "Could not find track: no results."
7276 except Exception as e :
7377 return "Could not get information: {}" .format (e )
7478 return format_album (item )
@@ -84,6 +88,8 @@ def spotify_artist(inp):
8488 try :
8589 data = http .get_json ("https://api.spotify.com/v1/search" , type = "artist" , limit = "1" , q = inp .strip ())
8690 item = data ["artists" ]["items" ][0 ]
91+ except IndexError :
92+ return "Could not find track: no results."
8793 except Exception as e :
8894 return "Could not get information: {}" .format (e )
8995 return format_artist (item )
You can’t perform that action at this time.
0 commit comments