From be122d77fe3502009a4a8ecb4c857e953a9f0101 Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 2 Oct 2025 21:22:08 +0300 Subject: [PATCH] Fix resolution parsing in format quality sorting Improves robustness of the get_quality function by handling None and non-string resolution values, and catching IndexError in addition to ValueError when parsing resolution. --- src/gui/ytsage_gui_format_table.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/gui/ytsage_gui_format_table.py b/src/gui/ytsage_gui_format_table.py index ecfc410..0130261 100644 --- a/src/gui/ytsage_gui_format_table.py +++ b/src/gui/ytsage_gui_format_table.py @@ -162,10 +162,13 @@ class FormatTableMixin: # Sort formats by quality def get_quality(f): if f.get("vcodec") != "none": - res = f.get("resolution", "0x0").split("x")[-1] + resolution = f.get("resolution", "0x0") + if resolution is None or not isinstance(resolution, str): + return 0 try: + res = resolution.split("x")[-1] return int(res) - except ValueError: + except (ValueError, IndexError): return 0 else: return f.get("abr", 0)