Merge branch '573-subsonic-type' into 'develop'

Fix #573: Added "type: funkwhale" and "funkwhale-version" in Subsonic responses

Closes #573

See merge request funkwhale/funkwhale!456
This commit is contained in:
Eliot Berriot 2018-10-21 15:48:57 +00:00
commit 6c7ee54dbc
4 changed files with 28 additions and 3 deletions

View file

@ -2,13 +2,22 @@ import xml.etree.ElementTree as ET
from rest_framework import renderers
import funkwhale_api
class SubsonicJSONRenderer(renderers.JSONRenderer):
def render(self, data, accepted_media_type=None, renderer_context=None):
if not data:
# when stream view is called, we don't have any data
return super().render(data, accepted_media_type, renderer_context)
final = {"subsonic-response": {"status": "ok", "version": "1.16.0"}}
final = {
"subsonic-response": {
"status": "ok",
"version": "1.16.0",
"type": "funkwhale",
"funkwhale-version": funkwhale_api.__version__,
}
}
final["subsonic-response"].update(data)
if "error" in final:
# an error was returned