From: kaliko Date: Wed, 2 Jun 2021 16:08:03 +0000 (+0200) Subject: Artist object changes X-Git-Tag: 0.18.0~50 X-Git-Url: https://git.kaliko.me/?a=commitdiff_plain;h=703c89bb8361c1d5bc7456ef47a91b5e63dcb74b;p=mpd-sima.git Artist object changes Use name for albumartist if albumartist is not provided. --- diff --git a/sima/lib/meta.py b/sima/lib/meta.py index a492d17..3f6a641 100644 --- a/sima/lib/meta.py +++ b/sima/lib/meta.py @@ -198,16 +198,14 @@ class Artist(Meta): :param str name: Artist name :param str mbid: Musicbrainz artist ID :param str artist: Overrides "name" argument - :param str albumartist: Overrides "name" and "artist" argument + :param str albumartist: use "name" if not set :param str musicbrainz_artistid: Overrides "mbid" argument - :param str musicbrainz_albumartistid: Overrides "musicbrainz_artistid" argument :Example: >>> trk = {'artist':'Art Name', >>> 'albumartist': 'Alb Art Name', # optional >>> 'musicbrainz_artistid': '', # optional - >>> 'musicbrainz_albumartistid': '', # optional >>> } >>> artobj0 = Artist(**trk) >>> artobj1 = Artist(name='Tool') @@ -219,13 +217,11 @@ class Artist(Meta): 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(SEPARATOR)[0] - if (kwargs.get('musicbrainz_albumartistid', False) and - kwargs.get('musicbrainz_albumartistid') != '89ad4ac3-39f7-470e-963a-56509c546377'): - mbid = kwargs.get('musicbrainz_albumartistid').split(SEPARATOR)[0] - super().__init__(name=name, mbid=mbid) + if not kwargs.get('albumartist', False): + kwargs['albumartist'] = name + super().__init__(name=name, mbid=mbid, + albumartist=kwargs.get('albumartist')) + class MetaContainer(Set): diff --git a/sima/utils/blcli.py b/sima/utils/blcli.py index 4522e06..5f0d14a 100644 --- a/sima/utils/blcli.py +++ b/sima/utils/blcli.py @@ -112,9 +112,8 @@ class BLCli(MPD): return track = tracks[0] album = Album(name=track.album, mbid=track.musicbrainz_albumid) - artist = Artist(name=track.artist, mbid=track.musicbrainz_artistid) self.log.info('Found album in library: %s (by "%s")', - album, artist) + album, track.Artist.albumartist) if self.sdb.get_bl_album(album, add=False): self.log.info('Already in blocklist') return diff --git a/tests/test_meta.py b/tests/test_meta.py index 783f647..e1be51b 100644 --- a/tests/test_meta.py +++ b/tests/test_meta.py @@ -124,17 +124,15 @@ class TestArtistObject(unittest.TestCase): 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 == 'Name') - self.assertTrue(art.mbid == VALID.replace('11', '22')) - artist.pop('musicbrainz_albumartistid') - art = Artist(**artist) + self.assertEqual(art.name, 'Original Name') self.assertTrue(art.mbid == VALID) + self.assertEqual(art.albumartist, artist['albumartist']) artist.pop('albumartist') art = Artist(**artist) - self.assertTrue(art.name == 'Original Name', art.name) + self.assertTrue(art.name, 'Original Name') + self.assertTrue(art.albumartist, 'Original Name') def test_empty_name(self): for args in [ diff --git a/tests/test_track.py b/tests/test_track.py index eb32803..368cd45 100644 --- a/tests/test_track.py +++ b/tests/test_track.py @@ -39,9 +39,10 @@ class TestTrackObject(unittest.TestCase): def test_albumartist(self): trk = Track(albumartist='album_artist', artist='track_artist') - self.assertEqual(trk.Artist.name, 'album_artist') + self.assertEqual(trk.Artist.name, 'track_artist') trk = Track(artist='track_artist') self.assertEqual(trk.Artist.name, 'track_artist') + self.assertEqual(trk.Artist.albumartist, 'track_artist') def test_genres(self): trk = Track(**{'artist': 'Devolt', 'genre': ['Rock, Stoner ', ' Punk; Heavy', 'doom']})