- return self._aliases + [self.name]
-
- def __add__(self, other):
- if isinstance(other, Artist):
- if self.mbid == other.mbid:
- res = Artist(**self.__dict__)
- res._aliases.extend(other.names)
- return res
+ return self.__aliases | {self.__name,}
+
+
+class Album(Meta):
+
+ @property
+ def album(self):
+ return self.name
+
+class Artist(Meta):
+
+ @mbidfilter
+ def __init__(self, name=None, mbid=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')
+ """
+ name = kwargs.get('artist', name).split(', ')[0]
+ mbid = kwargs.get('musicbrainz_artistid', mbid)
+ 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)
+
+class MetaContainer(Set):
+
+ def __init__(self, iterable):
+ self.elements = lst = []
+ for value in iterable:
+ if value not in lst:
+ lst.append(value)