小清理,优化代码排版
This commit is contained in:
@@ -129,7 +129,6 @@ def close_logfile(logdir: str):
|
|||||||
# 重写视频文件扫描,消除递归,取消全局变量,新增失败文件列表跳过处理
|
# 重写视频文件扫描,消除递归,取消全局变量,新增失败文件列表跳过处理
|
||||||
def movie_lists(root, conf):
|
def movie_lists(root, conf):
|
||||||
escape_folder = re.split("[,,]", conf.escape_folder())
|
escape_folder = re.split("[,,]", conf.escape_folder())
|
||||||
failed_folder = conf.failed_folder()
|
|
||||||
main_mode = conf.main_mode()
|
main_mode = conf.main_mode()
|
||||||
debug = conf.debug()
|
debug = conf.debug()
|
||||||
nfo_skip_days = conf.nfo_skip_days()
|
nfo_skip_days = conf.nfo_skip_days()
|
||||||
@@ -137,48 +136,46 @@ def movie_lists(root, conf):
|
|||||||
file_type = conf.media_type().upper().split(",")
|
file_type = conf.media_type().upper().split(",")
|
||||||
trailerRE = re.compile(r'-trailer\.', re.IGNORECASE)
|
trailerRE = re.compile(r'-trailer\.', re.IGNORECASE)
|
||||||
try:
|
try:
|
||||||
failed_list = open(os.path.join(failed_folder, 'failed_list.txt'), 'r', encoding='utf-8').read().splitlines()
|
failed_list = open(os.path.join(conf.failed_folder(), 'failed_list.txt'),
|
||||||
|
'r', encoding='utf-8').read().splitlines()
|
||||||
except:
|
except:
|
||||||
failed_list = []
|
failed_list = []
|
||||||
pass
|
pass
|
||||||
for current_dir, subdirs, files in os.walk(root, topdown=False):
|
for current_dir, subdirs, files in os.walk(root, topdown=False):
|
||||||
try:
|
if current_dir in escape_folder:
|
||||||
if current_dir in escape_folder:
|
continue
|
||||||
|
for f in files:
|
||||||
|
full_name = os.path.join(current_dir, f)
|
||||||
|
if not os.path.splitext(full_name)[1].upper() in file_type:
|
||||||
continue
|
continue
|
||||||
for f in files:
|
absf = os.path.abspath(full_name)
|
||||||
full_name = os.path.join(current_dir, f)
|
if absf in failed_list:
|
||||||
if not os.path.splitext(full_name)[1].upper() in file_type:
|
if debug:
|
||||||
|
print('[!]Skip failed file:', absf)
|
||||||
|
continue
|
||||||
|
if main_mode == 3 and nfo_skip_days > 0:
|
||||||
|
nfo = Path(absf).with_suffix('.nfo')
|
||||||
|
if file_modification_days(nfo) <= nfo_skip_days:
|
||||||
continue
|
continue
|
||||||
absf = os.path.abspath(full_name)
|
if (main_mode == 3 or not is_link(absf)) and not trailerRE.search(f):
|
||||||
if absf in failed_list:
|
total.append(absf)
|
||||||
if debug:
|
if nfo_skip_days <= 0 or not conf.soft_link() or main_mode == 3:
|
||||||
print('[!]Skip failed file:', absf)
|
|
||||||
continue
|
|
||||||
if main_mode == 3 and nfo_skip_days > 0:
|
|
||||||
nfo = Path(absf).with_suffix('.nfo')
|
|
||||||
if file_modification_days(nfo) <= nfo_skip_days:
|
|
||||||
continue
|
|
||||||
if (main_mode == 3 or not is_link(absf)) and not trailerRE.search(f):
|
|
||||||
total.append(absf)
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
if nfo_skip_days <= 0 or not conf.soft_link():
|
|
||||||
return total
|
return total
|
||||||
# 软连接方式,已经成功削刮的也需要从成功目录中检查.nfo更新天数,跳过N天内更新过的
|
# 软连接方式,已经成功削刮的也需要从成功目录中检查.nfo更新天数,跳过N天内更新过的
|
||||||
skip_numbers = set()
|
skip_numbers = set()
|
||||||
success_folder = conf.success_folder()
|
success_folder = conf.success_folder()
|
||||||
for current_dir, subdirs, files in os.walk(success_folder, topdown=False):
|
for current_dir, subdirs, files in os.walk(success_folder, topdown=False):
|
||||||
for f in files:
|
for f in files:
|
||||||
if os.path.splitext(f)[1].upper() in file_type:
|
if not os.path.splitext(f)[1].upper() in file_type:
|
||||||
nfo_file = os.path.join(current_dir, str(Path(f).with_suffix('.nfo')))
|
continue
|
||||||
if file_modification_days(nfo_file) <= nfo_skip_days:
|
nfo_file = os.path.join(current_dir, str(Path(f).with_suffix('.nfo')))
|
||||||
file_name = os.path.basename(f)
|
if file_modification_days(nfo_file) > nfo_skip_days:
|
||||||
number = get_number(False, file_name)
|
continue
|
||||||
if number:
|
number = get_number(False, os.path.basename(f))
|
||||||
skip_numbers.add(number.upper())
|
if number:
|
||||||
|
skip_numbers.add(number.upper())
|
||||||
for f in total:
|
for f in total:
|
||||||
file_name = os.path.basename(f)
|
n_number = get_number(False, os.path.basename(f))
|
||||||
n_number = get_number(False, file_name)
|
|
||||||
if n_number and n_number.upper() in skip_numbers:
|
if n_number and n_number.upper() in skip_numbers:
|
||||||
total.pop(total.index(f))
|
total.pop(total.index(f))
|
||||||
return total
|
return total
|
||||||
|
|||||||
Reference in New Issue
Block a user