]> kaliko git repositories - mpd-sima.git/commitdiff
Artist object changes
authorkaliko <kaliko@azylum.org>
Wed, 2 Jun 2021 16:08:03 +0000 (18:08 +0200)
committerkaliko <kaliko@azylum.org>
Wed, 2 Jun 2021 16:08:03 +0000 (18:08 +0200)
Use name for albumartist if albumartist is not provided.

sima/lib/meta.py
sima/utils/blcli.py
tests/test_meta.py
tests/test_track.py

index a492d17ed60e7ac3749216cf4245eb96bb39c227..3f6a641c3460938966eb2ef84431c55b3222667e 100644 (file)
@@ -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': '<UUID4>',       # optional
-    >>>        'musicbrainz_albumartistid': '<UUID4>',  # 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):
 
index 4522e06d736f0d07822e71c64c0879f110540d18..5f0d14a9c1bae797d6f9f68e1b347c9f3dc08678 100644 (file)
@@ -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
index 783f647f52c971565b49816239b296c337c09173..e1be51b63681beead721a00952c13a525d8ceff1 100644 (file)
@@ -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 [
index eb3280380a560cfe441f199a321431de0d2e7f78..368cd456b34948d1a27b8031a3b5228f82d31b3b 100644 (file)
@@ -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']})