Return codes depicting success/failure (#164)

* Add error codes for fetch playlist failures

* Add return codes to README.md
This commit is contained in:
Ritiek Malhotra
2017-11-30 10:44:46 +05:30
committed by GitHub
parent d39272d6a2
commit 6075a829e5
2 changed files with 15 additions and 1 deletions

View File

@@ -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
```

View File

@@ -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):