Add a import.ignored_alias_types option to ignore alias types.

Sometimes a user may want to use an artist's locale-specific alias but
*not* want to use their legal name, for example.
This commit is contained in:
David Logie 2021-05-03 11:47:22 +01:00
parent b11df49705
commit cfb32d9bc5
4 changed files with 26 additions and 3 deletions

View file

@ -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

View file

@ -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"]

View file

@ -45,6 +45,8 @@ New features:
:bug:`4379` :bug:`4387`
* Add :ref:`%sunique{} <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:

View file

@ -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