From 3b99757645f5281bfdbda3598fc204cb33d083ae Mon Sep 17 00:00:00 2001 From: abhiTronix Date: Mon, 24 Jun 2024 00:04:44 +0530 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20FFhelper:=20Fixed=20regex=20expr?= =?UTF-8?q?ession=20bugs=20in=20`get=5Fsupported=5Fdemuxers`=20method.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - ⚡️ Simplified regex search for demuxers and handled multi-line output correctly. - 🎨 Improved output extraction and stripping logic to handle commas within demuxer names. --- deffcode/ffhelper.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/deffcode/ffhelper.py b/deffcode/ffhelper.py index e09c904..c483345 100644 --- a/deffcode/ffhelper.py +++ b/deffcode/ffhelper.py @@ -342,16 +342,16 @@ def get_supported_demuxers(path): **Returns:** List of supported demuxers. """ + # extract and clean FFmpeg output demuxers = check_sp_output([path, "-hide_banner", "-demuxers"]) splitted = [x.decode("utf-8").strip() for x in demuxers.split(b"\n")] split_index = [idx for idx, s in enumerate(splitted) if "--" in s][0] supported_demuxers = splitted[split_index + 1 : len(splitted) - 1] - # compile regex - finder = re.compile(r"[a-z0-9_,-]{2,}\s\s") - # find all outputs - outputs = finder.findall("\n".join(supported_demuxers)) - # return output findings - return [o.strip() for o in outputs] + # search all demuxers + outputs = [re.search("\s[a-z0-9_,-]{2,}\s", d) for d in supported_demuxers] + outputs = [o.group(0) for o in outputs if o] + # return demuxers output + return [o.strip() if not ("," in o) else o.split(",")[-1].strip() for o in outputs] def extract_device_n_demuxer(path, machine_OS=None, verbose=False):