func(*args, **kwargs)
return wrapper
+
def serialize(func):
def wrapper(*args, **kwargs):
ans = func(*args, **kwargs)
@mbidfilter
def __init__(self, name=None, mbid=None, **kwargs):
+ if kwargs.get('musicbrainz_albumid', False):
+ mbid = kwargs.get('musicbrainz_albumid').split(SEPARATOR)[0]
super().__init__(name=name, mbid=mbid, **kwargs)
@property
import time
-from .meta import Artist, SEPARATOR
+from .meta import Artist, Album, SEPARATOR
class Track:
"""
return Artist(name='[unknown]', **self.__dict__)
return Artist(**self.__dict__)
+ @property
+ def Album(self):
+ """Get the :class:`sima.lib.meta.Album` associated to this track"""
+ if not self.album:
+ return Album(name='[unknown]', **self.__dict__)
+ return Album(name=self.album, **self.__dict__)
+
# VIM MODLINE
# vim: ai ts=4 sw=4 sts=4 expandtab
trk = Track(**{'artist': 'Devolt', 'genre': 'Punk '})
self.assertEqual(trk.genres, ['Punk'])
+ def test_artist_object(self):
+ trk = Track(**DEVOLT)
+ self.assertEqual(trk.Artist.name, DEVOLT['artist'])
+ self.assertEqual(trk.Artist.mbid, DEVOLT['musicbrainz_artistid'])
+
+ def test_album_object(self):
+ trk = Track(**DEVOLT)
+ self.assertEqual(trk.Album.name, DEVOLT['album'])
+ self.assertEqual(trk.Album.mbid, DEVOLT['musicbrainz_albumid'])
+
# vim: ai ts=4 sw=4 sts=4 expandtab