mirror of
https://github.com/beetbox/beets.git
synced 2025-12-28 11:32:30 +01:00
Add tests for legacy coverart tag in ogg
Added a `coverart.ogg` fixture file that contains raw image data encoded as base64 in the COVERART tag. We test that the `art` property on mediafiles correctly reads these tags and transforms them into METADATA_BLOCK_PICTURE tags on write.
This commit is contained in:
parent
ba2d7ce53c
commit
a99dea1d9b
3 changed files with 18 additions and 8 deletions
|
|
@ -704,7 +704,8 @@ class VorbisImageStorageStyle(ListStorageStyle):
|
|||
if 'metadata_block_picture' not in mutagen_file:
|
||||
# Try legacy COVERART tags.
|
||||
if 'coverart' in mutagen_file and mutagen_file['coverart']:
|
||||
return base64.b64decode(mutagen_file['coverart'][0])
|
||||
return [base64.b64decode(data)
|
||||
for data in mutagen_file['coverart']]
|
||||
return []
|
||||
|
||||
pics = []
|
||||
|
|
@ -717,13 +718,10 @@ class VorbisImageStorageStyle(ListStorageStyle):
|
|||
|
||||
def store(self, mutagen_file, image_data):
|
||||
# Strip all art, including legacy COVERART.
|
||||
if 'metadata_block_picture' in mutagen_file:
|
||||
if 'metadata_block_picture' in mutagen_file:
|
||||
del mutagen_file['metadata_block_picture']
|
||||
if 'coverart' in mutagen_file:
|
||||
del mutagen_file['coverart']
|
||||
if 'coverartmime' in mutagen_file:
|
||||
del mutagen_file['coverartmime']
|
||||
if 'coverart' in mutagen_file:
|
||||
del mutagen_file['coverart']
|
||||
if 'coverartmime' in mutagen_file:
|
||||
del mutagen_file['coverartmime']
|
||||
|
||||
image_data = image_data[0]
|
||||
# Add new art if provided.
|
||||
|
|
|
|||
BIN
test/rsrc/coverart.ogg
Normal file
BIN
test/rsrc/coverart.ogg
Normal file
Binary file not shown.
|
|
@ -500,6 +500,7 @@ class OggTest(ReadWriteTestBase, GenreListTestMixin, unittest.TestCase):
|
|||
'bitdepth': 0,
|
||||
'channels': 1,
|
||||
}
|
||||
|
||||
def test_read_date_from_year_tag(self):
|
||||
mediafile = self._mediafile_fixture('year')
|
||||
self.assertEqual(mediafile.year, 2000)
|
||||
|
|
@ -513,6 +514,17 @@ class OggTest(ReadWriteTestBase, GenreListTestMixin, unittest.TestCase):
|
|||
mediafile = MediaFile(mediafile.path)
|
||||
self.assertEqual(mediafile.mgfile['YEAR'], [u'2000'])
|
||||
|
||||
def test_legacy_coverart_tag(self):
|
||||
mediafile = self._mediafile_fixture('coverart')
|
||||
self.assertTrue('coverart' in mediafile.mgfile)
|
||||
self.assertEqual(mediafile.art, self.png_data)
|
||||
|
||||
mediafile.art = self.png_data
|
||||
mediafile.save()
|
||||
|
||||
mediafile = MediaFile(mediafile.path)
|
||||
self.assertFalse('coverart' in mediafile.mgfile)
|
||||
|
||||
class FlacTest(ReadWriteTestBase, PartialTestMixin,
|
||||
GenreListTestMixin, unittest.TestCase):
|
||||
extension = 'flac'
|
||||
|
|
|
|||
Loading…
Reference in a new issue