X-Git-Url: https://git.kaliko.me/?a=blobdiff_plain;f=sima%2Flib%2Fwebserv.py;h=7609da765b5f7f820007590ef2b249ecb1df1662;hb=70bf86ca3f65a550436cdc70326cb8601f24e5a6;hp=ffd516aae82388e237015daf23114df0279ce662;hpb=1b5cfb4c9187df891bd840b51c044d72ad0077d5;p=mpd-sima.git diff --git a/sima/lib/webserv.py b/sima/lib/webserv.py index ffd516a..7609da7 100644 --- a/sima/lib/webserv.py +++ b/sima/lib/webserv.py @@ -33,7 +33,7 @@ from hashlib import md5 from .plugin import Plugin from .track import Track from .meta import Artist -from ..utils.utils import WSError +from ..utils.utils import WSError, WSNotFound def cache(func): """Caching decorator""" @@ -179,6 +179,10 @@ class WebService(Plugin): self.log.debug('Requesting {} for {!r}'.format(self.ws.name, artist)) try: [as_art.append(art) for art in as_artists] + except WSNotFound as err: + if artist.mbid: + return self.ws_similar_artists(Artist(name=artist.name)) + self.log.warning('{}: {}'.format(self.ws.name, err)) except WSError as err: self.log.warning('{}: {}'.format(self.ws.name, err)) if as_art: @@ -222,6 +226,7 @@ class WebService(Plugin): return [] tolookfor = self.player.playlist[-1].Artist self.log.info('Looking for artist similar to "{}"'.format(tolookfor)) + self.log.debug(repr(tolookfor)) similar = self.ws_similar_artists(tolookfor) if not similar: self.log.info('Got nothing from {0}!'.format(self.ws.name)) @@ -248,7 +253,7 @@ class WebService(Plugin): if ret & queued_artists: self.log.debug('Removing already queued artist: {0}'.format(ret & queued_artists)) ret = ret - queued_artists - if self.player.current.Artist in ret: + if self.player.current and self.player.current.Artist in ret: self.log.debug('Removing current artist: {0}'.format(self.player.current.Artist)) ret = ret - {self.player.current.Artist} # Move around similars items to get in unplayed|not recently played