Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jvoisin
mat2
Commits
ee704db2
Commit
ee704db2
authored
Jan 01, 2020
by
jvoisin
Browse files
Add support for wav files
parent
693408f1
Changes
3
Hide whitespace changes
Inline
Side-by-side
libmat2/audio.py
View file @
ee704db2
...
...
@@ -6,7 +6,7 @@ from typing import Dict, Union
import
mutagen
from
.
import
abstract
,
parser_factory
from
.
import
abstract
,
parser_factory
,
video
class
MutagenParser
(
abstract
.
AbstractParser
):
...
...
@@ -77,3 +77,14 @@ class FLACParser(MutagenParser):
meta
[
name
]
=
p
.
get_meta
()
if
p
else
'harmful data'
# type: ignore
os
.
remove
(
fname
)
return
meta
class
WAVParser
(
video
.
AbstractFFmpegParser
):
mimetypes
=
{
'audio/x-wav'
,
}
meta_allowlist
=
{
'AvgBytesPerSec'
,
'BitsPerSample'
,
'Directory'
,
'Duration'
,
'Encoding'
,
'ExifToolVersion'
,
'FileAccessDate'
,
'FileInodeChangeDate'
,
'FileModifyDate'
,
'FileName'
,
'FilePermissions'
,
'FileSize'
,
'FileType'
,
'FileTypeExtension'
,
'MIMEType'
,
'NumChannels'
,
'SampleRate'
,
'SourceFile'
,
}
tests/data/dirty.wav
0 → 100644
View file @
ee704db2
File added
tests/test_libmat2.py
View file @
ee704db2
...
...
@@ -127,6 +127,11 @@ class TestGetMeta(unittest.TestCase):
self
.
assertEqual
(
meta
[
'Model'
],
'C7070WZ'
)
self
.
assertEqual
(
meta
[
'ModifyDate'
],
'2005:12:26 17:09:35'
)
def
test_wav
(
self
):
p
=
audio
.
WAVParser
(
'./tests/data/dirty.wav'
)
meta
=
p
.
get_meta
()
self
.
assertEqual
(
meta
[
'Artist'
],
'jvoisin'
)
def
test_mp3
(
self
):
p
=
audio
.
MP3Parser
(
'./tests/data/dirty.mp3'
)
meta
=
p
.
get_meta
()
...
...
@@ -301,6 +306,11 @@ class TestCleaning(unittest.TestCase):
'parser'
:
images
.
JPGParser
,
'meta'
:
{
'Comment'
:
'Created with GIMP'
},
'expected_meta'
:
{},
},
{
'name'
:
'wav'
,
'parser'
:
audio
.
WAVParser
,
'meta'
:
{
'Comment'
:
'Zomg, a comment!'
},
'expected_meta'
:
{},
},
{
'name'
:
'mp3'
,
'parser'
:
audio
.
MP3Parser
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment