prefer versions without moire-inducing tone effects

This commit is contained in:
xenofem 2024-02-17 02:54:04 -05:00
parent fd6e1f0eb4
commit 1457168951

View file

@ -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: