Commit 2fe17f51 authored by Konrad Mohrfeldt's avatar Konrad Mohrfeldt

add missing data fields to Audiofile serializer per frontend REST API spec. see #64

parent 08e9f0b5
......@@ -7,10 +7,22 @@ from program.models import Broadcast, RadioProgram
class AudiofileSourceSerializer(serializers.ModelSerializer):
src = serializers.FileField(source='audiofile', use_url=True)
container = serializers.SerializerMethodField()
codec = serializers.SerializerMethodField()
def get_container(self, obj):
# TODO: return proper container data for non-mp3 files
return None
def get_codec(self, obj: Audiofile):
# TODO: return proper codec data for non-mp3 files
if obj.audiofile.name.endswith('.mp3'):
return 'audio/mpeg'
return None
class Meta:
model = Audiofile
fields = ('bitrate', 'src')
fields = ('bitrate', 'codec', 'container', 'src')
class AudiofileSerializer(serializers.ModelSerializer):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment