1 # -*- coding: utf-8 -*-
3 Fetching similar artists from last.fm web services
6 # standart library import
9 # third parties componants
12 from ...lib.plugin import Plugin
13 from ...lib.track import Track
16 class RandomFallBack(Plugin):
18 def __init__(self, daemon):
19 Plugin.__init__(self, daemon)
24 def get_history(self):
25 """Constructs list of Track for already played titles.
27 duration = self.daemon.config.getint('sima', 'history_duration')
28 tracks_from_db = self.daemon.sdb.get_history(duration=duration,)
29 # Construct Track() objects list from database history
30 played_tracks = [Track(artist=tr[-1], album=tr[1], title=tr[2],
31 file=tr[3]) for tr in tracks_from_db]
34 def callback_need_track_fb(self):
35 mode = self.plugin_conf.get('flavour')
36 art = random.choice(self.player.list('artist'))
37 self.log.debug('Random art: {}'.format(art))
38 trk = random.choice(self.player.find_track(art))
39 self.log.info('random fallback ({}): {}'.format(mode, trk))
45 # vim: ai ts=4 sw=4 sts=4 expandtab