From 14571689510f5e4f0950f56189001fd8cddf8e3a Mon Sep 17 00:00:00 2001 From: xenofem Date: Sat, 17 Feb 2024 02:54:04 -0500 Subject: [PATCH] prefer versions without moire-inducing tone effects --- dlibrary/dlibrary.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/dlibrary/dlibrary.py b/dlibrary/dlibrary.py index b651134..de0279e 100755 --- a/dlibrary/dlibrary.py +++ b/dlibrary/dlibrary.py @@ -28,6 +28,7 @@ FANZA_ID_REGEX = re.compile('^d_[0-9]+$') FAKKU_ID_REGEX = re.compile('.*_FAKKU$') HI_RES_REGEX = re.compile('高解像度', re.IGNORECASE) +NO_TONE_REGEX = re.compile('トーン.*[な無]し|グレースケール') TEXTLESS_REGEX = re.compile('(台詞|セリフ|せりふ|テキスト|文字)((な|無)し|抜き)|notext|textless', re.IGNORECASE) FRONT_COVER_REGEX = re.compile('(^|[^裏])表紙|cover|hyoushi', re.IGNORECASE) @@ -555,12 +556,12 @@ def collate_from_paths(srcs, dest, start_index, exclude): return 0 if len(srcs) == 2 and all(src.is_dir() for src in srcs): - hi_res_dirs = [src for src in srcs if HI_RES_REGEX.search(nname(src))] - if len(hi_res_dirs) == 1: - hi_res_dir = hi_res_dirs[0] - lo_res_dir = next(src for src in srcs if src != hi_res_dir) - if len(descendant_files_ignore(lo_res_dir, exclude)) == len(descendant_files_ignore(hi_res_dir, exclude)): - return collate_from_paths([hi_res_dir], dest, start_index, exclude) + better_version_dirs = [src for src in srcs if HI_RES_REGEX.search(nname(src)) or NO_TONE_REGEX.search(nname(src))] + if len(better_version_dirs) == 1: + better_version_dir = better_version_dirs[0] + worse_version_dir = next(src for src in srcs if src != better_version_dir) + if len(descendant_files_ignore(worse_version_dir, exclude)) == len(descendant_files_ignore(better_version_dir, exclude)): + return collate_from_paths([better_version_dir], dest, start_index, exclude) images_vs_pdf = try_collate_images_vs_pdf(srcs, dest, start_index, exclude) if images_vs_pdf != False: