protocols¶
Protocol definitions for music provider capabilities.
This module defines Protocol classes that represent different capabilities a music provider can implement. Providers can implement one or more of these protocols to indicate what features they support (metadata fetching or library access).
Audio download and lyrics protocols live in the consuming application (e.g. ripper), as they depend on application-level types like LocalFile.
| CLASS | DESCRIPTION |
|---|---|
SupportsMetadata |
Protocol for providers that can search and fetch music metadata. |
SupportsLibrary |
Protocol for providers that can access a user's music library. |
SupportsMetadata
¶
Bases: Protocol
Protocol for providers that can search and fetch music metadata.
Implement this protocol to enable searching for music and retrieving detailed information about songs, albums, artists, playlists, and users from a provider.
search
¶
search(
query: str,
accepted_types: list[ResourceType] = None,
compare_with: Song = None,
) -> list[SearchResult]
Search for music resources matching the given query.
| PARAMETER | DESCRIPTION |
|---|---|
|
The search query string.
TYPE:
|
|
Optional list of resource types to filter results. If None, all resource types are included.
TYPE:
|
|
Optional Song object to match and sort results from.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[SearchResult]
|
A list of SearchResult objects matching the query. |
Source code in src/downmixer/providers/protocols.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | |
fetch_song
abstractmethod
¶
fetch_song(id: str) -> Song
Fetch detailed information about a song.
| PARAMETER | DESCRIPTION |
|---|---|
|
The provider-specific identifier for the song.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Song
|
A Song object containing the song's metadata. |
Source code in src/downmixer/providers/protocols.py
47 48 49 50 51 52 53 54 55 56 57 | |
fetch_album
abstractmethod
¶
fetch_album(id: str) -> Album
Fetch detailed information about an album.
| PARAMETER | DESCRIPTION |
|---|---|
|
The provider-specific identifier for the album.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Album
|
An Album object containing the album's metadata. |
Source code in src/downmixer/providers/protocols.py
59 60 61 62 63 64 65 66 67 68 69 | |
fetch_artist
abstractmethod
¶
fetch_artist(id: str) -> Artist
Fetch detailed information about an artist.
| PARAMETER | DESCRIPTION |
|---|---|
|
The provider-specific identifier for the artist.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Artist
|
An Artist object containing the artist's metadata. |
Source code in src/downmixer/providers/protocols.py
71 72 73 74 75 76 77 78 79 80 81 | |
fetch_playlist
abstractmethod
¶
fetch_playlist(id: str) -> Playlist
Fetch detailed information about a playlist.
| PARAMETER | DESCRIPTION |
|---|---|
|
The provider-specific identifier for the playlist.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Playlist
|
A Playlist object containing the playlist's metadata. |
Source code in src/downmixer/providers/protocols.py
83 84 85 86 87 88 89 90 91 92 93 | |
fetch_user
abstractmethod
¶
fetch_user(id: str) -> User
Fetch detailed information about a user.
| PARAMETER | DESCRIPTION |
|---|---|
|
The provider-specific identifier for the user.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
User
|
A User object containing the user's profile information. |
Source code in src/downmixer/providers/protocols.py
95 96 97 98 99 100 101 102 103 104 105 | |
fetch_list_songs
abstractmethod
¶
fetch_list_songs(id: str) -> list[Song]
Retrieves the all the songs from a playlist or album as a list. Args: id (str): A string containing a valid ID for the provider.
| RETURNS | DESCRIPTION |
|---|---|
list[Song]
|
All songs in the object. |
Source code in src/downmixer/providers/protocols.py
107 108 109 110 111 112 113 114 115 116 | |
SupportsLibrary
¶
Bases: Protocol
Protocol for providers that can access a user's music library.
Implement this protocol to enable fetching the authenticated user's saved playlists, albums, songs, and followed artists from a provider.
fetch_user_playlists
abstractmethod
¶
fetch_user_playlists() -> list[Playlist]
Retrieves the all the user's playlists in a list.
| RETURNS | DESCRIPTION |
|---|---|
list[Playlist]
|
User's playlists as a list of Playlist objects. |
Source code in src/downmixer/providers/protocols.py
127 128 129 130 131 132 133 134 | |
fetch_user_albums
abstractmethod
¶
fetch_user_albums() -> list[Album]
Retrieves the all the user's saved albums in a list.
| RETURNS | DESCRIPTION |
|---|---|
list[Album]
|
User's albums as a list of Album objects. |
Source code in src/downmixer/providers/protocols.py
136 137 138 139 140 141 142 143 | |
fetch_user_songs
abstractmethod
¶
fetch_user_songs() -> list[Song]
Retrieves the all the user's liked/saved songs in a list (for example, on Spotify, should return user's saved tracks).
| RETURNS | DESCRIPTION |
|---|---|
list[Song]
|
User's playlists as a list of Playlist objects. |
Source code in src/downmixer/providers/protocols.py
145 146 147 148 149 150 151 152 153 | |
fetch_user_artists
abstractmethod
¶
fetch_user_artists() -> list[Artist]
Retrieves the all the user's followed artists in a list.
| RETURNS | DESCRIPTION |
|---|---|
list[Artist]
|
User's followed artists as a list of artist names. |
Source code in src/downmixer/providers/protocols.py
155 156 157 158 159 160 161 162 | |