|
99 | 99 | use_folder_as_season = 0 |
100 | 100 | del_empty_folder = 0 |
101 | 101 | priority_match = 0 |
| 102 | + ignore_file_count_check = 0 |
102 | 103 | else: |
103 | 104 | # 新的argparse解析 |
104 | 105 | # python EpisodeReName.py --path E:\test\极端试验样本\S1 --delay 1 --overwrite 1 |
|
177 | 178 | type=int, |
178 | 179 | default=0, |
179 | 180 | ) |
| 181 | + ap.add_argument( |
| 182 | + '--ignore_file_count_check', |
| 183 | + required=False, |
| 184 | + help='忽略旧文件数量和新文件数量不一致的检查,即使可能会覆盖文件也继续执行。默认为0不开启, 1是开启', |
| 185 | + type=int, |
| 186 | + default=0, |
| 187 | + ) |
180 | 188 |
|
181 | 189 | args = vars(ap.parse_args()) |
182 | 190 | target_path = args['path'] |
|
190 | 198 | use_folder_as_season = args['use_folder_as_season'] |
191 | 199 | del_empty_folder = args['del_empty_folder'] |
192 | 200 | priority_match = args['priority_match'] |
| 201 | + ignore_file_count_check = args['ignore_file_count_check'] |
193 | 202 |
|
194 | 203 | if parse_resolution: |
195 | 204 | name_format = 'S{season}E{ep} - {resolution}' |
|
349 | 358 |
|
350 | 359 | # 检查旧的文件数量和新的文件数量是否一致,防止文件被覆盖 |
351 | 360 | new_set = set([x[1] for x in file_lists]) |
352 | | -if len(new_set) != len(file_lists): |
| 361 | +if len(new_set) != len(file_lists) and not ignore_file_count_check: |
353 | 362 | logger.warning(f"{'旧文件数量和新文件数量不一致,可能会被覆盖。请检查文件命名'}") |
354 | 363 | new_list = [x[1] for x in file_lists] |
355 | 364 | for file in new_set: |
356 | 365 | if new_list.count(file) > 1: |
357 | 366 | logger.warning(f"{'重复文件', file}") |
| 367 | + logger.info(f"{'如需忽略此检查,请使用 --ignore_file_count_check 1 参数'}") |
358 | 368 | sys.exit() |
| 369 | +elif len(new_set) != len(file_lists) and ignore_file_count_check: |
| 370 | + logger.warning(f"{'旧文件数量和新文件数量不一致,可能会被覆盖。已启用忽略检查,继续执行'}") |
| 371 | + new_list = [x[1] for x in file_lists] |
| 372 | + for file in new_set: |
| 373 | + if new_list.count(file) > 1: |
| 374 | + logger.warning(f"{'重复文件', file}") |
359 | 375 |
|
360 | 376 | # 错误记录 |
361 | 377 | error_logs = [] |
|
0 commit comments