X-Git-Url: http://git.kaliko.me/?a=blobdiff_plain;f=sima%2Flib%2Fwebserv.py;h=c6a906fce7f5a92091f426a18f266856e6d04d42;hb=1968c2cb249b9230f00f9749017770ab933582c0;hp=1f75c2000235919dd49c093be9f1a0c8bfa4ccbc;hpb=65c8109daf4b649eb1573cfcff18e1f0687ae22d;p=mpd-sima.git diff --git a/sima/lib/webserv.py b/sima/lib/webserv.py index 1f75c20..c6a906f 100644 --- a/sima/lib/webserv.py +++ b/sima/lib/webserv.py @@ -34,7 +34,7 @@ from hashlib import md5 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""" @@ -74,6 +74,7 @@ class WebService(Plugin): '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): """ @@ -189,6 +190,15 @@ class WebService(Plugin): 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: @@ -199,7 +209,7 @@ class WebService(Plugin): """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'): @@ -243,7 +253,7 @@ class WebService(Plugin): return [] tolookfor = self.player.playlist[-1].Artist self.log.info('Looking for artist similar to "%s"', tolookfor) - self.log.debug(repr(tolookfor)) + self.log.debug('%r', tolookfor) similar = self.ws_similar_artists(tolookfor) if not similar: self.log.info('Got nothing from %s!', self.ws.name)