diff options
| author | jvoisin | 2021-04-24 17:26:38 +0200 |
|---|---|---|
| committer | jvoisin | 2021-04-24 17:26:38 +0200 |
| commit | 85c08c5b68301d655a88dd78f2a5e790009a5eb6 (patch) | |
| tree | 23d1c20fcecbadde3c7dc711ca4e0b5074c54649 | |
| parent | c5841a241dcf737599422e34a99d8001f974d13a (diff) | |
Add support for AIFF files
This should close #151
Diffstat (limited to '')
| -rw-r--r-- | libmat2/audio.py | 11 | ||||
| -rw-r--r-- | tests/data/dirty.aiff | bin | 0 -> 358824 bytes | |||
| -rw-r--r-- | tests/test_libmat2.py | 11 |
3 files changed, 22 insertions, 0 deletions
diff --git a/libmat2/audio.py b/libmat2/audio.py index 0d54930..bd7add9 100644 --- a/libmat2/audio.py +++ b/libmat2/audio.py | |||
| @@ -90,3 +90,14 @@ class WAVParser(video.AbstractFFmpegParser): | |||
| 90 | 'FileSize', 'FileType', 'FileTypeExtension', | 90 | 'FileSize', 'FileType', 'FileTypeExtension', |
| 91 | 'MIMEType', 'NumChannels', 'SampleRate', 'SourceFile', | 91 | 'MIMEType', 'NumChannels', 'SampleRate', 'SourceFile', |
| 92 | } | 92 | } |
| 93 | |||
| 94 | class AIFFParser(video.AbstractFFmpegParser): | ||
| 95 | mimetypes = {'audio/aiff', 'audio/x-aiff'} | ||
| 96 | meta_allowlist = {'AvgBytesPerSec', 'BitsPerSample', 'Directory', | ||
| 97 | 'Duration', 'Encoding', 'ExifToolVersion', | ||
| 98 | 'FileAccessDate', 'FileInodeChangeDate', | ||
| 99 | 'FileModifyDate', 'FileName', 'FilePermissions', | ||
| 100 | 'FileSize', 'FileType', 'FileTypeExtension', | ||
| 101 | 'MIMEType', 'NumChannels', 'SampleRate', 'SourceFile', | ||
| 102 | 'NumSampleFrames', 'SampleSize', | ||
| 103 | } | ||
diff --git a/tests/data/dirty.aiff b/tests/data/dirty.aiff new file mode 100644 index 0000000..03aab43 --- /dev/null +++ b/tests/data/dirty.aiff | |||
| Binary files differ | |||
diff --git a/tests/test_libmat2.py b/tests/test_libmat2.py index a6c3a9a..5b9ad59 100644 --- a/tests/test_libmat2.py +++ b/tests/test_libmat2.py | |||
| @@ -230,6 +230,11 @@ class TestGetMeta(unittest.TestCase): | |||
| 230 | p = images.SVGParser('./tests/data/weird.svg') | 230 | p = images.SVGParser('./tests/data/weird.svg') |
| 231 | self.assertEqual(p.get_meta()['Xmlns'], 'http://www.w3.org/1337/svg') | 231 | self.assertEqual(p.get_meta()['Xmlns'], 'http://www.w3.org/1337/svg') |
| 232 | 232 | ||
| 233 | def test_aiff(self): | ||
| 234 | p = audio.AIFFParser('./tests/data/dirty.aiff') | ||
| 235 | meta = p.get_meta() | ||
| 236 | self.assertEqual(meta['Name'], 'I am so') | ||
| 237 | |||
| 233 | 238 | ||
| 234 | class TestRemovingThumbnails(unittest.TestCase): | 239 | class TestRemovingThumbnails(unittest.TestCase): |
| 235 | def test_odt(self): | 240 | def test_odt(self): |
| @@ -312,6 +317,12 @@ class TestCleaning(unittest.TestCase): | |||
| 312 | 'meta': {'Comment': 'Zomg, a comment!'}, | 317 | 'meta': {'Comment': 'Zomg, a comment!'}, |
| 313 | 'expected_meta': {}, | 318 | 'expected_meta': {}, |
| 314 | }, { | 319 | }, { |
| 320 | 'name': 'aiff', | ||
| 321 | 'parser': audio.AIFFParser, | ||
| 322 | 'meta': {'Annotation': 'Thank you for using MAT !'}, | ||
| 323 | 'expected_meta': {}, | ||
| 324 | }, | ||
| 325 | { | ||
| 315 | 'name': 'mp3', | 326 | 'name': 'mp3', |
| 316 | 'parser': audio.MP3Parser, | 327 | 'parser': audio.MP3Parser, |
| 317 | 'meta': {'TXXX:I am a': 'various comment'}, | 328 | 'meta': {'TXXX:I am a': 'various comment'}, |
