Merge pull request #325 from kuhnchris/allow-audio-play

Fix bug getting content_type for "audio only"
This commit is contained in:
meeb 2023-02-12 23:51:37 +11:00 committed by GitHub
commit e871983707
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 1 deletions

View File

@ -1140,7 +1140,22 @@ class Media(models.Model):
def content_type(self): def content_type(self):
if not self.downloaded: if not self.downloaded:
return 'video/mp4' return 'video/mp4'
vcodec = self.downloaded_video_codec.lower() vcodec = self.downloaded_video_codec
if vcodec is None:
acodec = self.downloaded_audio_codec
if acodec is None:
raise TypeError() # nothing here.
acodec = acodec.lower()
if acodec == "mp4a":
return "audio/mp4"
elif acodec == "opus":
return "audio/opus"
else:
# fall-fall-back.
return 'audio/ogg'
vcodec = vcodec.lower()
if vcodec == 'vp9': if vcodec == 'vp9':
return 'video/webm' return 'video/webm'
else: else: