Reverted attributes change. Not really in scope here and needs a bit more

refactoring to be consistent.
This commit is contained in:
Sebastian Mohr
2026-06-19 10:39:14 +02:00
parent cf73922cc6
commit 379bbebbf1
2 changed files with 25 additions and 20 deletions

View File

@@ -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(

View File

@@ -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):