From 7d333487fe983b11d923ac3c65e65145a428d25d Mon Sep 17 00:00:00 2001 From: KuhnChris Date: Sat, 11 Feb 2023 22:01:01 +0100 Subject: [PATCH 1/2] Fix bug getting content_type for "audio only" --- tubesync/sync/models.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tubesync/sync/models.py b/tubesync/sync/models.py index 338f731..24f2fbe 100644 --- a/tubesync/sync/models.py +++ b/tubesync/sync/models.py @@ -1140,7 +1140,11 @@ class Media(models.Model): def content_type(self): if not self.downloaded: return 'video/mp4' - vcodec = self.downloaded_video_codec.lower() + vcodec = self.downloaded_video_codec + if vcodec is None: + return 'audio/ogg' + + vcodec = vcodec.lower() if vcodec == 'vp9': return 'video/webm' else: From bf7a0fcec050bf59327d576a068a51a59b8b49cd Mon Sep 17 00:00:00 2001 From: KuhnChris Date: Sun, 12 Feb 2023 13:22:57 +0100 Subject: [PATCH 2/2] content_type based on vcodec/acodec --- tubesync/sync/models.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tubesync/sync/models.py b/tubesync/sync/models.py index 24f2fbe..16415c7 100644 --- a/tubesync/sync/models.py +++ b/tubesync/sync/models.py @@ -1142,7 +1142,18 @@ class Media(models.Model): return 'video/mp4' vcodec = self.downloaded_video_codec if vcodec is None: - return 'audio/ogg' + 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':