diff --git a/beetsplug/acousticbrainz.py b/beetsplug/acousticbrainz.py index 138fd88099..725c55089d 100644 --- a/beetsplug/acousticbrainz.py +++ b/beetsplug/acousticbrainz.py @@ -107,7 +107,8 @@ class AcousticPlugin(plugins.BeetsPlugin): def __init__(self): super(AcousticPlugin, self).__init__() - self.config.add({'auto': True}) + self.config.add({'auto': True, 'force': False}) + if self.config['auto']: self.register_listener('import_task_files', self.import_task_files) @@ -118,7 +119,13 @@ def commands(self): def func(lib, opts, args): items = lib.items(ui.decargs(args)) - self._fetch_info(items, ui.should_write()) + 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' + ) cmd.func = func return [cmd] @@ -151,10 +158,17 @@ def _get_data(self, mbid): return data - def _fetch_info(self, items, write): + def _fetch_info(self, items, write, force): """Fetch additional information from AcousticBrainz for the `item`s. """ for item in items: + if not force: + mood_str = item.get('mood_acoustic', u'') + if mood_str: + self._log.info(u'Already set acoustic\ + brainz tags for {} ', item) + continue + if not item.mb_trackid: continue diff --git a/docs/plugins/acousticbrainz.rst b/docs/plugins/acousticbrainz.rst index b66bf17def..5d72b8517a 100644 --- a/docs/plugins/acousticbrainz.rst +++ b/docs/plugins/acousticbrainz.rst @@ -8,7 +8,12 @@ The ``acousticbrainz`` plugin gets acoustic-analysis information from the Enable the ``acousticbrainz`` plugin in your configuration (see :ref:`using-plugins`) and run it by typing:: - $ beet acousticbrainz [QUERY] + $ beet acousticbrainz [-f] [QUERY] + +By default, the command will only look for acousticbrainz data when the tracks doesn't +already have it; the ``-f`` or ``--force`` switch makes it fetch acousticbrainz +for the item. If you specify a query, only matching tracks will be processed; +otherwise, the command processes every track in your library. For all tracks with a MusicBrainz recording ID, the plugin currently sets these fields: @@ -52,3 +57,6 @@ configuration file. There is one option: - **auto**: Enable AcousticBrainz during ``beet import``. Default: ``yes``. +- **force**: By default, beets will not override already fetched acousticbrainz data. To instead fetch acousticbrainz and override data, + set the ``force`` option to ``yes``. + Default: ``no``. \ No newline at end of file