sublime_music.adapters.subsonic.adapter module

exception sublime_music.adapters.subsonic.adapter.ServerError(status_code, message)[source]

Bases: Exception

Parameters
  • status_code (int) –

  • message (str) –

__init__(status_code, message)[source]
Parameters
  • status_code (int) –

  • message (str) –

class sublime_music.adapters.subsonic.adapter.SubsonicAdapter(config, data_directory)[source]

Bases: sublime_music.adapters.adapter_base.Adapter

Defines an adapter which retrieves its data from a Subsonic server

Parameters
__init__(config, data_directory)[source]

This function should be overridden by inheritors of Adapter and should be used to do whatever setup is required for the adapter.

This should do the bare minimum to get things set up, since this blocks the main UI loop. If you need to do longer initialization, use the initial_sync function.

Parameters
  • config (sublime_music.adapters.adapter_base.ConfigurationStore) – The adapter configuration. The keys of are the configuration parameter names as defined by the return value of the get_config_parameters function. The values are the actual value of the configuration parameter.

  • data_directory (pathlib.Path) – the directory where the adapter can store data. This directory is guaranteed to exist.

can_create_playlist = True
can_delete_playlist = True
can_get_album = True
can_get_albums = True
can_get_artist = True
can_get_artists = True
can_get_cover_art_uri = True
can_get_directory = True
property can_get_genres: bool

Whether or not the adapter supports get_genres.

can_get_ignored_articles = True
property can_get_play_queue: bool

Whether or not the adapter supports get_play_queue.

can_get_playlist_details = True
can_get_playlists = True
can_get_song_details = True
can_get_song_file_uri = True
can_get_song_rating = True
can_get_song_stream_uri = True
property can_save_play_queue: bool

Whether or not the adapter supports save_play_queue.

can_scrobble_song = True
property can_set_song_rating: bool

Whether or not the adapter supports set_song_rating.

can_stream = True
can_update_playlist = True
create_playlist(name, songs=None)[source]

Creates a playlist of the given name with the given songs.

Parameters
Returns

A sublime_music.adapter.api_objects.Playlist object for the created playlist. If getting this information will incurr network overhead, then just return None.

Return type

Optional[sublime_music.adapters.api_objects.Playlist]

delete_playlist(playlist_id)[source]

Deletes the given playlist.

Parameters

playlist_id (str) – The human-readable name of the playlist.

get_album(album_id)[source]

Get the details for the given album ID.

Parameters

album_id (str) – The ID of the album to get the details for.

Returns

The :classs`sublime_music.adapters.api_objects.Album`

Return type

sublime_music.adapters.api_objects.Album

get_albums(query, sort_direction='ascending')[source]

Get a list of all of the albums known to the adapter for the given query.

Note

This request is not paged. You should do any page management to get all of the albums matching the query internally.

Parameters
Returns

A list of all of the sublime_music.adapter.api_objects.Album objects known to the adapter that match the query.

Return type

Sequence[sublime_music.adapters.api_objects.Album]

get_artist(artist_id)[source]

Get the details for the given artist ID.

Parameters

artist_id (str) – The ID of the artist to get the details for.

Returns

The :classs`sublime_music.adapters.api_objects.Artist`

Return type

sublime_music.adapters.api_objects.Artist

get_artists()[source]

Get a list of all of the artists known to the adapter.

Returns

A list of all of the sublime_music.adapter.api_objects.Artist objects known to the adapter.

Return type

Sequence[sublime_music.adapters.api_objects.Artist]

static get_configuration_form(config_store)[source]

This function should return a Gtk.Box that gets any inputs required from the user and uses the given config_store to store the configuration values.

The Gtk.Box must expose a signal with the name "config-valid-changed" which returns a single boolean value indicating whether or not the configuration is valid.

If you don’t want to implement all of the GTK logic yourself, and just want a simple form, then you can use the ConfigureServerForm class to generate a form in a declarative manner.

Parameters

config_store (sublime_music.adapters.adapter_base.ConfigurationStore) –

Return type

gi.overrides.Gtk.Box

get_cover_art_uri(cover_art, scheme, size)[source]

Get a URI for a given cover_art_id.

Parameters
  • cover_art_id – The song, album, or artist ID.

  • scheme (str) – The URI scheme that should be returned. It is guaranteed that scheme will be one of the schemes returned by supported_schemes.

  • size (int) – The size of image to return. Denotes the max width or max height (whichever is larger).

  • cover_art (str) –

Returns

The URI as a string.

Return type

str

get_directory(directory_id)[source]

Return a Directory object representing the song files and directories in the given directory. This may not make sense for your adapter (for example, if there’s no actual underlying filesystem). In that case, make sure to set can_get_directory to False.

Parameters

directory_id (str) – The directory to retrieve. If the special value "root" is given, the adapter should list all of the directories at the root of the filesystem tree.

Returns

A list of the sublime_music.adapter.api_objects.Directory and sublime_music.adapter.api_objects.Song objects in the given directory.

Return type

sublime_music.adapters.api_objects.Directory

get_genres()[source]

Get a list of the genres known to the adapter.

Returns

A list of all of the :classs`sublime_music.adapter.api_objects.Genre` objects known to the adapter.

Return type

