From 09044aa95d4e8cf5c5c4926eb08da3de2e7fe8a4 Mon Sep 17 00:00:00 2001 From: tcely Date: Wed, 4 Dec 2024 17:03:18 -0500 Subject: [PATCH] Return for empty format lists first --- tubesync/sync/matching.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tubesync/sync/matching.py b/tubesync/sync/matching.py index 6a72972d..982af040 100644 --- a/tubesync/sync/matching.py +++ b/tubesync/sync/matching.py @@ -57,10 +57,10 @@ def get_best_audio_format(media): if not fmt['acodec']: continue audio_formats.append(fmt) - audio_formats = list(reversed(audio_formats)) if not audio_formats: # Media has no audio formats at all return False, False + audio_formats = list(reversed(audio_formats)) # Find the first audio format with a matching codec for fmt in audio_formats: if media.source.source_acodec == fmt['acodec']: @@ -113,12 +113,12 @@ def get_best_video_format(media): else: # Can't fallback return False, False - video_formats = multi_key_sort(video_formats, sort_keys, True) - source_resolution = media.source.source_resolution.strip().upper() - source_vcodec = media.source.source_vcodec if not video_formats: # Still no matches return False, False + video_formats = multi_key_sort(video_formats, sort_keys, True) + source_resolution = media.source.source_resolution.strip().upper() + source_vcodec = media.source.source_vcodec exact_match, best_match = None, None # Of our filtered video formats, check for resolution + codec + hdr + fps match if media.source.prefer_60fps and media.source.prefer_hdr: