From 34cc157bee569f7ae9bdb66c1e5ca02fd570b16b Mon Sep 17 00:00:00 2001 From: thebigmunch Date: Sat, 11 Apr 2020 07:56:14 -0400 Subject: [PATCH] Use a single enum for ID3v2 timestamp format [#22] * Remove ``ID3v2LyricsTimestampFormat`` * Remove ``ID3v2TempoTimestampFormat`` --- CHANGELOG.md | 8 ++++++++ src/audio_metadata/formats/id3v2frames.py | 11 +++++------ src/audio_metadata/formats/tables.py | 10 ++-------- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d90f2e..6cf982c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/audio_metadata/formats/id3v2frames.py b/src/audio_metadata/formats/id3v2frames.py index 57e15bf..a3d4bc6 100644 --- a/src/audio_metadata/formats/id3v2frames.py +++ b/src/audio_metadata/formats/id3v2frames.py @@ -88,8 +88,7 @@ ID3Version, ID3v1Genres, ID3v2LyricsContentType, - ID3v2LyricsTimestampFormat, - ID3v2TempoTimestampFormat, + ID3v2TimestampFormat, ) from ..exceptions import ( AudioMetadataWarning, @@ -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) @@ -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() @@ -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, @@ -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, diff --git a/src/audio_metadata/formats/tables.py b/src/audio_metadata/formats/tables.py index 4a1b1a7..45f12e1 100644 --- a/src/audio_metadata/formats/tables.py +++ b/src/audio_metadata/formats/tables.py @@ -5,8 +5,7 @@ 'ID3v1Genres', 'ID3v2FrameIDs', 'ID3v2LyricsContentType', - 'ID3v2LyricsTimestampFormat', - 'ID3v2TempoTimestampFormat', + 'ID3v2TimestampFormat', 'ID3v2UnofficialFrameIDs', 'LAMEBitrateMode', 'LAMEChannelMode', @@ -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