diff --git a/tubesync/sync/matching.py b/tubesync/sync/matching.py index 0b1f8d34..5993a4d1 100644 --- a/tubesync/sync/matching.py +++ b/tubesync/sync/matching.py @@ -339,7 +339,7 @@ def get_best_video_format(media): for fmt in video_formats: # Check for a codec, hdr and fps match but drop the resolution if (source_vcodec == fmt['vcodec'] and - not fmt['is_hdr'] and fmt['is_60fps']): + not fmt['is_hdr'] and not fmt['is_60fps']): # Close match exact_match, best_match = False, fmt break diff --git a/tubesync/sync/models.py b/tubesync/sync/models.py index 2f116356..4f9de7f7 100644 --- a/tubesync/sync/models.py +++ b/tubesync/sync/models.py @@ -422,7 +422,7 @@ class Source(models.Model): help_text=_('List of subtitles langs to download, comma-separated. Example: en,fr or all,-fr,-live_chat'), validators=[ RegexValidator( - regex=r"^(\-?[\_\.a-zA-Z]+,)*(\-?[\_\.a-zA-Z]+){1}$", + regex=r"^(\-?[\_\.a-zA-Z-]+(,|$))+", message=_('Subtitle langs must be a comma-separated list of langs. example: en,fr or all,-fr,-live_chat') ) ] diff --git a/tubesync/sync/utils.py b/tubesync/sync/utils.py index 3dfcba2d..1c00b4a2 100644 --- a/tubesync/sync/utils.py +++ b/tubesync/sync/utils.py @@ -144,6 +144,21 @@ def multi_key_sort(sort_dict, specs, use_reversed=False): return result +def normalize_codec(codec_str): + result = str(codec_str).upper() + parts = result.split('.') + if len(parts) > 0: + result = parts[0].strip() + else: + return None + if 'NONE' == result: + return None + if str(0) in result: + prefix = result.rstrip('0123456789') + result = prefix + str(int(result[len(prefix):])) + return result + + def parse_media_format(format_dict): ''' This parser primarily adapts the format dict returned by youtube-dl into a @@ -151,23 +166,9 @@ def parse_media_format(format_dict): any internals, update it here. ''' vcodec_full = format_dict.get('vcodec', '') - vcodec_parts = vcodec_full.split('.') - if len(vcodec_parts) > 0: - vcodec = vcodec_parts[0].strip().upper() - else: - vcodec = None - if vcodec == 'NONE': - vcodec = None - if vcodec == 'VP09': - vcodec = 'VP9' + vcodec = normalize_codec(vcodec_full) acodec_full = format_dict.get('acodec', '') - acodec_parts = acodec_full.split('.') - if len(acodec_parts) > 0: - acodec = acodec_parts[0].strip().upper() - else: - acodec = None - if acodec == 'NONE': - acodec = None + acodec = normalize_codec(acodec_full) try: fps = int(format_dict.get('fps', 0)) except (ValueError, TypeError):