From a8564c25541996050f8720570ef931d6aad2fe08 Mon Sep 17 00:00:00 2001 From: meeb Date: Sun, 13 Dec 2020 21:07:54 +1100 Subject: [PATCH] handle weird formats like dash with no preset height --- tubesync/sync/models.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tubesync/sync/models.py b/tubesync/sync/models.py index 729b86cc..158cdefe 100644 --- a/tubesync/sync/models.py +++ b/tubesync/sync/models.py @@ -637,7 +637,13 @@ class Media(models.Model): # If the download has completed use existing values if self.downloaded: if self.downloaded_format != 'audio': - fmt.append(self.downloaded_format.lower()) + video_format = self.downloaded_format.lower() + if ' ' in video_format or not video_format.lower().endswith('p'): + height = self.downloaded_height + if height > 0: + fmt.append(f'{height}p') + else: + fmt.append(video_format) fmt.append(self.downloaded_video_codec.lower()) fmt.append(self.downloaded_audio_codec.lower()) if self.downloaded_format != 'audio': @@ -661,6 +667,13 @@ class Media(models.Model): # Combined vformat = cformat if vformat: + video_format = vformat['format'].lower() + if ' ' in video_format or not video_format.lower().endswith('p'): + height = vformat.get('height', 0) + if height > 0: + fmt.append(f'{height}p') + else: + fmt.append(video_format) fmt.append(vformat['format'].lower()) fmt.append(vformat['vcodec'].lower()) fmt.append(aformat['acodec'].lower())