From 379bbebbf186162df76ed5a71ca4e4ce2a5190b8 Mon Sep 17 00:00:00 2001 From: Sebastian Mohr Date: Fri, 19 Jun 2026 10:39:14 +0200 Subject: [PATCH] Reverted attributes change. Not really in scope here and needs a bit more refactoring to be consistent. --- beetsplug/tidal/__init__.py | 5 +---- beetsplug/tidal/api_types.py | 40 +++++++++++++++++++++--------------- 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/beetsplug/tidal/__init__.py b/beetsplug/tidal/__init__.py index c7edc6ac6..d4374f3f5 100644 --- a/beetsplug/tidal/__init__.py +++ b/beetsplug/tidal/__init__.py @@ -29,7 +29,6 @@ if TYPE_CHECKING: from .api_types import ( AlbumAttributes, - Attributes, ResourceIdentifier, TidalAlbum, TidalArtist, @@ -37,8 +36,6 @@ if TYPE_CHECKING: TrackAttributes, ) - PopularityAttributes = Attributes - log = getLogger("beets.tidal") @@ -485,7 +482,7 @@ class TidalPlugin(MetadataSourcePlugin): return None @staticmethod - def _parse_popularity(attributes: PopularityAttributes) -> int: + def _parse_popularity(attributes: AlbumAttributes | TrackAttributes) -> int: return round(attributes["popularity"] * 100) def sync_item_popularity( diff --git a/beetsplug/tidal/api_types.py b/beetsplug/tidal/api_types.py index 87b82f409..7e61e6b14 100644 --- a/beetsplug/tidal/api_types.py +++ b/beetsplug/tidal/api_types.py @@ -42,39 +42,38 @@ class ArtistAttributes(TypedDict): spotlighted: NotRequired[bool] -class Attributes(TypedDict): - title: str - duration: str # ISO 8601 - explicit: bool - mediaTags: list[str] - popularity: float - - accessType: NotRequired[Literal["PUBLIC", "UNLISTED", "PRIVATE"]] - copyright: NotRequired[Copyright] - createdAt: NotRequired[str] # ISO 8601 datetime - externalLinks: NotRequired[list[ExternalLink]] - version: NotRequired[str] - - -class AlbumAttributes(Attributes): +class AlbumAttributes(TypedDict): # see "Albums_Attributes" # in https://tidal-music.github.io/tidal-api-reference/tidal-api-oas.json # Required albumType: Literal["ALBUM", "EP", "SINGLE"] barcodeId: str + duration: str # ISO 8601 + explicit: bool + mediaTags: list[str] numberOfItems: int numberOfVolumes: int + popularity: float + title: str # Optional + accessType: NotRequired[Literal["PUBLIC", "UNLISTED", "PRIVATE"]] + copyright: NotRequired[Copyright] + createdAt: NotRequired[str] # ISO 8601 datetime + externalLinks: NotRequired[list[ExternalLink]] releaseDate: NotRequired[str] # ISO date YYYY-MM-DD + version: NotRequired[str] -class TrackAttributes(Attributes): +class TrackAttributes(TypedDict): # see "Tracks_Attributes" # in https://tidal-music.github.io/tidal-api-reference/tidal-api-oas.json # Required + title: str + duration: str # ISO 8601 + explicit: bool isrc: str key: Literal[ "UNKNOWN", @@ -107,9 +106,18 @@ class TrackAttributes(Attributes): "MELODIC_MINOR", "PENTATONIC_MINOR", ] + mediaTags: list[str] + popularity: float + + # Optional + accessType: NotRequired[Literal["PUBLIC", "UNLISTED", "PRIVATE"]] bpm: NotRequired[float] + copyright: NotRequired[Copyright] + createdAt: NotRequired[str] # ISO 8601 datetime + externalLinks: NotRequired[list[ExternalLink]] spotlighted: NotRequired[bool] toneTags: NotRequired[list[str]] + version: NotRequired[str] class SearchAttributes(TypedDict):