from .plugin import Plugin
from .track import Track
from .meta import Artist, MetaContainer
-from ..utils.utils import WSError, WSNotFound
+from ..utils.utils import WSError, WSNotFound, WSTimeout
def cache(func):
"""Caching decorator"""
'album': self._album}
self.queue_mode = wrapper.get(self.plugin_conf.get('queue_mode'))
self.ws = None
+ self.ws_retry = 0
def _flush_cache(self):
"""
return self.ws_similar_artists(Artist(name=artist.name))
except WSNotFound as err:
self.log.debug('%s: %s', self.ws.name, err)
+ except WSTimeout as err:
+ self.log.warning('%s: %s', self.ws.name, err)
+ if self.ws_retry < 3:
+ self.ws_retry += 1
+ self.log.warning('%s: retrying', self.ws.name)
+ as_art = self.ws_similar_artists(artist)
+ else:
+ self.log.warning('%s: stop retrying', self.ws.name)
+ self.ws_retry = 0
except WSError as err:
self.log.warning('%s: %s', self.ws.name, err)
if as_art:
"""Check against local player for similar artists (recursive w/ history)
"""
if not self.player.playlist:
- return
+ return []
history = list(self.history)
# In random play mode use complete playlist to filter
if self.player.playmode.get('random'):
"""Retrieve album history"""
albums_list = set()
for trk in self.get_history(artist=artist.name):
- albums_list.add(trk[1])
+ if not trk.album:
+ continue
+ albums_list.add(trk.album)
return albums_list
def find_album(self, artists):
titles = [t for t in self.ws.get_toptrack(artist)]
except WSError as err:
self.log.warning('%s: %s', self.ws.name, err)
+ continue
for trk in titles:
found = self.player.search_track(artist, trk.title)
if found: