diff --git a/beets/autotag/mb.py b/beets/autotag/mb.py index e6a2e277f..3bd7e8c81 100644 --- a/beets/autotag/mb.py +++ b/beets/autotag/mb.py @@ -117,11 +117,20 @@ def _preferred_alias(aliases): # Only consider aliases that have locales set. aliases = [a for a in aliases if 'locale' in a] + # Get any ignored alias types and lower case them to prevent case issues + ignored_alias_types = config['import']['ignored_alias_types'].as_str_seq() + ignored_alias_types = [a.lower() for a in ignored_alias_types] + # Search configured locales in order. for locale in config['import']['languages'].as_str_seq(): - # Find matching primary aliases for this locale. - matches = [a for a in aliases - if a['locale'] == locale and 'primary' in a] + # Find matching primary aliases for this locale that are not + # being ignored + matches = [] + for a in aliases: + if a['locale'] == locale and 'primary' in a and \ + a.get('type', '').lower() not in ignored_alias_types: + matches.append(a) + # Skip to the next locale if we have no matches if not matches: continue diff --git a/beets/config_default.yaml b/beets/config_default.yaml index 6afb3e5a4..40598ae6a 100644 --- a/beets/config_default.yaml +++ b/beets/config_default.yaml @@ -33,6 +33,7 @@ import: duplicate_action: ask bell: no set_fields: {} + ignored_alias_types: [] clutter: ["Thumbs.DB", ".DS_Store"] ignore: [".*", "*~", "System Volume Information", "lost+found"] diff --git a/docs/changelog.rst b/docs/changelog.rst index 11f04dee4..bd4413f41 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -45,6 +45,8 @@ New features: :bug:`4379` :bug:`4387` * Add :ref:`%sunique{} ` template to disambiguate between singletons. :bug:`4438` +* Add a new ``import.ignored_alias_types`` config option to allow for + specific alias types to be skipped over when importing items/albums. Bug fixes: diff --git a/docs/reference/config.rst b/docs/reference/config.rst index 99f916e88..afabe1aa0 100644 --- a/docs/reference/config.rst +++ b/docs/reference/config.rst @@ -652,6 +652,17 @@ MusicBrainz. You can use a space-separated list of language abbreviations, like ``en jp es``, to specify a preference order. Defaults to an empty list, meaning that no language is preferred. +.. _ignored_alias_types: + +ignored_alias_types +~~~~~~~~~~~~~~~~~~~ + +A list of alias types to be ignored when importing new items. + +See the `MusicBrainz Documentation` for more information on aliases. + +.._MusicBrainz Documentation: https://musicbrainz.org/doc/Aliases + .. _detail: detail