detect epilogues in auto collation
This commit is contained in:
		
							parent
							
								
									ef0c115f0f
								
							
						
					
					
						commit
						61a7eb07f9
					
				
					 1 changed files with 28 additions and 15 deletions
				
			
		|  | @ -25,6 +25,7 @@ FANZA_ID_REGEX = re.compile('^d_[0-9]+$') | ||||||
| FAKKU_ID_REGEX = re.compile('.*_FAKKU$') | FAKKU_ID_REGEX = re.compile('.*_FAKKU$') | ||||||
| 
 | 
 | ||||||
| TEXTLESS_REGEX = re.compile('(台詞|セリフ)(な|無)し|notext|textless') | TEXTLESS_REGEX = re.compile('(台詞|セリフ)(な|無)し|notext|textless') | ||||||
|  | EPILOGUE_REGEX = re.compile('after|後日談') | ||||||
| ALT_VERSIONS = ['褐色', '日焼け', 'pink', '金髪', '白肌'] | ALT_VERSIONS = ['褐色', '日焼け', 'pink', '金髪', '白肌'] | ||||||
| 
 | 
 | ||||||
| IMAGE_FILE_EXTENSIONS = ['.png', '.jpg', '.jpeg', '.gif', '.tiff'] | IMAGE_FILE_EXTENSIONS = ['.png', '.jpg', '.jpeg', '.gif', '.tiff'] | ||||||
|  | @ -345,6 +346,26 @@ def collate(args): | ||||||
|     collation_staging_area.rmdir() |     collation_staging_area.rmdir() | ||||||
|     con.close() |     con.close() | ||||||
| 
 | 
 | ||||||
|  | def collate_regex_later(srcs, dest, regex, start_index): | ||||||
|  |     matching = [] | ||||||
|  |     nonmatching = [] | ||||||
|  |     for src in srcs: | ||||||
|  |         if regex.search(src.name): | ||||||
|  |             matching.append(src) | ||||||
|  |         else: | ||||||
|  |             nonmatching.append(src) | ||||||
|  | 
 | ||||||
|  |     if not (matching and nonmatching): | ||||||
|  |         return False | ||||||
|  | 
 | ||||||
|  |     nonmatching_pages = collate_from_paths(nonmatching, dest, start_index) | ||||||
|  |     if nonmatching_pages is None: | ||||||
|  |         return None | ||||||
|  |     matching_pages = collate_from_paths(matching, dest, start_index+nonmatching_pages) | ||||||
|  |     if matching_pages is None: | ||||||
|  |         return None | ||||||
|  |     return nonmatching_pages + matching_pages | ||||||
|  | 
 | ||||||
| def collate_from_paths(srcs, dest, start_index): | def collate_from_paths(srcs, dest, start_index): | ||||||
|     if len(srcs) == 1 and srcs[0].is_dir(): |     if len(srcs) == 1 and srcs[0].is_dir(): | ||||||
|         return collate_from_paths(ls_ignore(srcs[0]), dest, start_index) |         return collate_from_paths(ls_ignore(srcs[0]), dest, start_index) | ||||||
|  | @ -356,21 +377,13 @@ def collate_from_paths(srcs, dest, start_index): | ||||||
|     if len(srcs) == 0: |     if len(srcs) == 0: | ||||||
|         return 0 |         return 0 | ||||||
| 
 | 
 | ||||||
|     with_text = [] |     textless_split = collate_regex_later(srcs, dest, TEXTLESS_REGEX, start_index) | ||||||
|     textless = [] |     if textless_split != False: | ||||||
|     for src in srcs: |         return textless_split | ||||||
|         if TEXTLESS_REGEX.search(src.name): | 
 | ||||||
|             textless.append(src) |     epilogue_split = collate_regex_later(srcs, dest, EPILOGUE_REGEX, start_index) | ||||||
|         else: |     if epilogue_split != False: | ||||||
|             with_text.append(src) |         return epilogue_split | ||||||
|     if with_text and textless: |  | ||||||
|         text_pages = collate_from_paths(with_text, dest, start_index) |  | ||||||
|         if text_pages is None: |  | ||||||
|             return None |  | ||||||
|         textless_pages = collate_from_paths(textless, dest, start_index+text_pages) |  | ||||||
|         if textless_pages is None: |  | ||||||
|             return None |  | ||||||
|         return text_pages + textless_pages |  | ||||||
| 
 | 
 | ||||||
|     if all(src.is_file() and src.suffix.lower() in IMAGE_FILE_EXTENSIONS for src in srcs): |     if all(src.is_file() and src.suffix.lower() in IMAGE_FILE_EXTENSIONS for src in srcs): | ||||||
|         ordering = complete_prefix_number_ordering(srcs) |         ordering = complete_prefix_number_ordering(srcs) | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue