Skip to content

Commit

Permalink
Use a single enum for ID3v2 timestamp format [#22]
Browse files Browse the repository at this point in the history
* Remove ``ID3v2LyricsTimestampFormat``
* Remove ``ID3v2TempoTimestampFormat``
  • Loading branch information
thebigmunch committed Apr 11, 2020
1 parent 7764a27 commit 34cc157
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ This project adheres to [Semantic Versioning](https://semver.org).
* ``ID3v2NumberFrame`` value is not the appropriate class
(``ID3v2Disc`` or ``ID3v2Track``) rather than having
the number/total abstraction on the frame class itself.
* Use a single enum for ID3v2 timestamp format.
* Remove ``ID3v2LyricsTimestampFormat``.
* Remove ``ID3v2TempoTimestampFormat``.

### Removed

* ``ID3v2LyricsTimestampFormat``.
* ``ID3v2TempoTimestampFormat``.

### Fixed

Expand Down
11 changes: 5 additions & 6 deletions src/audio_metadata/formats/id3v2frames.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@
ID3Version,
ID3v1Genres,
ID3v2LyricsContentType,
ID3v2LyricsTimestampFormat,
ID3v2TempoTimestampFormat,
ID3v2TimestampFormat,
)
from ..exceptions import (
AudioMetadataWarning,
Expand Down Expand Up @@ -192,7 +191,7 @@ class ID3v2Lyrics(AttrMapping):
kw_only=True,
)
class ID3v2SynchronizedLyrics(ID3v2Lyrics):
timestamp_format = attrib(converter=ID3v2LyricsTimestampFormat)
timestamp_format = attrib(converter=ID3v2TimestampFormat)
content_type = attrib(converter=ID3v2LyricsContentType)


Expand Down Expand Up @@ -298,7 +297,7 @@ class ID3v2RecommendedBuffer(AttrMapping):
kw_only=True,
)
class ID3v2SynchronizedTempoCodes(AttrMapping):
timestamp_format = attrib(converter=ID3v2TempoTimestampFormat)
timestamp_format = attrib(converter=ID3v2TimestampFormat)
data = attrib()


Expand Down Expand Up @@ -673,7 +672,7 @@ def _parse_frame_data(data):

return (
ID3v2SynchronizedTempoCodes(
timestamp_format=ID3v2TempoTimestampFormat(frame_data[0]),
timestamp_format=ID3v2TimestampFormat(frame_data[0]),
data=frame_data[1:]
),
None,
Expand Down Expand Up @@ -974,7 +973,7 @@ def _parse_frame_data(data):
language=decode_bytestring(frame_data[1:4]),
description=decode_bytestring(description, encoding),
text=decode_bytestring(text, encoding),
timestamp_format=ID3v2LyricsTimestampFormat(frame_data[4]),
timestamp_format=ID3v2TimestampFormat(frame_data[4]),
content_type=frame_data[5],
),
encoding,
Expand Down
10 changes: 2 additions & 8 deletions src/audio_metadata/formats/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
'ID3v1Genres',
'ID3v2FrameIDs',
'ID3v2LyricsContentType',
'ID3v2LyricsTimestampFormat',
'ID3v2TempoTimestampFormat',
'ID3v2TimestampFormat',
'ID3v2UnofficialFrameIDs',
'LAMEBitrateMode',
'LAMEChannelMode',
Expand Down Expand Up @@ -88,12 +87,7 @@ class ID3v2LyricsContentType(_BaseIntEnum):
IMAGES = 8


class ID3v2LyricsTimestampFormat(_BaseIntEnum):
MPEG_FRAMES = 0
MILLISECONDS = 1


class ID3v2TempoTimestampFormat(_BaseIntEnum):
class ID3v2TimestampFormat(_BaseIntEnum):
MPEG_FRAMES = 0
MILLISECONDS = 1

Expand Down

0 comments on commit 34cc157

Please sign in to comment.