"search", "sticker find",]
track_obj = ['currentsong']
if self._comm in tracks_listing + track_obj:
- # pylint: disable=star-args
+ # pylint: disable=star-args
if isinstance(ans, list):
return [Track(**track) for track in ans]
elif isinstance(ans, dict):
kwalbart = {'albumartist':name, 'artist':name}
for album in self.list('album', 'albumartist', artist):
if album and album not in albums:
- albums.append(Album(name=album, **kwalbart)) #pylint: disable=star-args
+ albums.append(Album(name=album, **kwalbart)) # pylint: disable=star-args
for album in self.list('album', 'artist', artist):
album_trks = [trk for trk in self.find('album', album)]
if 'Various Artists' in [tr.albumartist for tr in album_trks]:
# -*- coding: utf-8 -*-
-# Copyright (c) 2013, 2014 Jack Kaliko <kaliko@azylum.org>
+# Copyright (c) 2013, 2014, 2015 Jack Kaliko <kaliko@azylum.org>
#
# This file is part of sima
#
import re
UUID_RE = r'^[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89aAbB][a-f0-9]{3}-[a-f0-9]{12}$'
+# The Track Object is collapsing multiple tags into a single string using this
+# separator. It is used then to split back the string to tags list.
+SEPARATOR = chr(0x1F) # ASCII Unit Separator
def is_uuid4(uuid):
regexp = re.compile(UUID_RE, re.IGNORECASE)
"artist" entry:
>>> trk = {'artist':'Art Name',
>>> 'albumartist': 'Alb Art Name', # optional
- >>> 'musicbrainz_artistid': '<UUID4>' , # 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('artist', False):
+ name = kwargs.get('artist').split(SEPARATOR)[0]
+ if kwargs.get('musicbrainz_artistid', False):
+ mbid = kwargs.get('musicbrainz_artistid').split(SEPARATOR)[0]
if (kwargs.get('albumartist', False) and
kwargs.get('albumartist') != 'Various Artists'):
- name = kwargs.get('albumartist').split(', ')[0]
+ name = kwargs.get('albumartist').split(SEPARATOR)[0]
if (kwargs.get('musicbrainz_albumartistid', False) and
kwargs.get('musicbrainz_albumartistid') != '89ad4ac3-39f7-470e-963a-56509c546377'):
- mbid = kwargs.get('musicbrainz_albumartistid').split(', ')[0]
+ mbid = kwargs.get('musicbrainz_albumartistid').split(SEPARATOR)[0]
super().__init__(name=name, mbid=mbid)
class MetaContainer(Set):
# -*- coding: utf-8 -*-
-# Copyright (c) 2009, 2010, 2011, 2013, 2014 Jack Kaliko <kaliko@azylum.org>
+# Copyright (c) 2009, 2010, 2011, 2013, 2014, 2015 Jack Kaliko <kaliko@azylum.org>
# Copyright (c) 2009 J. Alexander Treuman (Tag collapse method)
# Copyright (c) 2008 Rick van Hattem
#
import time
-from .meta import Artist
+from .meta import Artist, SEPARATOR
class Track:
"""
continue
if isinstance(value, list):
self.collapsed_tags.append(tag)
- self.__dict__.update({tag: ', '.join(set(value))})
+ self.__dict__.update({tag: SEPARATOR.join(set(value))})
def __repr__(self):
return '%s(artist="%s", album="%s", title="%s", file="%s")' % (
class MpdOptions(Plugin):
"""
- Deal with MPD options ‑ idle and repeat mode
+ Deal with MPD options - idle and repeat mode
"""
def __init__(self, daemon):
import unittest
from sima.lib.meta import Meta, Artist, MetaContainer, is_uuid4
-from sima.lib.meta import WrongUUID4, MetaException
+from sima.lib.meta import WrongUUID4, MetaException, SEPARATOR
VALID = '110e8100-e29b-41d1-a716-116655250000'
class TestArtistObject(unittest.TestCase):
def test_init(self):
- artist = {'artist': ', '.join(['Original Name', 'Featuring Nane', 'Feature…']),
+ artist = {'artist': SEPARATOR.join(['Original Name', 'Featuring Nane', 'Feature…']),
'albumartist': 'Name',
'musicbrainz_artistid': VALID,
'musicbrainz_albumartistid': VALID.replace('11', '22'),
art = Artist(**artist)
self.assertTrue(art.name == 'Original Name', art.name)
+ def test_empty_name(self):
+ for args in [
+ {'mbid':VALID},
+ {'name': None},
+ {},
+ ]:
+ with self.assertRaises(MetaException,
+ msg='{} does not raise an except.'.format(args)):
+ Artist(**args)
class TestMetaContainers(unittest.TestCase):