- def __init__(self, **kwargs):
- self._aliases = set()
- super().__init__(**kwargs)
-
- def append(self, name):
- self._aliases.update({name,})
+ def __init__(self, name=None, **kwargs):
+ """Artist object built from a mapping dict containing at least an
+ "artist" entry:
+ >>> trk = {'artist':'Art Name',
+ >>> 'albumartist': 'Alb Art Name', # optional
+ >>> 'musicbrainz_artistid': '<UUID4>' , # optional
+ >>> 'musicbrainz_albumartistid': '<UUID4>', # optional
+ >>> }
+ >>> artobj0 = Artist(**trk)
+ >>> artobj1 = Artist(name='Tool')
+ """
+ self.__aliases = set()
+ name = kwargs.get('artist', name)
+ mbid = kwargs.get('musicbrainz_artistid', None)
+ if (kwargs.get('albumartist', False) and
+ kwargs.get('albumartist') != 'Various Artists'):
+ name = kwargs.get('albumartist').split(', ')[0]
+ if (kwargs.get('musicbrainz_albumartistid', False) and
+ kwargs.get('musicbrainz_albumartistid') != '89ad4ac3-39f7-470e-963a-56509c546377'):
+ mbid = kwargs.get('musicbrainz_albumartistid').split(', ')[0]
+ super().__init__(name=name, mbid=mbid)
+
+ def add_alias(self, other):
+ if getattr(other, '__str__', None):
+ if callable(other.__str__):
+ self.__aliases |= {other.__str__()}
+ elif isinstance(other, Artist):
+ self.__aliases |= other._Artist__aliases
+ else:
+ raise MetaException('No __str__ method found in {!r}'.format(other))