sublime_music.adapters.manager module
- class sublime_music.adapters.manager.AdapterManager[source]
Bases:
object
- R
alias of TypeVar(‘R’)
- TAdapter
alias of TypeVar(‘TAdapter’, bound=
sublime_music.adapters.adapter_base.Adapter
)
- __init__()[source]
This should not ever be called. You should only ever use the static methods on this class.
- available_adapters: Set[Any] = {<class 'sublime_music.adapters.subsonic.adapter.SubsonicAdapter'>, <class 'sublime_music.adapters.filesystem.adapter.FilesystemAdapter'>}
- static batch_download_songs(song_ids, before_download, on_song_download_complete, one_at_a_time=False, delay=0.0)[source]
- static create_playlist(name, songs=None)[source]
- Parameters
name (str) –
songs (Optional[Sequence[sublime_music.adapters.api_objects.Song]]) –
- Return type
sublime_music.adapters.manager.Result[Optional[sublime_music.adapters.api_objects.Playlist]]
- download_executor: concurrent.futures.thread.ThreadPoolExecutor = <concurrent.futures.thread.ThreadPoolExecutor object>
- download_set_lock = <unlocked _thread.lock object>
- executor: concurrent.futures.thread.ThreadPoolExecutor = <concurrent.futures.thread.ThreadPoolExecutor object>
- static get_album(album_id, before_download=<function AdapterManager.<lambda>>, force=False)[source]
- Parameters
- Return type
sublime_music.adapters.manager.Result[sublime_music.adapters.api_objects.Album]
- static get_albums(query, sort_direction='ascending', before_download=<function AdapterManager.<lambda>>, use_ground_truth_adapter=False)[source]
- Parameters
query (sublime_music.adapters.adapter_base.AlbumSearchQuery) –
sort_direction (str) –
before_download (Callable[[], None]) –
use_ground_truth_adapter (bool) –
- Return type
sublime_music.adapters.manager.Result[Sequence[sublime_music.adapters.api_objects.Album]]
- static get_artist(artist_id, before_download=<function AdapterManager.<lambda>>, force=False)[source]
- Parameters
- Return type
sublime_music.adapters.manager.Result[sublime_music.adapters.api_objects.Artist]
- static get_artists(force=False, before_download=<function AdapterManager.<lambda>>)[source]
- Parameters
- Return type
sublime_music.adapters.manager.Result[Sequence[sublime_music.adapters.api_objects.Artist]]
- static get_cached_statuses(song_ids)[source]
- Parameters
- Return type
Sequence[sublime_music.adapters.adapter_base.SongCacheStatus]
- static get_cover_art_uri(cover_art_id, scheme, size=300, before_download=None, force=False, allow_download=True)[source]
- static get_directory(directory_id, before_download=<function AdapterManager.<lambda>>, force=False)[source]
- Parameters
- Return type
sublime_music.adapters.manager.Result[sublime_music.adapters.api_objects.Directory]
- static get_genres(force=False)[source]
- Parameters
force (bool) –
- Return type
sublime_music.adapters.manager.Result[Sequence[sublime_music.adapters.api_objects.Genre]]
- static get_playlist_details(playlist_id, before_download=<function AdapterManager.<lambda>>, force=False, allow_download=True)[source]
- Parameters
- Return type
sublime_music.adapters.manager.Result[sublime_music.adapters.api_objects.Playlist]
- static get_playlists(before_download=<function AdapterManager.<lambda>>, force=False, allow_download=True)[source]
- Parameters
- Return type
sublime_music.adapters.manager.Result[Sequence[sublime_music.adapters.api_objects.Playlist]]
- static get_song_details(song_id, allow_download=True, before_download=<function AdapterManager.<lambda>>, force=False)[source]
- Parameters
- Return type
sublime_music.adapters.manager.Result[sublime_music.adapters.api_objects.Song]
- static reset(config, on_song_download_progress)[source]
- Parameters
config (Any) –
on_song_download_progress (Callable[[str, sublime_music.adapters.manager.DownloadProgress], None]) –
- static search(query, search_callback, before_download=<function AdapterManager.<lambda>>)[source]
- Parameters
query (str) –
search_callback (Callable[[sublime_music.adapters.api_objects.SearchResult], None]) –
before_download (Callable[[], None]) –
- Return type
- static update_playlist(playlist_id, name=None, comment=None, public=False, song_ids=None, append_song_ids=None, before_download=<function AdapterManager.<lambda>>)[source]
- Parameters
- Return type
sublime_music.adapters.manager.Result[sublime_music.adapters.api_objects.Playlist]
- class sublime_music.adapters.manager.DownloadProgress(type: sublime_music.adapters.manager.DownloadProgress.Type, total_bytes: Optional[int] = None, current_bytes: Optional[int] = None, exception: Optional[Exception] = None)[source]
Bases:
object
- Parameters
- Return type
None
- class Type(value)[source]
Bases:
enum.Enum
An enumeration.
- CANCELLED = 3
- DONE = 2
- ERROR = 4
- PROGRESS = 1
- QUEUED = 0
- __init__(type, total_bytes=None, current_bytes=None, exception=None)
- class sublime_music.adapters.manager.Result(data_resolver, *args, is_download=False, default_value=None, on_cancel=None)[source]
Bases:
Generic
[sublime_music.adapters.manager.T
]A result from a
AdapterManager
function. This is effectively a wrapper around aconcurrent.futures.Future
, but it resolves immediately if the data already exists.- Parameters
- __init__(data_resolver, *args, is_download=False, default_value=None, on_cancel=None)[source]
Creates a
Result
object.- Parameters
data_resolver (Union[sublime_music.adapters.manager.T, Callable[[], sublime_music.adapters.manager.T]]) – the actual data, or a function that will return the actual data. If the latter, the function will be executed by the thread pool.
is_download (bool) – whether or not this result requires a file download. If it does, then it uses a separate executor.
default_value (Optional[sublime_music.adapters.manager.T]) –
- add_done_callback(fn, *args)[source]
Attaches the callable
fn
to the future.- Parameters
fn (Callable) –