Skip to content

Commit

Permalink
Feat/mp4 (#1)
Browse files Browse the repository at this point in the history
* Add MP4 load(s) support [thebigmunch#14]

* Add m4b, m4v to MP4 parser

* MP4 Freeform tags are appendended in the wrong location

* Embed just the necessary parts of tbm-utils

Co-authored-by: thebigmunch <[email protected]>
Co-authored-by: Allen Wittenauer <[email protected]>
  • Loading branch information
3 people authored Dec 29, 2022
1 parent 9f5e71e commit ac41045
Show file tree
Hide file tree
Showing 28 changed files with 1,704 additions and 34 deletions.
11 changes: 5 additions & 6 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@

ON_GITHUB = 'GITHUB_ACTIONS' in os.environ

py36 = '3.6'
py37 = '3.7'
py38 = '3.8'
py39 = '3.9'
py310 = '3.10'


nox.options.reuse_existing_virtualenvs = True
nox.options.sessions = [
Expand Down Expand Up @@ -41,21 +40,21 @@ def doc(session):
)


@nox.session(python=[py36, py37, py38, py39])
@nox.session(python=[py39, py310])
def test(session):
session.install('-U', '.[test]')
session.run('coverage', 'run', '-m', 'ward', *session.posargs)
session.notify('report')


@nox.session(python=[py36, py37, py38, py39])
@nox.session(python=[py39, py310])
def integration(session):
session.install('-U', '.[test]')
session.run('coverage', 'run', '-m', 'ward', '--tags', 'integration', *session.posargs)
session.notify('report')


@nox.session(python=[py36, py37, py38, py39])
@nox.session(python=[py39, py310])
def unit(session):
session.install('-U', '.[test]')
session.run('coverage', 'run', '-m', 'ward', '--tags', 'unit', *session.posargs)
Expand Down
5 changes: 1 addition & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ build-backend = "poetry.masonry.api"
[tool.poetry]
name = "audio-metadata"
description = "A library for reading and, in the future, writing metadata from audio files."
version = "0.11.1"
version = "0.12.0"

license = "MIT"

Expand All @@ -24,9 +24,7 @@ attrs = ">=18.2"
bidict = "0.*"
bitstruct = ">=6.0,<9.0"
more-itertools = ">=4.0,<9.0"
pendulum = ">=2.0,<=3.0,!=2.0.5,!=2.1.0" # Work around https://github.com/sdispater/pendulum/issues/454
pprintpp = "0.*"
tbm-utils = "^2.3"
wrapt = "^1.0"

coverage = { version = ">=5.0,<6.0", optional = true, extras = [ "toml" ] }
Expand Down Expand Up @@ -65,7 +63,6 @@ lint = [
"flake8-builtins",
"flake8-comprehensions",
"flake8-import-order",
"flake8-import-order-tbm",
]
test = [
"coverage",
Expand Down
9 changes: 8 additions & 1 deletion src/audio_metadata/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
FileIO,
)

from tbm_utils import DataReader
from .tbm_utils import DataReader

from .exceptions import (
FormatError,
Expand All @@ -19,6 +19,7 @@
from .formats import (
FLAC,
MP3,
MP4,
WAVE,
ID3v2,
MP3StreamInfo,
Expand Down Expand Up @@ -68,6 +69,12 @@ def determine_format(data):
if d.startswith(b'RIFF'):
return WAVE

if (
d[4:8].lower() == b'ftyp'
and d[8:].lower().startswith((b'dash', b'm4a', b'm4b', b'm4v', b'mp4'))
):
return MP4

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

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 .id3v2frames import *
from .mp3 import *
from .mp4 import *
from .ogg import *
from .oggopus import *
from .oggvorbis import *
Expand All @@ -17,6 +18,7 @@
*id3v2.__all__,
*id3v2frames.__all__,
*mp3.__all__,
*mp4.__all__,
*ogg.__all__,
*oggopus.__all__,
*oggvorbis.__all__,
Expand Down
2 changes: 1 addition & 1 deletion src/audio_metadata/formats/flac.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
attrib,
attrs,
)
from tbm_utils import (
from ..tbm_utils import (
AttrMapping,
LabelList,
datareader,
Expand Down
2 changes: 1 addition & 1 deletion src/audio_metadata/formats/id3v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
attrib,
attrs,
)
from tbm_utils import (
from ..tbm_utils import (
AttrMapping,
datareader,
)
Expand Down
2 changes: 1 addition & 1 deletion src/audio_metadata/formats/id3v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
attrs,
)
from bidict import frozenbidict
from tbm_utils import (
from ..tbm_utils import (
AttrMapping,
datareader,
)
Expand Down
9 changes: 4 additions & 5 deletions src/audio_metadata/formats/id3v2frames.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,8 @@
attrib,
attrs,
)
from pendulum.parsing import ParserError
from pendulum.parsing.iso8601 import parse_iso8601
from tbm_utils import (
from datetime import datetime
from ..tbm_utils import (
AttrMapping,
datareader,
)
Expand Down Expand Up @@ -1419,8 +1418,8 @@ class ID3v2TimestampFrame(ID3v2Frame):
def _validate_value(self, attribute, value):
for v in value:
try:
parse_iso8601(v)
except ParserError:
datetime.fromisoformat(v.replace('Z', '+00:00'))
except:
raise TagError("Timestamp frame values must conform to the ID3v2-compliant subset of ISO 8601.")

@datareader
Expand Down
2 changes: 1 addition & 1 deletion src/audio_metadata/formats/mp3.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
attrib,
attrs,
)
from tbm_utils import (
from ..tbm_utils import (
AttrMapping,
LabelList,
datareader,
Expand Down
Loading

0 comments on commit ac41045

Please sign in to comment.