1
0
mirror of synced 2024-11-22 09:14:23 +01:00

Delete pictures of FLAC files

This commit is contained in:
jvoisin 2018-10-11 18:15:11 +02:00
parent 35dca4bf1c
commit b2e153b69c
3 changed files with 15 additions and 0 deletions

View File

@ -44,3 +44,17 @@ class OGGParser(MutagenParser):
class FLACParser(MutagenParser): class FLACParser(MutagenParser):
mimetypes = {'audio/flac', 'audio/x-flac'} mimetypes = {'audio/flac', 'audio/x-flac'}
def remove_all(self):
shutil.copy(self.filename, self.output_filename)
f = mutagen.File(self.output_filename)
f.clear_pictures()
f.delete()
f.save(deleteid3=True)
return True
def get_meta(self):
meta = super().get_meta()
if mutagen.File(self.filename).pictures:
meta['Picture'] = 'Cover'
return meta

Binary file not shown.

View File

@ -96,6 +96,7 @@ class TestGetMeta(unittest.TestCase):
p = audio.FLACParser('./tests/data/dirty.flac') p = audio.FLACParser('./tests/data/dirty.flac')
meta = p.get_meta() meta = p.get_meta()
self.assertEqual(meta['title'], 'I am so') self.assertEqual(meta['title'], 'I am so')
self.assertEqual(meta['Picture'], 'Cover')
def test_docx(self): def test_docx(self):
p = office.MSOfficeParser('./tests/data/dirty.docx') p = office.MSOfficeParser('./tests/data/dirty.docx')