From a98ba439bc00894c6a121161a4e6770ba149ab74 Mon Sep 17 00:00:00 2001 From: lededev Date: Fri, 3 Sep 2021 18:49:52 +0800 Subject: [PATCH 1/4] ignore -trailer video files --- AV_Data_Capture.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AV_Data_Capture.py b/AV_Data_Capture.py index 9daa1a2..8ae7039 100755 --- a/AV_Data_Capture.py +++ b/AV_Data_Capture.py @@ -57,7 +57,7 @@ def movie_lists(root, escape_folder): total += movie_lists(f, escape_folder) elif os.path.splitext(f)[1].upper() in file_type: absf = os.path.abspath(f) - if conf.main_mode() == 3 or not is_link(absf): + if conf.main_mode() == 3 or (not is_link(absf) and not re.match(r'.*-trailer\..*', f, re.IGNORECASE)): total.append(absf) return total From f9433e589fed1747b563199f78b88e4f74f84cc9 Mon Sep 17 00:00:00 2001 From: lededev Date: Fri, 3 Sep 2021 19:10:49 +0800 Subject: [PATCH 2/4] mode 3 also need check this match pattern --- AV_Data_Capture.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AV_Data_Capture.py b/AV_Data_Capture.py index 8ae7039..eb65298 100755 --- a/AV_Data_Capture.py +++ b/AV_Data_Capture.py @@ -57,7 +57,7 @@ def movie_lists(root, escape_folder): total += movie_lists(f, escape_folder) elif os.path.splitext(f)[1].upper() in file_type: absf = os.path.abspath(f) - if conf.main_mode() == 3 or (not is_link(absf) and not re.match(r'.*-trailer\..*', f, re.IGNORECASE)): + if not re.match(r'.*-trailer\..*', f, re.IGNORECASE) and (conf.main_mode() == 3 or not is_link(absf)): total.append(absf) return total From 757e930a503fbf4441a17a22683ba6794b7423fd Mon Sep 17 00:00:00 2001 From: lededev Date: Fri, 3 Sep 2021 19:30:52 +0800 Subject: [PATCH 3/4] precompile and search --- AV_Data_Capture.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/AV_Data_Capture.py b/AV_Data_Capture.py index eb65298..64e604f 100755 --- a/AV_Data_Capture.py +++ b/AV_Data_Capture.py @@ -49,6 +49,7 @@ def movie_lists(root, escape_folder): if os.path.basename(root) in escape_folder: return [] total = [] + trailerRE = re.compile(r'-trailer\.', re.IGNORECASE) file_type = conf.media_type().upper().split(",") dirs = os.listdir(root) for entry in dirs: @@ -57,7 +58,7 @@ def movie_lists(root, escape_folder): total += movie_lists(f, escape_folder) elif os.path.splitext(f)[1].upper() in file_type: absf = os.path.abspath(f) - if not re.match(r'.*-trailer\..*', f, re.IGNORECASE) and (conf.main_mode() == 3 or not is_link(absf)): + if (conf.main_mode() == 3 or not is_link(absf)) and not trailerRE.search(f): total.append(absf) return total From 631dee6d9a49a28d58103f825abf33f7dd2b13c9 Mon Sep 17 00:00:00 2001 From: lededev Date: Fri, 3 Sep 2021 19:47:12 +0800 Subject: [PATCH 4/4] change to global variables to avoid repeated compilling in recursion --- AV_Data_Capture.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/AV_Data_Capture.py b/AV_Data_Capture.py index 64e604f..e582116 100755 --- a/AV_Data_Capture.py +++ b/AV_Data_Capture.py @@ -45,11 +45,13 @@ def argparse_function(ver: str) -> typing.Tuple[str, str, bool]: return args.file, args.path, args.number, args.autoexit + +G_trailerRE = re.compile(r'-trailer\.', re.IGNORECASE) + def movie_lists(root, escape_folder): if os.path.basename(root) in escape_folder: return [] total = [] - trailerRE = re.compile(r'-trailer\.', re.IGNORECASE) file_type = conf.media_type().upper().split(",") dirs = os.listdir(root) for entry in dirs: @@ -58,7 +60,7 @@ def movie_lists(root, escape_folder): total += movie_lists(f, escape_folder) elif os.path.splitext(f)[1].upper() in file_type: absf = os.path.abspath(f) - if (conf.main_mode() == 3 or not is_link(absf)) and not trailerRE.search(f): + if (conf.main_mode() == 3 or not is_link(absf)) and not G_trailerRE.search(f): total.append(absf) return total