From c27879edbc5d5a3dacc09fc7f853a29cbcd8dacc Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Wed, 28 Dec 2016 11:59:14 -0500 Subject: [PATCH] Slight code formatting tweaks for #2349 --- beetsplug/acousticbrainz.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/beetsplug/acousticbrainz.py b/beetsplug/acousticbrainz.py index 725c55089..93647170b 100644 --- a/beetsplug/acousticbrainz.py +++ b/beetsplug/acousticbrainz.py @@ -107,7 +107,10 @@ class AcousticPlugin(plugins.BeetsPlugin): def __init__(self): super(AcousticPlugin, self).__init__() - self.config.add({'auto': True, 'force': False}) + self.config.add({ + 'auto': True, + 'force': False, + }) if self.config['auto']: self.register_listener('import_task_files', @@ -116,17 +119,17 @@ class AcousticPlugin(plugins.BeetsPlugin): def commands(self): cmd = ui.Subcommand('acousticbrainz', help=u"fetch metadata from AcousticBrainz") - - def func(lib, opts, args): - items = lib.items(ui.decargs(args)) - self._fetch_info(items, ui.should_write(), - opts.force_refetch or self.config['force']) cmd.parser.add_option( u'-f', u'--force', dest='force_refetch', action='store_true', default=False, help=u're-download data when already present' ) + def func(lib, opts, args): + items = lib.items(ui.decargs(args)) + self._fetch_info(items, ui.should_write(), + opts.force_refetch or self.config['force']) + cmd.func = func return [cmd] @@ -162,13 +165,17 @@ class AcousticPlugin(plugins.BeetsPlugin): """Fetch additional information from AcousticBrainz for the `item`s. """ for item in items: + # If we're not forcing re-downloading for all tracks, check + # whether the data is already present. We use one + # representative field name to check for previously fetched + # data. if not force: mood_str = item.get('mood_acoustic', u'') if mood_str: - self._log.info(u'Already set acoustic\ - brainz tags for {} ', item) + self._log.info(u'data already present for: {}', item) continue + # We can only fetch data for tracks with MBIDs. if not item.mb_trackid: continue