From cc0070f6496e501d77352bad475fb02d6a86846a Mon Sep 17 00:00:00 2001 From: bashonly Date: Sun, 14 Jul 2024 14:58:07 -0500 Subject: [PATCH] [utils] `parse_codecs`: Fix parsing of mixed case codec strings Authored by: bashonly --- test/test_utils.py | 5 +++++ yt_dlp/utils/_utils.py | 1 + 2 files changed, 6 insertions(+) diff --git a/test/test_utils.py b/test/test_utils.py index 3ff1f8b55..e82f551bc 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -929,6 +929,11 @@ def test_parse_codecs(self): 'acodec': 'none', 'dynamic_range': 'DV', }) + self.assertEqual(parse_codecs('fLaC'), { + 'vcodec': 'none', + 'acodec': 'flac', + 'dynamic_range': None, + }) self.assertEqual(parse_codecs('theora, vorbis'), { 'vcodec': 'theora', 'acodec': 'vorbis', diff --git a/yt_dlp/utils/_utils.py b/yt_dlp/utils/_utils.py index b582b7d4e..2c23b3ed5 100644 --- a/yt_dlp/utils/_utils.py +++ b/yt_dlp/utils/_utils.py @@ -2984,6 +2984,7 @@ def parse_codecs(codecs_str): str.strip, codecs_str.strip().strip(',').split(',')))) vcodec, acodec, scodec, hdr = None, None, None, None for full_codec in split_codecs: + full_codec = re.sub(r'^([^.]+)', lambda m: m.group(1).lower(), full_codec) parts = re.sub(r'0+(?=\d)', '', full_codec).split('.') if parts[0] in ('avc1', 'avc2', 'avc3', 'avc4', 'vp9', 'vp8', 'hev1', 'hev2', 'h263', 'h264', 'mp4v', 'hvc1', 'av1', 'theora', 'dvh1', 'dvhe'):