diff --git a/README.md b/README.md index a567777..6c70de7 100755 --- a/README.md +++ b/README.md @@ -204,6 +204,14 @@ Beside some other characters, spaces will be replaced by underscores. There's no Just make sure your working directory is the one you have the music files in. +## Return codes + +- `0` - Success +- `1` - Unknown error +- `2` - Command line error (e.g. invalid args) +- `10` - Invalid playlist URL +- `11` - Playlist not found + ## Running tests ``` diff --git a/spotdl.py b/spotdl.py index aa7ca58..6c6c000 100755 --- a/spotdl.py +++ b/spotdl.py @@ -337,13 +337,19 @@ def grab_playlist(playlist): else: splits = playlist.split(':') - username = splits[-3] + try: + username = splits[-3] + except IndexError: + # Wrong format, in either case + print('The provided playlist URL is not in a recognized format!') + sys.exit(10) playlist_id = splits[-1] try: write_playlist(username, playlist_id) except spotipy.client.SpotifyException: print('Unable to find playlist') print('Make sure the playlist is set to publicly visible and then try again') + sys.exit(11) def grab_album(album):