Sequence[sublime_music.adapters.api_objects.Genre]

get_ignored_articles()[source]

Get the list of articles to ignore when sorting artists by name.

Returns

A set of articles (i.e. The, A, El, La, Los) to ignore when sorting artists.

Return type

Set[str]

get_play_queue()[source]

Returns the state of the play queue for this user. This could be used to restore the play queue from the cloud.

Returns

The cloud-saved play queue as a sublime_music.adapter.api_objects.PlayQueue object.

Return type

Optional[sublime_music.adapters.api_objects.PlayQueue]

get_playlist_details(playlist_id)[source]

Get the details for the given playlist_id. If the playlist_id does not exist, then this function should throw an exception.

Parameters

playlist_id (str) – The ID of the playlist to retrieve.

Returns

A sublime_music.adapter.api_objects.Play object for the given playlist.

Return type

sublime_music.adapters.api_objects.Playlist

get_playlists()[source]

Get a list of all of the playlists known by the adapter.

Returns

A list of all of the sublime_music.adapter.api_objects.Playlist objects known to the adapter.

Return type

Sequence[sublime_music.adapters.api_objects.Playlist]

get_song_details(song_id)[source]

Get the details for a given song ID.

Parameters

song_id (str) – The ID of the song to get the details for.

Returns

The sublime_music.adapters.api_objects.Song.

Return type

sublime_music.adapters.api_objects.Song

get_song_file_uri(song_id, schemes)[source]

Get a URI for a given song. This URI must give the full file.

Parameters
  • song_id (str) – The ID of the song to get a URI for.

  • schemes (Iterable[str]) – A set of URI schemes that can be returned. It is guaranteed that all of the items in schemes will be one of the schemes returned by supported_schemes.

Returns

The URI for the given song.

Return type

str

get_song_stream_uri(song_id)[source]

Get a URI for streaming the given song.

Parameters

song_id (str) – The ID of the song to get the stream URI for.

Returns

the stream URI for the given song.

Return type

str

static get_ui_info()[source]
Returns

A UIInfo object.

Return type

sublime_music.adapters.adapter_base.UIInfo

initial_sync()[source]

Perform any operations that are required to get the adapter functioning properly. For example, this function can be used to wait for an initial ping to come back from the server.

static migrate_configuration(config_store)[source]

This function allows the adapter to migrate its configuration.

Parameters

config_store (sublime_music.adapters.adapter_base.ConfigurationStore) –

on_offline_mode_change(offline_mode)[source]

This function should be used to handle any operations that need to be performed when Sublime Music goes from online to offline mode or vice versa.

Parameters

offline_mode (bool) –

property ping_status: bool

If the adapter is_networked, then this function should return whether or not the server can be pinged. This function must provide an answer instantly (it can’t actually ping the server). This function is called very often, and even a few milliseconds delay stacks up quickly and can block the UI thread.

One option is to ping the server every few seconds and cache the result of the ping and use that as the result of this function.

save_play_queue(song_ids, current_song_index=None, position=None)[source]

Save the current play queue to the cloud.

Parameters
scrobble_song(song)[source]

Scrobble the given song.

Params song

The sublime_music.adapters.api_objects.Song to scrobble.

Parameters

song (sublime_music.adapters.api_objects.Song) –

search(query)[source]

Return search results fro the given query.

Parameters

query (str) – The query string.

Returns

A sublime_music.adapters.api_objects.SearchResult object representing the results of the search.

Return type

sublime_music.adapters.api_objects.SearchResult

set_song_rating(song_id, rating)[source]

Rate the given song

Parameters
  • song_id (str) – A string which uniquely identifies the file (song)

  • rating (int | None) – The rating between 1 and 5 (inclusive), or None to remove the rating

shutdown()[source]

This function is called when the app is being closed or the server is changing. This should be used to clean up anything that is necessary such as writing a cache to disk, disconnecting from a server, etc.

property supported_artist_query_types: Set[sublime_music.adapters.adapter_base.AlbumSearchQuery.Type]

A set of the query types that this adapter can service.

Returns

A set of AlbumSearchQuery.Type objects.

property supported_schemes: Iterable[str]

Specifies a collection of scheme names that can be provided by the adapter for a given resource (song or cover art) right now.

Examples of values that could be provided include http, https, file, or ftp.

update_playlist(playlist_id, name=None, comment=None, public=None, song_ids=None, append_song_ids=None)[source]

Updates a given playlist. If a parameter is None, then it will be ignored and no updates will occur to that field.

Parameters
  • playlist_id (str) – The human-readable name of the playlist.

  • name (Optional[str]) – The human-readable name of the playlist.

  • comment (Optional[str]) – The playlist comment.

  • public (Optional[bool]) – This is very dependent on the adapter, but if the adapter has a shared/public vs. not shared/private playlists concept, setting this to True will make the playlist shared/public.

  • song_ids (Optional[Sequence[str]]) – A list of song IDs that should be included in the playlist.

  • append_song_ids (Optional[Sequence[str]]) –

Returns

A sublime_music.adapter.api_objects.Playlist object for the updated playlist.

Return type

sublime_music.adapters.api_objects.Playlist

version_at_least(version)[source]
Parameters

version (str) –

Return type

bool