funquail/api/funquail_api/subsonic/negotiation.py
Shin'ya Minazuki 54c6d22102 音楽で楽しみましょう!-Let's have fun with music!-
Signed-off-by: Shin'ya Minazuki <shinyoukai@laidback.moe>
2026-01-24 16:16:49 -03:00

18 lines
611 B
Python

from rest_framework import exceptions, negotiation
from . import renderers
MAPPING = {
"json": (renderers.SubsonicJSONRenderer(), "application/json"),
"xml": (renderers.SubsonicXMLRenderer(), "text/xml"),
}
class SubsonicContentNegociation(negotiation.DefaultContentNegotiation):
def select_renderer(self, request, renderers, format_suffix=None):
data = request.GET or request.POST
requested_format = data.get("f", "xml")
try:
return MAPPING[requested_format]
except KeyError:
raise exceptions.NotAcceptable(available_renderers=renderers)