From fdc591cc7c77bdd042a0a75d9595801a9024af03 Mon Sep 17 00:00:00 2001 From: meeb Date: Thu, 19 Jan 2023 13:29:37 +1100 Subject: [PATCH] fix in-client video player with correct content type headers --- tubesync/sync/models.py | 10 ++++++++++ tubesync/sync/templates/sync/media-item.html | 2 +- tubesync/sync/views.py | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/tubesync/sync/models.py b/tubesync/sync/models.py index 71dbed6..338f731 100644 --- a/tubesync/sync/models.py +++ b/tubesync/sync/models.py @@ -1136,6 +1136,16 @@ class Media(models.Model): return False return os.path.exists(self.media_file.path) + @property + def content_type(self): + if not self.downloaded: + return 'video/mp4' + vcodec = self.downloaded_video_codec.lower() + if vcodec == 'vp9': + return 'video/webm' + else: + return 'video/mp4' + @property def nfoxml(self): ''' diff --git a/tubesync/sync/templates/sync/media-item.html b/tubesync/sync/templates/sync/media-item.html index 868b1c1..1ce3a2a 100644 --- a/tubesync/sync/templates/sync/media-item.html +++ b/tubesync/sync/templates/sync/media-item.html @@ -13,7 +13,7 @@ -

Download

+

Download

{% endif %} diff --git a/tubesync/sync/views.py b/tubesync/sync/views.py index b6bf35a..ad6aa8b 100644 --- a/tubesync/sync/views.py +++ b/tubesync/sync/views.py @@ -677,8 +677,8 @@ class MediaContent(DetailView): def dispatch(self, request, *args, **kwargs): self.object = self.get_object() - headers = { + 'Content-Type': self.object.content_type, 'X-Accel-Redirect': self.object.media_file.url, } return HttpResponse(headers=headers)