A feature-rich command-line audio/video downloader
[utils] `parse_resolution`: Support width-only pattern (#13802)
doe10804385480795ac
diff --git a/test/test_utils.py b/test/test_utils.pyindex aedb565ec1..44747efda6 100644--- a/test/test_utils.py+++ b/test/test_utils.py@@ -1373,6 +1373,7 @@ class TestUtil(unittest.TestCase):self.assertEqual(parse_resolution('pre_1920x1080_post'), {'width': 1920, 'height': 1080})self.assertEqual(parse_resolution('ep1x2'), {})self.assertEqual(parse_resolution('1920, 1080'), {'width': 1920, 'height': 1080})+ self.assertEqual(parse_resolution('1920w', lenient=True), {'width': 1920})def test_parse_bitrate(self):self.assertEqual(parse_bitrate(None), None)diff --git a/yt_dlp/utils/_utils.py b/yt_dlp/utils/_utils.pyindex 1cb62712ba..a5471da4df 100644--- a/yt_dlp/utils/_utils.py+++ b/yt_dlp/utils/_utils.py@@ -1875,6 +1875,11 @@ def parse_resolution(s, *, lenient=False):if mobj:return {'height': int(mobj.group(1)) * 540}+ if lenient:+ mobj = re.search(r'(?<!\d)(\d{2,5})w(?![a-zA-Z0-9])', s)+ if mobj:+ return {'width': int(mobj.group(1))}+return {}