Python spotipy.SpotifyException() Examples
The following are 7
code examples of spotipy.SpotifyException().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
spotipy
, or try the search function
.
Example #1
Source File: spotify_plugs.py From pbl with MIT License | 6 votes |
def _get_more_tracks(self): fields = self.uri.split(':') if len(fields) == 5: _,_,user,_,playlist_id = fields else: _,_,playlist_id = fields try: results = _get_spotify().playlist_tracks(playlist_id, limit=self.limit, offset=self.next_offset) except spotipy.SpotifyException as e: raise engine.PBLException(self, e.msg) self.total = results['total'] for item in results['items']: track = item['track'] if track and 'id' in track: self.tracks.append(track['id']) _add_track(self.name, track) self.next_offset += self.limit
Example #2
Source File: spotify_plugs.py From pbl with MIT License | 6 votes |
def next_track(self): if self.buffer == None: self.buffer = [] try: results = _get_spotify().tracks(self.uris) except spotipy.SpotifyException as e: raise engine.PBLException(self, e.msg) for track in results['tracks']: if track and 'id' in track: self.buffer.append(track['id']) _add_track(self.name, track) else: raise engine.PBLException(self, 'bad track') if len(self.buffer) > 0: return self.buffer.pop(0) else: return None
Example #3
Source File: spotify_plugs.py From pbl with MIT License | 6 votes |
def next_track(self): if self.buffer == None: if self.title != None and self.uri == None: self.uri = self._get_uri_from_artist_title(self.artist, self.title) self.buffer = [] if self.uri: _,_,id = self.uri.split(':') try: results = _get_spotify().album_tracks(id) except spotipy.SpotifyException as e: raise engine.PBLException(self, e.msg) for track in results['items']: if track and 'id' in track: self.buffer.append(track['id']) _add_track(self.name, track) else: raise engine.PBLException(self, "Can't find that album"); if len(self.buffer) > 0: return self.buffer.pop(0) else: return None
Example #4
Source File: spotify_plugs.py From pbl with MIT License | 6 votes |
def next_track(self): if self.buffer == None: self.buffer = [] if self.uri == None: self.uri = _find_artist_by_name(_get_spotify(), self.artist_name) if self.uri != None: _,_,id = self.uri.split(':') try: results = _get_spotify().artist_top_tracks(id) except spotipy.SpotifyException as e: raise engine.PBLException(self, e.msg) for track in results['tracks']: if track and 'id' in track: self.buffer.append(track['id']) _add_track(self.name, track) else: raise engine.PBLException(self, "Can't find that artist") if len(self.buffer) > 0: return self.buffer.pop(0) else: return None
Example #5
Source File: spotify_plugs.py From pbl with MIT License | 5 votes |
def next_track(self): if self.uri == None: try: track = _find_track_by_name(_get_spotify(), self.title) if track and 'id' in track: _add_track(self.name, track) self.uri = track['id'] return self.uri else: raise engine.PBLException(self, "Can't find that track") except spotipy.SpotifyException as e: raise engine.PBLException(self, e.msg) else: return None
Example #6
Source File: library.py From mopidy-spotify-web with Apache License 2.0 | 5 votes |
def get_top_tracks_from_web_api(sp, uri): if sp is None: return [] try: results = sp.artist_top_tracks(get_artist_from_uri(uri)) logger.debug('Processing spotify top get tracks result') arr = [Ref.track(uri=track['uri'], name=track['name']) for track in results['tracks']] except spotipy.SpotifyException as e: logger.error('Spotipy error(%s): %s', e.code, e.msg) return arr
Example #7
Source File: library.py From mopidy-spotify-web with Apache License 2.0 | 5 votes |
def get_from_sp(sp, get_next_items, process_results, uri=None): if sp is None: return [] try: arr = get_from_sp_while_next(sp, get_next_items, process_results, uri) except spotipy.SpotifyException as e: logger.error('Spotipy error(%s): %s', e.code, e.msg) return arr