From 24cc6f0ba625f217d6127fc0cee880b22a8c6cbf Mon Sep 17 00:00:00 2001 From: kaliko Date: Sat, 6 Dec 2014 14:42:27 +0100 Subject: [PATCH 1/1] Deal with multi-tag for musicbrainz_albumartistid and albumartist --- sima/lib/meta.py | 5 +++++ sima/lib/track.py | 6 ++---- tests/test_track.py | 6 ++++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/sima/lib/meta.py b/sima/lib/meta.py index 949b556..9265c3c 100644 --- a/sima/lib/meta.py +++ b/sima/lib/meta.py @@ -68,6 +68,11 @@ class Meta: return bool(self.name) class Album(Meta): + """Info: + If a class that overrides __eq__() needs to retain the implementation of + __hash__() from a parent class, the interpreter must be told this explicitly + by setting __hash__ = .__hash__. + """ __hash__ = Meta.__hash__ def __init__(self, **kwargs): diff --git a/sima/lib/track.py b/sima/lib/track.py index 3926c4d..6c28351 100644 --- a/sima/lib/track.py +++ b/sima/lib/track.py @@ -46,7 +46,6 @@ class Track: 'musicbrainz_artistid', 'musicbrainz_albumartistid'] # have tags been collapsed? - self.collapse_tags_bool = False self.collapsed_tags = list() # Needed for multiple tags which returns a list instead of a string self.collapse_tags() @@ -60,7 +59,6 @@ class Track: if tag not in self.tags_to_collapse: continue if isinstance(value, list): - self.collapse_tags_bool = True self.collapsed_tags.append(tag) self.__dict__.update({tag: ', '.join(set(value))}) @@ -133,10 +131,10 @@ class Track: name = self.artist mbid = self.musicbrainz_artistid if self.albumartist and self.albumartist != 'Various Artists': - name = self.albumartist + name = self.albumartist.split(', ')[0] if (self.musicbrainz_albumartistid and self.musicbrainz_albumartistid != '89ad4ac3-39f7-470e-963a-56509c546377'): - mbid = self.musicbrainz_albumartistid + mbid = self.musicbrainz_albumartistid.split(', ')[0] return Artist(name=name, mbid=mbid) # VIM MODLINE diff --git a/tests/test_track.py b/tests/test_track.py index 28487b7..b572221 100644 --- a/tests/test_track.py +++ b/tests/test_track.py @@ -11,7 +11,7 @@ DEVOLT = { 'artist': 'Devolt', 'date': '2011-12-01', 'disc': '1/1', - 'file': 'gberret.music/Devolt/2011-Grey/03-Devolt - Crazy.mp3', + 'file': 'music/Devolt/2011-Grey/03-Devolt - Crazy.mp3', 'last-modified': '2012-04-02T20:48:59Z', 'musicbrainz_albumartistid': 'd8e7e3e2-49ab-4f7c-b148-fc946d521f99', 'musicbrainz_albumid': 'ea2ef2cf-59e1-443a-817e-9066e3e0be4b', @@ -26,8 +26,10 @@ class TestTrackObject(unittest.TestCase): def test_tagcollapse(self): trk = Track(**DEVOLT) - self.assertTrue(trk.collapse_tags_bool, 'Should have collapsed a tag') + self.assertTrue(trk.collapsed_tags, 'Should have collapsed a tag') self.assertFalse(isinstance(trk.albumartist, list), 'Failed to collapse albumartist tag') + self.assertTrue(trk.get_artist().name in DEVOLT.get('albumartist'), + 'Failed to split multiple tag?') def test_boolean_type(self): self.assertFalse(bool(Track())) -- 2.39.5