}
self._cache['artists'] = frozenset(self._client.list('artist'))
+ @blacklist(track=True)
def find_track(self, artist, title=None):
#return getattr(self, 'find')('artist', artist, 'title', title)
if title:
def queue(self):
to_add = list()
for plugin in self.plugins:
- pl_callback = getattr(plugin, 'callback_need_track')()
+ pl_callback = getattr(plugin, 'callback_need_track')()
if pl_callback:
to_add.extend(pl_callback)
if not to_add:
self.log.warning('Queue plugins returned nothing!')
for plugin in self.plugins:
- pl_callback = getattr(plugin, 'callback_need_track_fb')()
+ pl_callback = getattr(plugin, 'callback_need_track_fb')()
if pl_callback:
to_add.extend(pl_callback)
for track in to_add:
except PlayerUnHandledError as err:
#TODO: unhandled Player exceptions
self.log.warning('Unhandled player exception: {}'.format(err))
- del(self.player)
+ del self.player
self.player = PlayerClient()
time.sleep(10)
except PlayerError as err:
self.log.warning('Player error: %s' % err)
self.reconnect_player()
- del(self.changed)
+ del self.changed
def loop(self):
"""Dispatching callbacks to plugins
sima: sima.core.Sima instance
source: ['internal', 'contrib']
"""
- if not sima.config.get('sima', source ):
+ if not sima.config.get('sima', source):
return
logger = logging.getLogger('sima')
for plugin in sima.config.get('sima', source).split(','):
+# pylint: disable=missing-docstring
"SELECT artist FROM albums")] +
[row[0] for row in connection.execute(
"SELECT artist FROM tracks")])
- orphans = [ (orphan,) for orphan in artists_ids - artist_2_artist_ids ]
+ orphans = [(orphan,) for orphan in artists_ids - artist_2_artist_ids]
connection.executemany('DELETE FROM artists WHERE id = (?);', orphans)
if not with_connection:
connection.commit()
"""SELECT albums.id FROM albums
LEFT JOIN tracks ON albums.id = tracks.album
WHERE tracks.album IS NULL""")])
- orphans = [ (orphan,) for orphan in orphan_black_ids & orphan_tracks_ids ]
+ orphans = [(orphan,) for orphan in orphan_black_ids & orphan_tracks_ids]
connection.executemany('DELETE FROM albums WHERE id = (?);', orphans)
if not with_connection:
connection.commit()
"""SELECT tracks.id FROM tracks
LEFT JOIN black_list ON tracks.id = black_list.track
WHERE black_list.track IS NULL""")])
- orphans = [ (orphan,) for orphan in hist_orphan_ids & black_list_orphan_ids ]
+ orphans = [(orphan,) for orphan in hist_orphan_ids & black_list_orphan_ids]
connection.executemany('DELETE FROM tracks WHERE id = (?);', orphans)
if not with_connection:
connection.commit()
title = song.get('title')
if title not in titles:
titles.append(title)
- yield Track(title=title, **artist )
+ yield Track(title=title, **artist)
# VIM MODLINE
def _cleanup_cache(self):
"""Avoid bloated cache
"""
- for _ , val in self._cache.items():
+ for _, val in self._cache.items():
if isinstance(val, dict):
while len(val) > 150:
val.popitem()
if trk[0] not in art_in_hist:
art_in_hist.append(trk[0])
art_in_hist.reverse()
- art_not_in_hist = [ ar for ar in alist if ar not in art_in_hist ]
+ art_not_in_hist = [ar for ar in alist if ar not in art_in_hist]
random.shuffle(art_not_in_hist)
art_not_in_hist.extend(art_in_hist)
self.log.info('{}'.format(
self.log.info('Looking for an album to add for "%s"...' % artist)
albums = self.player.find_albums(artist)
# str conversion while Album type is not propagated
- albums = [ str(album) for album in albums]
+ albums = [str(album) for album in albums]
if albums:
self.log.debug('Albums candidate: {0:s}'.format(
' / '.join(albums)))
self.log.debug('Trying to find titles to add for "{}"'.format(
artist))
found = self.player.find_track(artist)
+ if not found:
+ self.log.debug('Found nothing to queue for {0}'.format(artist))
+ continue
# find tracks not in history for artist
self.filter_track(found)
if len(self.to_add) == nbtracks_target:
"""Get some tracks for top track queue mode
"""
artists = self.get_local_similar_artists()
- nbtracks_target = self.plugin_conf.getint('track_to_add')
self.find_top(artists)
for track in self.to_add:
self.log.info('{1} candidates: {0!s}'.format(track, self.ws.name))
+# pylint: disable=missing-docstring
+# pylint: disable=missing-docstring
+# pylint: disable=missing-docstring
+# pylint: disable=missing-docstring
duration = self.daemon.config.getint('sima', 'history_duration')
tracks_from_db = self.daemon.sdb.get_history(duration=duration)
# Construct Track() objects list from database history
- artists = [ tr[-1] for tr in tracks_from_db ]
+ artists = [tr[-1] for tr in tracks_from_db]
return set(artists)
def callback_need_track_fb(self):
elif self.mode == 'pure':
art = random.choice(artists)
self.log.debug('Random art: {}'.format(art))
- trk = random.choice(self.player.find_track(art))
+ trk = random.choice(self.player.find_track(art))
self.log.info('random fallback ({}): {}'.format(self.mode, trk))
return trk
elif self.startopt.get('var_dir'):
# If var folder is provided via CLI set data_dir accordingly
data_dir = join(self.startopt.get('var_dir'))
- elif (homedir and isdir(homedir) and homedir not in ['/']):
+ elif homedir and isdir(homedir) and homedir not in ['/']:
data_dir = join(homedir, '.local', 'share', DIRNAME)
else:
self.log.error('Can\'t find a suitable location for data folder (XDG_DATA_HOME)')
pass
elif environ.get('XDG_CONFIG_HOME'):
conf_dir = join(environ.get('XDG_CONFIG_HOME'), DIRNAME)
- elif (homedir and isdir(homedir) and homedir not in ['/']):
+ elif homedir and isdir(homedir) and homedir not in ['/']:
conf_dir = join(homedir, '.config', DIRNAME)
# Create conf_dir if necessary
if not isdir(conf_dir):