Skip to content

Commit

Permalink
Convert mb_artistid and mb_albumartistid to multivalue
Browse files Browse the repository at this point in the history
Resolves beetbox#43
  • Loading branch information
JuniorJPDJ committed May 12, 2021
1 parent dd75232 commit 37fa6fe
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 14 deletions.
17 changes: 9 additions & 8 deletions mediafile.py
Original file line number Diff line number Diff line change
Expand Up @@ -1947,16 +1947,17 @@ def update(self, dict):
StorageStyle('MUSICBRAINZ_ALBUMID'),
ASFStorageStyle('MusicBrainz/Album Id'),
)
mb_artistid = MediaField(
MP3DescStorageStyle(u'MusicBrainz Artist Id'),
MP4StorageStyle('----:com.apple.iTunes:MusicBrainz Artist Id'),
StorageStyle('MUSICBRAINZ_ARTISTID'),
mb_artistid = ListMediaField(
MP3ListDescStorageStyle(u'MusicBrainz Artist Id'),
MP4ListStorageStyle('----:com.apple.iTunes:MusicBrainz Artist Id'),
ListStorageStyle('MUSICBRAINZ_ARTISTID'),
ASFStorageStyle('MusicBrainz/Artist Id'),
)
mb_albumartistid = MediaField(
MP3DescStorageStyle(u'MusicBrainz Album Artist Id'),
MP4StorageStyle('----:com.apple.iTunes:MusicBrainz Album Artist Id'),
StorageStyle('MUSICBRAINZ_ALBUMARTISTID'),
mb_albumartistid = ListMediaField(
MP3ListDescStorageStyle(u'MusicBrainz Album Artist Id'),
MP4ListStorageStyle(
'----:com.apple.iTunes:MusicBrainz Album Artist Id'),
ListStorageStyle('MUSICBRAINZ_ALBUMARTISTID'),
ASFStorageStyle('MusicBrainz/Album Artist Id'),
)
mb_releasegroupid = MediaField(
Expand Down
22 changes: 16 additions & 6 deletions test/test_mediafile.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ class ReadWriteTestBase(ArtTestMixin, GenreListTestMixin,
'mb_trackid': '8b882575-08a5-4452-a7a7-cbb8a1531f9e',
'mb_releasetrackid': 'c29f3a57-b439-46fd-a2e2-93776b1371e0',
'mb_albumid': '9e873859-8aa4-4790-b985-5a953e8ef628',
'mb_artistid': '7cf0ea9d-86b9-4dad-ba9e-2355a64899ea',
'mb_artistid': ['7cf0ea9d-86b9-4dad-ba9e-2355a64899ea'],
'art': None,
'label': u'the label',
}
Expand Down Expand Up @@ -371,7 +371,6 @@ class ReadWriteTestBase(ArtTestMixin, GenreListTestMixin,
'mb_releasetrackid',
'mb_workid',
'mb_albumid',
'mb_artistid',
'art',
'label',
'rg_track_peak',
Expand All @@ -381,7 +380,6 @@ class ReadWriteTestBase(ArtTestMixin, GenreListTestMixin,
'r128_track_gain',
'r128_album_gain',
'albumartist',
'mb_albumartistid',
'artist_sort',
'albumartist_sort',
'acoustid_fingerprint',
Expand Down Expand Up @@ -449,7 +447,11 @@ def test_read_full(self):
def test_read_empty(self):
mediafile = self._mediafile_fixture('empty')
for field in self.tag_fields:
self.assertIsNone(getattr(mediafile, field))
value = getattr(mediafile, field)
if isinstance(value, list):
assert len(value) == 0
else:
self.assertIsNone(value)

def test_write_empty(self):
mediafile = self._mediafile_fixture('empty')
Expand Down Expand Up @@ -620,7 +622,11 @@ def test_delete_tag(self):
mediafile = MediaFile(mediafile.path)

for key in keys:
self.assertIsNone(getattr(mediafile, key))
value = getattr(mediafile, key)
if isinstance(value, list):
assert len(value) == 0
else:
self.assertIsNone(value)

def test_delete_packed_total(self):
mediafile = self._mediafile_fixture('full')
Expand Down Expand Up @@ -705,6 +711,9 @@ def _generate_tags(self, base=None):
for key in ['disc', 'disctotal', 'track', 'tracktotal', 'bpm']:
tags[key] = 1

for key in ['mb_artistid', 'mb_albumartistid']:
tags[key] = ['multival', 'test']

tags['art'] = self.jpg_data
tags['comp'] = True

Expand Down Expand Up @@ -976,7 +985,8 @@ def test_properties_from_readable_fields(self):

def test_known_fields(self):
fields = list(ReadWriteTestBase.tag_fields)
fields.extend(('encoder', 'images', 'genres', 'albumtype'))
fields.extend(('encoder', 'images', 'genres', 'albumtype',
'mb_artistid', 'mb_albumartistid'))
assertCountEqual(self, MediaFile.fields(), fields)

def test_fields_in_readable_fields(self):
Expand Down

0 comments on commit 37fa6fe

Please sign in to comment.