# description: Plugins list declaration.
# Optional plugin's configuration must be in its own section.
# For instance a "AwesomePlugin" declared here
-# gets its configuration from an "[AwesomePlugin]"
-# or "[awesomeplugin]" section (case insensitive).
+# gets its configuration from the corresponding section:
+# "[awesomeplugin]"
#
# Two plugins sources are available, internal and contrib
#
key = Value
[crop]
+## CONSUME
# type: integer
# default: unset, not cropping playlist
# description: How many played tracks to keep in the playlist.
# Leave commented to keep all tracks
#consume = 10
-[RandomFallback]
+[randomfallback]
+## FLAVOUR
# type: string
# default: sensible
# description: When no similar tracks are found, falling back to random
# * pure: complete random choice among all tracks available in the
# player media library
# * sensible: use play history to filter chosen tracks
-# * genre: chose among the same genre as current track (using genre
+# * genre: # NOT IMPLEMENTED #
+# chose among the same genre as current track (using genre
# tag). If no genre tag is available "sensible" flavour
# is used instead
#flavour=sensible
+## TRACK_TO_ADD
+# type: integer
+# description: how many tracks the plugin will try to get
+# default: 1
+#track_to_add = 1
+
+
+# EchoNest or LastFM
+#[echonest]
[lastfm]
## QUEUE_MODE # NOT COMPLETED #
# type: string
# album : Will queue whole album from similar artists.
queue_mode = track
-## SIMILARITY
-# type: integer in [0 100]
-# description: Similarity as a percentage of similarity between artists
-# (this is a last.fm metric)
-similarity = 15
-
-## DYNAMIC
+## MAX_ART
# type: integer
# description: Number of similar artist to retrieve from local media library.
# When set to something superior to zero, MPD_sima tries to get as much similar
-# artists from media library provided artists similarity is superior to
-# similarity value.
-dynamic = 10
+# artists from media library
+max_art = 10
## DEPTH
# type: integer in [1, +∞]
## SINGLE_ALBUM
# type: boolean
# scope: "track" and "top" queue modes
-# description: Prevent from queueing a track from the same album (for instance with OST).
+# description: Prevent from queueing a track from the same album (for instance
+# with OST).
single_album = false
## TRACK_TO_ADD
try:
self.player.connect()
except (PlayerError, PlayerUnHandledError) as err:
- self.log.error('Fails to connect player: {}'.format(err))
- self.shutdown()
- sys.exit(1)
+ self.log.warning('Player: {}'.format(err))
self.short_history = deque(maxlen=60)
def __get_player(self):
class RandomFallBack(Plugin):
+ """Add random track as fallback"""
def __init__(self, daemon):
super().__init__(daemon)
if not self.plugin_conf:
return
self.mode = self.plugin_conf.get('flavour', None)
- if self.mode not in ['pure', 'sensible', 'genre']:
+ if self.mode not in ['pure', 'sensible']:
self.log.warning('Bad value for flavour, '
- '{} not in ["pure", "sensible", "genre"]'.format(self.mode))
+ '"{}" not in ["pure", "sensible"]'.format(self.mode))
self.mode = 'pure'
def get_played_artist(self,):
return set(artists)
def callback_need_track_fb(self):
- art = random.choice(self.player.list('artist'))
- self.log.debug('Random art: {}'.format(art))
+ trks = list()
+ target = self.plugin_conf.getint('track_to_add')
+ while len(trks) < target:
+ trks.append(self.get_trk())
+ return trks
+
+ def get_trk(self):
+ artists = list(self.player.artists)
if self.mode == 'sensitive':
played_art = self.get_played_artist()
while 42:
- art = random.choice(self.player.list('artist'))
+ art = random.choice(artists)
if art not in played_art:
break
+ elif self.mode == 'pure':
+ art = random.choice(artists)
+ self.log.debug('Random art: {}'.format(art))
trk = random.choice(self.player.find_track(art))
self.log.info('random fallback ({}): {}'.format(self.mode, trk))
- return [trk]
+ return trk
'depth': "1",
},
'randomfallback': {
- 'flavour': "sensible", # in pure, sensible, genre
+ 'flavour': "sensible", # in pure, sensible
'track_to_add': "1",
}
}