From 4685bf67db0ec7ac64a532d03007aa656bf4e387 Mon Sep 17 00:00:00 2001 From: Max Mauermann Date: Mon, 2 Sep 2024 16:55:00 +0200 Subject: [PATCH 1/2] segments work again when result files are in different folders. --- segments.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/segments.py b/segments.py index 068d4135..855bc485 100644 --- a/segments.py +++ b/segments.py @@ -89,13 +89,14 @@ def parseFolders(apath: str, rpath: str, allowed_result_filetypes: list[str] = [ for root, _, files in os.walk(apath): for f in files: if f.rsplit(".", 1)[-1].lower() in cfg.ALLOWED_FILETYPES: - data[os.path.join(root, f.rsplit(".", 1)[0])] = {"audio": os.path.join(root, f), "result": ""} + table_key = os.path.join(root.strip(apath), f.split(".", 1)[0]) + data[table_key] = {"audio": os.path.join(root, f), "result": ""} # Get all result files for root, _, files in os.walk(rpath): for f in files: if f.rsplit(".", 1)[-1] in allowed_result_filetypes and ".BirdNET." in f: - table_key = os.path.join(root, f.split(".BirdNET.", 1)[0]) + table_key = os.path.join(root.strip(rpath), f.split(".BirdNET.", 1)[0]) if table_key in data: data[table_key]["result"] = os.path.join(root, f) From be11b81191551c82f07495eebabab80e02964815 Mon Sep 17 00:00:00 2001 From: Max Mauermann Date: Tue, 3 Sep 2024 13:18:12 +0200 Subject: [PATCH 2/2] changed to rsplit for audiofiles to be robust against . in filenames --- segments.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/segments.py b/segments.py index 855bc485..53c1e51c 100644 --- a/segments.py +++ b/segments.py @@ -89,7 +89,7 @@ def parseFolders(apath: str, rpath: str, allowed_result_filetypes: list[str] = [ for root, _, files in os.walk(apath): for f in files: if f.rsplit(".", 1)[-1].lower() in cfg.ALLOWED_FILETYPES: - table_key = os.path.join(root.strip(apath), f.split(".", 1)[0]) + table_key = os.path.join(root.strip(apath), f.rsplit(".", 1)[0]) data[table_key] = {"audio": os.path.join(root, f), "result": ""} # Get all result files