diff --git a/votify/interface/audio.py b/votify/interface/audio.py index 66eb2de..f4e3cbf 100644 --- a/votify/interface/audio.py +++ b/votify/interface/audio.py @@ -1,7 +1,6 @@ import logging from .base import SpotifyBaseInterface -from .constants import AAC_AUDIO_QUALITIES from .enums import AudioQuality from .exceptions import VotifyMediaAudioQualityNotAvailableException from .types import DecryptionKeyAv, StreamInfo, StreamInfoAv @@ -25,7 +24,7 @@ class SpotifyAudioInterface(SpotifyBaseInterface): skip_pssh: bool, ) -> StreamInfoAv | None: if ( - self.audio_quality.value not in AAC_AUDIO_QUALITIES + not self.audio_quality.mp4 or self.audio_quality.premium and not self.api.premium_session ): diff --git a/votify/interface/enums.py b/votify/interface/enums.py index 2e7d7e7..ef46472 100644 --- a/votify/interface/enums.py +++ b/votify/interface/enums.py @@ -3,11 +3,11 @@ from __future__ import annotations from enum import Enum from .constants import ( + AAC_AUDIO_QUALITIES, FORMAT_ID_MAP, MEDIA_RATING_STR_MAP, MEDIA_TYPE_STR_MAP, PREMIUM_AUDIO_QUALITIES, - AAC_AUDIO_QUALITIES, VORBIS_AUDIO_QUALITIES, ) @@ -54,18 +54,22 @@ class AudioQuality(Enum): def premium(self) -> bool: return self.value in PREMIUM_AUDIO_QUALITIES + @property + def mp4(self) -> bool: + return self.value in AAC_AUDIO_QUALITIES + @property def format_id(self) -> str | None: return FORMAT_ID_MAP.get(self.value) @property def previous_quality(self) -> "AudioQuality" | None: - if self.value in VORBIS_AUDIO_QUALITIES: + if not self.mp4: if self.value == "vorbis-high": return AudioQuality.VORBIS_MEDIUM elif self.value == "vorbis-medium": return AudioQuality.VORBIS_LOW - elif self.value in AAC_AUDIO_QUALITIES: + else: if self.value == "aac-high": return AudioQuality.AAC_MEDIUM return None