Skip to content

Commit

Permalink
Add MP4 load(s) support [#14]
Browse files Browse the repository at this point in the history
  • Loading branch information
thebigmunch committed Mar 7, 2020
1 parent c999e1f commit cf66fcc
Show file tree
Hide file tree
Showing 9 changed files with 921 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/audio_metadata/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from .formats import (
FLAC,
MP3,
MP4,
WAV,
ID3v2,
MP3StreamInfo,
Expand Down Expand Up @@ -68,6 +69,12 @@ def determine_format(data):
if d.startswith(b'RIFF'):
return WAV

if (
d[4:8].lower() == b'ftyp'
and d[8:12].lower() in (b'dash', b'm4a ')
):
return MP4

if d.startswith(b'ID3'):
ID3v2.parse(data)

Expand Down
7 changes: 7 additions & 0 deletions src/audio_metadata/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
__all__ = [
'AudioMetadataException',
'InvalidAtom',
'InvalidBlock',
'InvalidChunk',
'InvalidComment',
Expand All @@ -16,6 +17,12 @@ class AudioMetadataException(Exception):
pass


class InvalidAtom(AudioMetadataException):
"""Exception raised when an MPEG atom is invalid."""

pass


class InvalidBlock(AudioMetadataException):
"""Exception raised when a FLAC metadata block is invalid."""

Expand Down
2 changes: 2 additions & 0 deletions src/audio_metadata/formats/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from .id3v2 import *
from .id3v2_frames import *
from .mp3 import *
from .mp4 import *
from .ogg import *
from .oggopus import *
from .oggvorbis import *
Expand All @@ -17,6 +18,7 @@
*id3v2_frames.__all__,
*id3v2.__all__,
*mp3.__all__,
*mp4.__all__,
*ogg.__all__,
*oggopus.__all__,
*oggvorbis.__all__,
Expand Down
Loading

0 comments on commit cf66fcc

Please sign in to comment.