5 from logging import getLogger
7 from ..mpdclient import MPD
8 from ..mpdclient import PlayerError
10 from ..plugins.internal.tags import forge_filter, control_config
12 log = getLogger('sima')
15 def tags_config_test(cli, config):
16 tags_cfg = config['tags']
17 if not control_config(tags_cfg):
19 filt = forge_filter(tags_cfg)
20 log.info('Trying tags and filter config:')
23 # Use window to limit reponse size
24 res = cli.find(filt, 'window', (0, 300))
25 except PlayerError as err:
27 print('filter error: %s' % err, file=sys.stderr)
29 artists = list({trk.albumartist for trk in res if trk.albumartist})
31 log.info('Tags config correct but got nothing from MPD\'s library')
33 log.info('Got results, here are some of the artists found:')
34 log.info('%s', ' / '.join(artists[:6]))
37 def config_test(config):
39 log.info('Trying to connect MPD: %s:%s',
40 config.get('MPD', 'host'),
41 config.get('MPD', 'port'))
44 except PlayerError as err:
45 print(err, file=sys.stderr)
47 tags_config_test(cli, config)
51 # vim: ai ts=4 sw=4 sts=4 expandtab fileencoding=utf8