diff --git a/README.rst b/README.rst index f89d432..aa1cefd 100644 --- a/README.rst +++ b/README.rst @@ -2,7 +2,7 @@ :alt: Sublime Music Logo Sublime Music is a native, GTK3 -`Subsonic`_/`Airsonic`_/`Revel`_/`Gonic`_/`Navidrome`_/\*sonic client for the +`Subsonic`_/`Airsonic`_/`Revel`_/`Gonic`_/`Navidrome`_/`Ampache`_/\*sonic client for the Linux Desktop. .. _Subsonic: http://www.subsonic.org/pages/index.jsp @@ -10,6 +10,7 @@ Linux Desktop. .. _Revel: https://gitlab.com/robozman/revel .. _Gonic: https://github.com/sentriz/gonic .. _Navidrome: https://www.navidrome.org/ +.. _Ampache: http://ampache.org/ .. figure:: https://gitlab.com/sublime-music/sublime-music/-/raw/master/docs/_static/screenshots/play-queue.png :align: center diff --git a/sublime_music/adapters/subsonic/adapter.py b/sublime_music/adapters/subsonic/adapter.py index a4529e8..4dbe3d1 100644 --- a/sublime_music/adapters/subsonic/adapter.py +++ b/sublime_music/adapters/subsonic/adapter.py @@ -592,8 +592,12 @@ class SubsonicAdapter(Adapter): def delete_playlist(self, playlist_id: str): self._get_json(self._make_url("deletePlaylist"), id=playlist_id) - def get_cover_art_uri(self, cover_art_id: str, scheme: str, size: int) -> str: - params = {"id": cover_art_id, "size": size, **self._get_params()} + def get_cover_art_uri(self, cover_art: str, scheme: str, size: int) -> str: + # Some servers return a full URL instead of an ID + if cover_art.startswith("http://") or cover_art.startswith("https://"): + return cover_art + + params = {"id": cover_art, "size": size, **self._get_params()} return self._make_url("getCoverArt") + "?" + urlencode(params) def get_song_file_uri(self, song_id: str, schemes: Iterable[str]) -> str: diff --git a/sublime_music/adapters/subsonic/api_objects.py b/sublime_music/adapters/subsonic/api_objects.py index 73561bd..730a725 100644 --- a/sublime_music/adapters/subsonic/api_objects.py +++ b/sublime_music/adapters/subsonic/api_objects.py @@ -17,10 +17,12 @@ from dateutil import parser from .. import api_objects as SublimeAPI -# Translation map +# Translation map for encoding/decoding API results. For instance some servers +# may return a string where an integer is required. decoder_functions = { datetime: (lambda s: parser.parse(s) if s else None), - timedelta: (lambda s: timedelta(seconds=s) if s else None), + timedelta: (lambda s: timedelta(seconds=float(s)) if s else None), + int: (lambda s: int(s) if s else None), } encoder_functions = { datetime: (lambda d: datetime.strftime(d, "%Y-%m-%dT%H:%M:%S.%f%z") if d else None),