From 38ab05195b7c6045e4a24d06f2fa84d14a156472 Mon Sep 17 00:00:00 2001 From: Eliot Berriot Date: Wed, 3 Jul 2019 11:35:34 +0200 Subject: [PATCH] Fix #867: Fixed remaining transcoding issue with Subsonic API --- api/funkwhale_api/subsonic/views.py | 2 +- api/tests/subsonic/test_views.py | 9 +++++---- changes/changelog.d/867.bugfix | 1 + 3 files changed, 7 insertions(+), 5 deletions(-) create mode 100644 changes/changelog.d/867.bugfix diff --git a/api/funkwhale_api/subsonic/views.py b/api/funkwhale_api/subsonic/views.py index 52f37c870..909f7a6e4 100644 --- a/api/funkwhale_api/subsonic/views.py +++ b/api/funkwhale_api/subsonic/views.py @@ -256,7 +256,7 @@ class SubsonicViewSet(viewsets.GenericViewSet): if max_bitrate: max_bitrate = max_bitrate * 1000 - format = data.get("format", "raw") or None + format = data.get("format") or None if max_bitrate and not format: # specific bitrate requested, but no format specified # so we use a default one, cf #867. This helps with clients diff --git a/api/tests/subsonic/test_views.py b/api/tests/subsonic/test_views.py index cde07ac53..e227f4d1d 100644 --- a/api/tests/subsonic/test_views.py +++ b/api/tests/subsonic/test_views.py @@ -288,15 +288,16 @@ def test_stream_transcode( mocker, settings, ): + upload = factories["music.Upload"](playable=True) + params = {"id": upload.track.pk, "maxBitRate": max_bitrate} + if format: + params["format"] = format settings.SUBSONIC_DEFAULT_TRANSCODING_FORMAT = default_transcoding_format url = reverse("api:subsonic-stream") mocked_serve = mocker.patch.object( music_views, "handle_serve", return_value=Response() ) - upload = factories["music.Upload"](playable=True) - response = logged_in_api_client.get( - url, {"id": upload.track.pk, "maxBitRate": max_bitrate, "format": format} - ) + response = logged_in_api_client.get(url, params) mocked_serve.assert_called_once_with( upload=upload, diff --git a/changes/changelog.d/867.bugfix b/changes/changelog.d/867.bugfix new file mode 100644 index 000000000..ab690cc16 --- /dev/null +++ b/changes/changelog.d/867.bugfix @@ -0,0 +1 @@ +Fixed remaining transcoding issue with Subsonic API (#867)