-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
library: Fail nicely on lookups when offline
- Loading branch information
Showing
2 changed files
with
29 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,17 +30,22 @@ def lookup(self, uri): | |
logger.info('Failed to lookup "%s": %s', uri, exc) | ||
return [] | ||
|
||
if sp_link.type is spotify.LinkType.TRACK: | ||
return list(self._lookup_track(sp_link)) | ||
elif sp_link.type is spotify.LinkType.ALBUM: | ||
return list(self._lookup_album(sp_link)) | ||
elif sp_link.type is spotify.LinkType.ARTIST: | ||
return list(self._lookup_artist(sp_link)) | ||
elif sp_link.type is spotify.LinkType.PLAYLIST: | ||
return list(self._lookup_playlist(sp_link)) | ||
else: | ||
logger.info( | ||
'Failed to lookup "%s": Cannot handle %r', uri, sp_link.type) | ||
try: | ||
if sp_link.type is spotify.LinkType.TRACK: | ||
return list(self._lookup_track(sp_link)) | ||
elif sp_link.type is spotify.LinkType.ALBUM: | ||
return list(self._lookup_album(sp_link)) | ||
elif sp_link.type is spotify.LinkType.ARTIST: | ||
return list(self._lookup_artist(sp_link)) | ||
elif sp_link.type is spotify.LinkType.PLAYLIST: | ||
return list(self._lookup_playlist(sp_link)) | ||
else: | ||
logger.info( | ||
'Failed to lookup "%s": Cannot handle %r', | ||
uri, sp_link.type) | ||
return [] | ||
except RuntimeError as exc: | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
jodal
Author
Member
|
||
logger.info('Failed to lookup "%s": %s', uri, exc) | ||
return [] | ||
|
||
def _lookup_track(self, sp_link): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Huh, this is actually a RuntimeError, should it be something more specific to pyspotify?