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_delete_cached_songs(song_ids, on_song_delete)[source]
Parameters
static batch_download_songs(song_ids, before_download, on_song_download_complete, one_at_a_time=False, delay=0.0)[source]
Parameters
Return type

sublime_music.adapters.manager.Result[None]

static batch_permanently_cache_songs(song_ids, before_download, on_song_download_complete)[source]
Parameters
Return type

sublime_music.adapters.manager.Result[None]

static can_batch_download_songs()[source]
Return type

bool

static can_create_playlist()[source]
Return type

bool

static can_delete_playlist()[source]
Return type

bool

static can_get_artist()[source]
Return type

bool

static can_get_artists()[source]
Return type

bool

static can_get_directory()[source]
Return type

bool

static can_get_genres()[source]
Return type

bool

static can_get_play_queue()[source]
Return type

bool

static can_get_playlist_details()[source]
Return type

bool

static can_get_playlists()[source]
Return type

bool

static can_get_song_file_uri()[source]
Return type

bool

static can_get_song_rating()[source]
Return type

bool

static can_get_song_stream_uri()[source]
Return type

bool

static can_save_play_queue()[source]
Return type

bool

static can_scrobble_song()[source]
Return type

bool

Return type

bool

static can_set_song_rating()[source]
Return type

bool

static can_update_playlist()[source]
Return type

bool

static cancel_download_songs(song_ids)[source]
Parameters

song_ids (Iterable[str]) –

static clear_entire_cache()[source]
static clear_song_cache()[source]
static create_playlist(name, songs=None)[source]
Parameters
Return type

sublime_music.adapters.manager.Result[Optional[sublime_music.adapters.api_objects.Playlist]]

current_download_ids: Set[str] = {}
static delete_playlist(playlist_id)[source]
Parameters

playlist_id (str) –

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
  • album_id (str) –

  • before_download (Callable[[], None]) –

  • force (bool) –

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
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
  • artist_id (str) –

  • before_download (Callable[[], None]) –

  • force (bool) –

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

song_ids (Sequence[str]) –

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]
Parameters
Return type

sublime_music.adapters.manager.Result[str]

static get_directory(directory_id, before_download=<function AdapterManager.<lambda>>, force=False)[source]
Parameters
  • directory_id (str) –

  • before_download (Callable[[], None]) –

  • force (bool) –

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_ping_status()[source]
Return type

bool

static get_play_queue()[source]
Return type

sublime_music.adapters.manager.Result[Optional[sublime_music.adapters.api_objects.PlayQueue]]

static get_playlist_details(playlist_id, before_download=<function AdapterManager.<lambda>>, force=False, allow_download=True)[source]
Parameters
  • playlist_id (str) –

  • before_download (Callable[[], None]) –

  • force (bool) –

  • allow_download (bool) –

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
  • before_download (Callable[[], None]) –

  • force (bool) –

  • allow_download (bool) –

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
  • song_id (str) –

  • allow_download (bool) –

  • before_download (Callable[[], None]) –

  • force (bool) –

Return type

sublime_music.adapters.manager.Result[sublime_music.adapters.api_objects.Song]

static get_song_file_uri(song)[source]
Parameters

song (sublime_music.adapters.api_objects.Song) –

Return type

str

static get_song_stream_uri(song)[source]
Parameters

song (sublime_music.adapters.api_objects.Song) –

Return type

str

static get_supported_artist_query_types()[source]
Return type

Set[sublime_music.adapters.adapter_base.AlbumSearchQuery.Type]

static ground_truth_adapter_is_networked()[source]
Return type

bool

static initial_sync()[source]
Return type

sublime_music.adapters.manager.Result[None]

is_shutting_down: bool = False
static on_offline_mode_change(offline_mode)[source]
Parameters

offline_mode (bool) –

static reset(config, on_song_download_progress)[source]
Parameters
static save_play_queue(song_ids, current_song_index=None, position=None)[source]
Parameters
static scrobble_song(song)[source]
Parameters

song (sublime_music.adapters.api_objects.Song) –

static search(query, search_callback, before_download=<function AdapterManager.<lambda>>)[source]
Parameters
Return type

sublime_music.adapters.manager.Result[bool]

static set_song_rating(song, rating)[source]
Parameters
Return type

sublime_music.adapters.manager.Result[None]

static shutdown()[source]
static sort_by_ignored_articles(it, key, use_ground_truth_adapter=False)[source]
Parameters
  • it (Iterable[sublime_music.adapters.manager._S]) –

  • key (Callable[[sublime_music.adapters.manager._S], str]) –

  • use_ground_truth_adapter (bool) –

Return type

List[sublime_music.adapters.manager._S]

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)
Parameters
Return type

None

current_bytes: Optional[int] = None
exception: Optional[Exception] = None
property progress_fraction: Optional[float]
total_bytes: Optional[int] = None
type: sublime_music.adapters.manager.DownloadProgress.Type
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 a concurrent.futures.Future, but it resolves immediately if the data already exists.

Parameters
  • data_resolver (Union[sublime_music.adapters.manager.T, Callable[[], sublime_music.adapters.manager.T]]) –

  • is_download (bool) –

  • default_value (Optional[sublime_music.adapters.manager.T]) –

  • on_cancel (Optional[Callable[[], None]]) –

__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]) –

  • on_cancel (Optional[Callable[[], None]]) –

add_done_callback(fn, *args)[source]

Attaches the callable fn to the future.

Parameters

fn (Callable) –

cancel()[source]

Cancel the future, or do nothing if the data already exists.

Return type

bool

cancelled()[source]
Return type

bool

property data_is_available: bool

Whether or not the data is available at the current moment. This can be used to determine whether or not the UI needs to put the callback into a GLib.idle_add call.

result()[source]

Retrieve the actual data. If the data exists already, then return it, otherwise, blocking-wait on the future’s result.

Return type

sublime_music.adapters.manager.T