From 325ae6f0eea3c69a8f7a0cd394375eeb8a7d4928 Mon Sep 17 00:00:00 2001 From: Owen Parry Date: Mon, 27 Nov 2017 07:55:38 -0800 Subject: [PATCH 1/4] Add tags configuration to acousticbrainz plugin --- beetsplug/acousticbrainz.py | 18 +++++++++++++----- docs/plugins/acousticbrainz.rst | 4 +++- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/beetsplug/acousticbrainz.py b/beetsplug/acousticbrainz.py index 4291d9117..cee765bbb 100644 --- a/beetsplug/acousticbrainz.py +++ b/beetsplug/acousticbrainz.py @@ -110,6 +110,7 @@ class AcousticPlugin(plugins.BeetsPlugin): self.config.add({ 'auto': True, 'force': False, + 'tags': [] }) if self.config['auto']: @@ -164,6 +165,7 @@ class AcousticPlugin(plugins.BeetsPlugin): def _fetch_info(self, items, write, force): """Fetch additional information from AcousticBrainz for the `item`s. """ + tags = self.config['tags'].get() for item in items: # If we're not forcing re-downloading for all tracks, check # whether the data is already present. We use one @@ -183,11 +185,17 @@ class AcousticPlugin(plugins.BeetsPlugin): data = self._get_data(item.mb_trackid) if data: for attr, val in self._map_data_to_scheme(data, ABSCHEME): - self._log.debug(u'attribute {} of {} set to {}', - attr, - item, - val) - setattr(item, attr, val) + if not tags or attr in tags: + self._log.debug(u'attribute {} of {} set to {}', + attr, + item, + val) + setattr(item, attr, val) + else: + self._log.debug(u'skipping attribute {} of {} (value {}) due to config', + attr, + item, + val) item.store() if write: item.try_write() diff --git a/docs/plugins/acousticbrainz.rst b/docs/plugins/acousticbrainz.rst index bf2102790..5bd514c64 100644 --- a/docs/plugins/acousticbrainz.rst +++ b/docs/plugins/acousticbrainz.rst @@ -54,10 +54,12 @@ Configuration ------------- To configure the plugin, make a ``acousticbrainz:`` section in your -configuration file. There is one option: +configuration file. There are three options: - **auto**: Enable AcousticBrainz during ``beet import``. Default: ``yes``. - **force**: Download AcousticBrainz data even for tracks that already have it. Default: ``no``. +- **tags**: Which tags from the list above to set on your files. + Default: [] (all) From eaa84178f71427901c6d5b22e16fa70b953446c3 Mon Sep 17 00:00:00 2001 From: Owen Parry Date: Mon, 27 Nov 2017 09:11:53 -0800 Subject: [PATCH 2/4] split long line --- beetsplug/acousticbrainz.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/beetsplug/acousticbrainz.py b/beetsplug/acousticbrainz.py index cee765bbb..982f7829c 100644 --- a/beetsplug/acousticbrainz.py +++ b/beetsplug/acousticbrainz.py @@ -192,7 +192,8 @@ class AcousticPlugin(plugins.BeetsPlugin): val) setattr(item, attr, val) else: - self._log.debug(u'skipping attribute {} of {} (value {}) due to config', + self._log.debug(u'skipping attribute {} of {} (value {})' + u' due to config', attr, item, val) From a2393e48f250719e435901966b170bc819880fa9 Mon Sep 17 00:00:00 2001 From: Owen Parry Date: Mon, 27 Nov 2017 09:15:03 -0800 Subject: [PATCH 3/4] add changelog entry for acousticbrainz 'tag' option --- docs/changelog.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index fe19403f0..e3518cba6 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -28,9 +28,9 @@ New features: before touching your files. Thanks to :user:`konman2`. :bug:`2708` :bug:`2427` -* :doc:`/plugins/lyrics`: The Genius backend should work again. - Thanks to :user:`lmagno`. - :bug:`2709` +* :doc:`/plugins/acousticbrainz`: The plugin can now be configured to write only + a specific list of tags. + Thanks to :user:`woparry`. Fixes: From 1f45ea00f49ba6a9697333204dbfd67045d5a2c6 Mon Sep 17 00:00:00 2001 From: Owen Parry Date: Sat, 2 Dec 2017 11:31:31 -0800 Subject: [PATCH 4/4] use as_str_seq and fix line length --- beetsplug/acousticbrainz.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/beetsplug/acousticbrainz.py b/beetsplug/acousticbrainz.py index 982f7829c..f4960c301 100644 --- a/beetsplug/acousticbrainz.py +++ b/beetsplug/acousticbrainz.py @@ -165,7 +165,7 @@ class AcousticPlugin(plugins.BeetsPlugin): def _fetch_info(self, items, write, force): """Fetch additional information from AcousticBrainz for the `item`s. """ - tags = self.config['tags'].get() + tags = self.config['tags'].as_str_seq() for item in items: # If we're not forcing re-downloading for all tracks, check # whether the data is already present. We use one @@ -192,8 +192,8 @@ class AcousticPlugin(plugins.BeetsPlugin): val) setattr(item, attr, val) else: - self._log.debug(u'skipping attribute {} of {} (value {})' - u' due to config', + self._log.debug(u'skipping attribute {} of {}' + u' (value {}) due to config', attr, item, val)