library¶
Data classes to hold standardized metadata about songs, artists, and albums.
| CLASS | DESCRIPTION |
|---|---|
AlbumType |
Classification of album release types. |
ResourceType |
Enum representing the type of resource being handled. The UNKNOWN value is used when a provider has IDs that are |
BaseLibraryItem |
Base class for all library item types. |
User |
Base class for a user of a music library. |
Artist |
Holds info about an artist. |
Album |
Holds info about an album. |
Song |
Holds info about a song. |
Playlist |
Holds info about a playlist. |
__all__
module-attribute
¶
__all__ = [
"Album",
"AlbumType",
"Artist",
"ResourceType",
"Song",
"User",
"Playlist",
"BaseLibraryItem",
]
AlbumType
¶
Bases: Enum
Classification of album release types.
ResourceType
¶
Bases: Enum
Enum representing the type of resource being handled. The UNKNOWN value is used when a provider has IDs that are valid for multiple types, but can't determine which exact type.
BaseLibraryItem
dataclass
¶
BaseLibraryItem()
Base class for all library item types.
Provides common functionality for converting provider-specific data into
standardized Downmixer types. Subclasses should set _resource_type and
override from_provider() in their provider-specific adapter classes.
get_resource_type
classmethod
¶
get_resource_type() -> ResourceType
Returns the resource type for this class.
Source code in src/downmixer/types/library.py
57 58 59 60 | |
from_provider
classmethod
¶
from_provider(data: Any, extra_data: dict = None)
Create an instance of this class from data coming from a provider's API.
| PARAMETER | DESCRIPTION |
|---|---|
|
Data from the provider's API.
TYPE:
|
|
Extra data from provider's API to be used to make instances of this class.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
|
An instance of this class. |
Source code in src/downmixer/types/library.py
62 63 64 65 66 67 68 69 70 71 72 73 | |
from_provider_list
classmethod
¶
from_provider_list(
data: list[Any], extra_data: dict = None
) -> list
Creates a list of instances of this class from a list of objects with data coming from a provider's API.
| PARAMETER | DESCRIPTION |
|---|---|
|
List of objects with data from the provider's API.
TYPE:
|
|
Extra data from provider's API to be used to make instances of this class.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list
|
A list with instances of this class. |
Source code in src/downmixer/types/library.py
75 76 77 78 79 80 81 82 83 84 85 86 | |
to_dict
¶
to_dict() -> dict
Returns this class as a dict. Useful for serialization.
Uses the native Python dataclass.asdict() function.
| RETURNS | DESCRIPTION |
|---|---|
dict
|
Dictionary with a deep copy of the object.
TYPE:
|
Source code in src/downmixer/types/library.py
88 89 90 91 92 93 94 95 | |
from_dict
classmethod
¶
from_dict(data: dict) -> 'BaseLibraryItem'
Returns an instance of this class with parameters from the given dictionary.
| PARAMETER | DESCRIPTION |
|---|---|
|
Dictionary containing all the parameters of this object and their values.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
'BaseLibraryItem'
|
An instance of this class. |
Source code in src/downmixer/types/library.py
97 98 99 100 101 102 103 104 105 106 107 | |
User
dataclass
¶
User(
id: str = None,
name: str | None = None,
handle: str | None = None,
)
Bases: BaseLibraryItem
Base class for a user of a music library.
__hash__
¶
__hash__()
Source code in src/downmixer/types/library.py
120 121 122 123 124 125 126 | |
__str__
¶
__str__()
Source code in src/downmixer/types/library.py
128 129 | |
Artist
dataclass
¶
Artist(
name: str,
images: list[str] | None = None,
genres: list[str] | None = None,
id: str | None = None,
url: str | None = None,
)
Bases: BaseLibraryItem
Holds info about an artist.
slug
¶
slug() -> 'Artist'
Returns self with sluggified text attributes.
Source code in src/downmixer/types/library.py
144 145 146 147 148 149 150 151 152 | |
__hash__
¶
__hash__()
Source code in src/downmixer/types/library.py
154 155 156 157 158 | |
__str__
¶
__str__()
Source code in src/downmixer/types/library.py
160 161 | |
Album
dataclass
¶
Album(
name: str,
available_markets: list[str] | None = None,
artists: list[Artist] | None = None,
date: str | None = None,
tracks: list["Song"] | None = None,
track_count: int | None = None,
cover: str | None = None,
upc: str | None = None,
id: str | None = None,
url: str | None = None,
)
Bases: BaseLibraryItem
Holds info about an album. cover should be a string containing a valid URL.
title
property
¶
title: str
str: Title of the album, including artist, in the format '[primary artist] - [album name]'.
full_title
property
¶
full_title: str
str: Full title of the album, including all artists, in the format [artist 1, artist 2, ...] - [album name].
__hash__
¶
__hash__()
Source code in src/downmixer/types/library.py
181 182 183 184 185 | |
slug
¶
slug() -> 'Album'
Returns self with sluggified text attributes.
Source code in src/downmixer/types/library.py
202 203 204 205 206 207 208 209 210 211 212 213 | |
__str__
¶
__str__()
Source code in src/downmixer/types/library.py
215 216 | |
Song
dataclass
¶
Song(
name: str,
artists: list[Artist],
duration: float = 0,
album: Album | None = None,
available_markets: list[str] | None = None,
date: str | None = None,
track_number: int | None = None,
isrc: str | None = None,
lyrics: str | None = None,
id: str | None = None,
url: str | None = None,
cover: str | None = None,
)
Bases: BaseLibraryItem
Holds info about a song.
title
property
¶
title: str
str: Title of the song, including artist, in the format '[primary artist] - [song name]'.
full_title
property
¶
full_title: str
str: Full title of the song, including all artists, in the format [artist 1, artist 2, ...] - [song name].
slug
¶
slug() -> 'Song'
Returns self with sluggified text attributes.
Source code in src/downmixer/types/library.py
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 | |
__hash__
¶
__hash__()
Source code in src/downmixer/types/library.py
269 270 271 272 273 | |
__str__
¶
__str__()
Source code in src/downmixer/types/library.py
275 276 | |
Playlist
dataclass
¶
Playlist(
name: str,
description: str | None = None,
tracks: list[Song] | None = None,
images: list[dict] | None = None,
fingerprint: str | None = None,
id: str | None = None,
url: str | None = None,
owner: User | None = None,
)
Bases: BaseLibraryItem
Holds info about a playlist.
__hash__
¶
__hash__()
Source code in src/downmixer/types/library.py
294 295 296 297 298 299 300 | |
__str__
¶
__str__()
Source code in src/downmixer/types/library.py
306 307 | |