- """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)
- 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)
+ if kwargs.get('artist', False):
+ name = kwargs.get('artist')
+ if kwargs.get('musicbrainz_artistid', False):
+ mbid = kwargs.get('musicbrainz_artistid')
+ if name and not kwargs.get('albumartist', False):
+ kwargs['albumartist'] = name.split(SEPARATOR)[0]
+ super().__init__(name=name, mbid=mbid,
+ albumartist=kwargs.get('albumartist'))
+
+
+class MetaContainer(Set):
+
+ def __init__(self, iterable):
+ self.elements = lst = []
+ for value in iterable:
+ if value not in lst:
+ lst.append(value)
+ else:
+ for inlst in lst:
+ if value == inlst:
+ inlst.add_alias(value)
+
+ def __iter__(self):
+ return iter(self.elements)
+
+ def __contains__(self, value):
+ return value in self.elements
+
+ def __len__(self):
+ return len(self.elements)
+
+ def __repr__(self):
+ return repr(self.elements)