mirror of
https://github.com/oskvr37/tiddl.git
synced 2026-06-13 12:15:13 +03:00
🏷️ add not required to TrackResponse
This commit is contained in:
+6
-4
@@ -131,12 +131,14 @@ def main():
|
||||
track = api.getTrack(int(track_id), track_quality)
|
||||
quality = TRACK_QUALITY[track["audioQuality"]]
|
||||
|
||||
# qualities below master dont have `bitDepth` and `sampleRate`
|
||||
# TODO: add special types for master quality 🏷️
|
||||
|
||||
MASTER_QUALITIES: list[TrackQuality] = ["HI_RES_LOSSLESS", "LOSSLESS"]
|
||||
if track["audioQuality"] in MASTER_QUALITIES:
|
||||
details = f"{track['bitDepth']} bit {track['sampleRate']/1000:.1f} kHz"
|
||||
bit_depth, sample_rate = track.get("bitDepth"), track.get("sampleRate")
|
||||
if bit_depth is None or sample_rate is None:
|
||||
raise ValueError(
|
||||
"bitDepth and sampleRate must be provided for master qualities"
|
||||
)
|
||||
details = f"{bit_depth} bit {sample_rate/1000:.1f} kHz"
|
||||
else:
|
||||
details = quality["details"]
|
||||
|
||||
|
||||
+4
-3
@@ -1,9 +1,10 @@
|
||||
from typing import TypedDict, Optional, List, Any, Literal
|
||||
from typing import TypedDict, Optional, List, Any, Literal, NotRequired
|
||||
|
||||
|
||||
TrackQuality = Literal["LOW", "HIGH", "LOSSLESS", "HI_RES_LOSSLESS"]
|
||||
TrackArg = Literal["low", "normal", "high", "master"]
|
||||
|
||||
|
||||
class QualityDetails(TypedDict):
|
||||
name: str
|
||||
details: str
|
||||
@@ -135,5 +136,5 @@ class TrackResponse(TypedDict):
|
||||
albumPeakAmplitude: float
|
||||
trackReplayGain: float
|
||||
trackPeakAmplitude: float
|
||||
bitDepth: int
|
||||
sampleRate: int
|
||||
bitDepth: NotRequired[int]
|
||||
sampleRate: NotRequired[int]
|
||||
|
||||
Reference in New Issue
Block a user