From f83f6a74490bf714a53119dc3e8a1ea3bbadc918 Mon Sep 17 00:00:00 2001 From: xenofem Date: Mon, 1 Apr 2024 22:07:21 -0400 Subject: [PATCH] do hi-res/lo-res detection even when there's other files lying around --- dlibrary/dlibrary.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/dlibrary/dlibrary.py b/dlibrary/dlibrary.py index dca0fbc..e6dd1f5 100755 --- a/dlibrary/dlibrary.py +++ b/dlibrary/dlibrary.py @@ -32,7 +32,7 @@ DLSITE_ID_REGEX = re.compile('^[BR]J[0-9]+$') FANZA_ID_REGEX = re.compile('^d_[0-9]+$') FAKKU_ID_REGEX = re.compile('.*_FAKKU$') -HI_RES_REGEX = re.compile('高解像度|原寸', re.I) +HI_RES_REGEX = re.compile('高解像度|原寸|大サイズ', re.I) NO_TONE_REGEX = re.compile('トーン(効果)?[な無]し|グレースケール', re.I) TONE_REGEX = re.compile('トーン(版|(効果)?[有あ]り)', re.I) COLOR_REGEX = re.compile('カラー', re.I) @@ -441,20 +441,22 @@ class Collator: if select_language is not False: return select_language - if len(srcs) == 2 and all(src.is_dir() for src in srcs): + dirs = [src for src in srcs if src.is_dir()] + if len(dirs) == 2: for quality in IMAGE_QUALITY_REGEXES: def a_not_b(a, b, src): if a in quality: return quality[a].search(nname(src)) else: return not quality[b].search(nname(src)) - better_srcs = [src for src in srcs if a_not_b('better', 'worse', src)] - worse_srcs = [src for src in srcs if a_not_b('worse', 'better', src)] + better_srcs = [src for src in dirs if a_not_b('better', 'worse', src)] + worse_srcs = [src for src in dirs if a_not_b('worse', 'better', src)] if len(better_srcs) == 1 and len(worse_srcs) == 1 and better_srcs[0] != worse_srcs[0]: better = better_srcs[0] worse = worse_srcs[0] if len(descendant_files_ignore(better, self.exclude)) == len(descendant_files_ignore(worse, self.exclude)): - return self.collate_from_paths([better]) + non_dirs = [src for src in srcs if not src.is_dir()] + return self.collate_from_paths([better] + non_dirs) images_vs_pdf = self.try_collate_images_vs_pdf(srcs) if images_vs_pdf is not False: