From c3664f5f7a63b58cf7c099693065b8b2980e11c4 Mon Sep 17 00:00:00 2001 From: Robert Honz Date: Tue, 2 Apr 2024 15:56:54 +0200 Subject: [PATCH 1/2] =?UTF-8?q?=E2=9C=A8=20Enum=20removal=20was=20reverted?= =?UTF-8?q?=20but=20also=20extended=20with=20`str`,=20so=20`.value`=20do?= =?UTF-8?q?=20not=20need=20to=20be=20used.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tidalapi/media.py | 45 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 9 deletions(-) diff --git a/tidalapi/media.py b/tidalapi/media.py index d91f723..683c998 100644 --- a/tidalapi/media.py +++ b/tidalapi/media.py @@ -53,54 +53,75 @@ from tidalapi.types import JsonObj -class Quality: +class Quality(str, Enum): low_96k: str = "LOW" low_320k: str = "HIGH" high_lossless: str = "LOSSLESS" hi_res: str = "HI_RES" hi_res_lossless: str = "HI_RES_LOSSLESS" + def __str__(self) -> str: + return self.value -class VideoQuality: + +class VideoQuality(str, Enum): high: str = "HIGH" medium: str = "MEDIUM" low: str = "LOW" audio_only: str = "AUDIO_ONLY" + def __str__(self) -> str: + return self.value + -class AudioMode: +class AudioMode(str, Enum): stereo: str = "STEREO" sony_360: str = "SONY_360RA" dolby_atmos: str = "DOLBY_ATMOS" + def __str__(self) -> str: + return self.value + -class MediaMetadataTags: +class MediaMetadataTags(str, Enum): mqa: str = "MQA" hires_lossless: str = "HIRES_LOSSLESS" lossless: str = "LOSSLESS" sony_360: str = "SONY_360RA" dolby_atmos: str = "DOLBY_ATMOS" + def __str__(self) -> str: + return self.value -class AudioExtensions: + +class AudioExtensions(str, Enum): FLAC: str = ".flac" M4A: str = ".m4a" MP4: str = ".mp4" + def __str__(self) -> str: + return self.value + -class VideoExtensions: +class VideoExtensions(str, Enum): TS: str = ".ts" + def __str__(self) -> str: + return self.value -class ManifestMimeType: + +class ManifestMimeType(str, Enum): # EMU: str = "application/vnd.tidal.emu" # APPL: str = "application/vnd.apple.mpegurl" MPD: str = "application/dash+xml" BTS: str = "application/vnd.tidal.bts" VIDEO: str = "video/mp2t" + def __str__(self) -> str: + return self.value + -class Codec: +class Codec(str, Enum): MP3: str = "MP3" AAC: str = "AAC" M4A: str = "MP4A" @@ -113,8 +134,11 @@ class Codec: PremiumCodecs: [str] = [MQA, Atmos, AC4] HQCodecs: [str] = PremiumCodecs + [FLAC] + def __str__(self) -> str: + return self.value -class MimeType: + +class MimeType(str, Enum): audio_mpeg = "audio/mpeg" audio_mp3 = "audio/mp3" audio_m4a = "audio/m4a" @@ -135,6 +159,9 @@ class MimeType: Codec.AC4: audio_ac4, } + def __str__(self) -> str: + return self.value + @staticmethod def from_audio_codec(codec): return MimeType.audio_map.get(codec, MimeType.audio_m4a) From 03b940ec12ef9728056a8c3cbcd513a886f32910 Mon Sep 17 00:00:00 2001 From: Robert Honz Date: Tue, 2 Apr 2024 15:56:54 +0200 Subject: [PATCH 2/2] =?UTF-8?q?=E2=9C=A8=20Enum=20removal=20was=20reverted?= =?UTF-8?q?=20but=20also=20extended=20with=20`str`,=20so=20`.value`=20do?= =?UTF-8?q?=20not=20need=20to=20be=20used.=20Fixes=20tamland/python-tidal#?= =?UTF-8?q?243?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tidalapi/media.py | 45 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 9 deletions(-) diff --git a/tidalapi/media.py b/tidalapi/media.py index d91f723..683c998 100644 --- a/tidalapi/media.py +++ b/tidalapi/media.py @@ -53,54 +53,75 @@ from tidalapi.types import JsonObj -class Quality: +class Quality(str, Enum): low_96k: str = "LOW" low_320k: str = "HIGH" high_lossless: str = "LOSSLESS" hi_res: str = "HI_RES" hi_res_lossless: str = "HI_RES_LOSSLESS" + def __str__(self) -> str: + return self.value -class VideoQuality: + +class VideoQuality(str, Enum): high: str = "HIGH" medium: str = "MEDIUM" low: str = "LOW" audio_only: str = "AUDIO_ONLY" + def __str__(self) -> str: + return self.value + -class AudioMode: +class AudioMode(str, Enum): stereo: str = "STEREO" sony_360: str = "SONY_360RA" dolby_atmos: str = "DOLBY_ATMOS" + def __str__(self) -> str: + return self.value + -class MediaMetadataTags: +class MediaMetadataTags(str, Enum): mqa: str = "MQA" hires_lossless: str = "HIRES_LOSSLESS" lossless: str = "LOSSLESS" sony_360: str = "SONY_360RA" dolby_atmos: str = "DOLBY_ATMOS" + def __str__(self) -> str: + return self.value -class AudioExtensions: + +class AudioExtensions(str, Enum): FLAC: str = ".flac" M4A: str = ".m4a" MP4: str = ".mp4" + def __str__(self) -> str: + return self.value + -class VideoExtensions: +class VideoExtensions(str, Enum): TS: str = ".ts" + def __str__(self) -> str: + return self.value -class ManifestMimeType: + +class ManifestMimeType(str, Enum): # EMU: str = "application/vnd.tidal.emu" # APPL: str = "application/vnd.apple.mpegurl" MPD: str = "application/dash+xml" BTS: str = "application/vnd.tidal.bts" VIDEO: str = "video/mp2t" + def __str__(self) -> str: + return self.value + -class Codec: +class Codec(str, Enum): MP3: str = "MP3" AAC: str = "AAC" M4A: str = "MP4A" @@ -113,8 +134,11 @@ class Codec: PremiumCodecs: [str] = [MQA, Atmos, AC4] HQCodecs: [str] = PremiumCodecs + [FLAC] + def __str__(self) -> str: + return self.value -class MimeType: + +class MimeType(str, Enum): audio_mpeg = "audio/mpeg" audio_mp3 = "audio/mp3" audio_m4a = "audio/m4a" @@ -135,6 +159,9 @@ class MimeType: Codec.AC4: audio_ac4, } + def __str__(self) -> str: + return self.value + @staticmethod def from_audio_codec(codec): return MimeType.audio_map.get(codec, MimeType.audio_m4a)