本文整理汇总了Python中spotipy.SpotifyException方法的典型用法代码示例。如果您正苦于以下问题:Python spotipy.SpotifyException方法的具体用法?Python spotipy.SpotifyException怎么用?Python spotipy.SpotifyException使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类spotipy
的用法示例。
在下文中一共展示了spotipy.SpotifyException方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _get_more_tracks
# 需要导入模块: import spotipy [as 别名]
# 或者: from spotipy import SpotifyException [as 别名]
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
示例2: next_track
# 需要导入模块: import spotipy [as 别名]
# 或者: from spotipy import SpotifyException [as 别名]
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
示例3: get_top_tracks_from_web_api
# 需要导入模块: import spotipy [as 别名]
# 或者: from spotipy import SpotifyException [as 别名]
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
示例4: get_from_sp
# 需要导入模块: import spotipy [as 别名]
# 或者: from spotipy import SpotifyException [as 别名]
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