fix: revert the api of moveFailedFolder
This commit is contained in:
44
core.py
44
core.py
@@ -29,11 +29,11 @@ def escape_path(path, escape_literals: str): # Remove escape literals
|
|||||||
return path
|
return path
|
||||||
|
|
||||||
|
|
||||||
def moveFailedFolder(filepath, failed_folder, symlink: bool = False):
|
def moveFailedFolder(filepath, failed_folder):
|
||||||
root_path = str(pathlib.Path(filepath).parent)
|
root_path = str(pathlib.Path(filepath).parent)
|
||||||
file_name = pathlib.Path(filepath).name
|
file_name = pathlib.Path(filepath).name
|
||||||
destination_path = root_path + '/' + failed_folder + '/'
|
destination_path = root_path + '/' + failed_folder + '/'
|
||||||
if symlink:
|
if config.Config.soft_link():
|
||||||
print('[-]Create symlink to Failed output folder')
|
print('[-]Create symlink to Failed output folder')
|
||||||
os.symlink(filepath, destination_path + '/' + file_name)
|
os.symlink(filepath, destination_path + '/' + file_name)
|
||||||
else:
|
else:
|
||||||
@@ -105,7 +105,7 @@ def get_data_from_json(file_number, filepath, conf: config.Config): # 从JSON
|
|||||||
# Return if data not found in all sources
|
# Return if data not found in all sources
|
||||||
if not json_data:
|
if not json_data:
|
||||||
print('[-]Movie Data not found!')
|
print('[-]Movie Data not found!')
|
||||||
moveFailedFolder(filepath, conf.failed_folder(), conf.soft_link())
|
moveFailedFolder(filepath, conf.failed_folder())
|
||||||
return
|
return
|
||||||
|
|
||||||
# ================================================网站规则添加结束================================================
|
# ================================================网站规则添加结束================================================
|
||||||
@@ -133,7 +133,7 @@ def get_data_from_json(file_number, filepath, conf: config.Config): # 从JSON
|
|||||||
|
|
||||||
if title == '' or number == '':
|
if title == '' or number == '':
|
||||||
print('[-]Movie Data not found!')
|
print('[-]Movie Data not found!')
|
||||||
moveFailedFolder(filepath, conf.failed_folder(), conf.soft_link())
|
moveFailedFolder(filepath, conf.failed_folder())
|
||||||
return
|
return
|
||||||
|
|
||||||
# if imagecut == '3':
|
# if imagecut == '3':
|
||||||
@@ -322,14 +322,14 @@ def download_file_with_filename(url, filename, path, conf: config.Config, filepa
|
|||||||
i += 1
|
i += 1
|
||||||
print('[-]Image Download : Connect retry ' + str(i) + '/' + str(retry_count))
|
print('[-]Image Download : Connect retry ' + str(i) + '/' + str(retry_count))
|
||||||
print('[-]Connect Failed! Please check your Proxy or Network!')
|
print('[-]Connect Failed! Please check your Proxy or Network!')
|
||||||
moveFailedFolder(filepath, failed_folder, conf.soft_link())
|
moveFailedFolder(filepath, failed_folder)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
# 封面是否下载成功,否则移动到failed
|
# 封面是否下载成功,否则移动到failed
|
||||||
def image_download(cover, number, c_word, path, conf: config.Config, filepath, failed_folder):
|
def image_download(cover, number, c_word, path, conf: config.Config, filepath, failed_folder):
|
||||||
if download_file_with_filename(cover, number + c_word + '-fanart.jpg', path, conf, filepath, failed_folder) == 'failed':
|
if download_file_with_filename(cover, number + c_word + '-fanart.jpg', path, conf, filepath, failed_folder) == 'failed':
|
||||||
moveFailedFolder(filepath, failed_folder, conf.soft_link())
|
moveFailedFolder(filepath, failed_folder)
|
||||||
return
|
return
|
||||||
|
|
||||||
switch, _proxy, _timeout, retry, _proxytype = conf.proxy()
|
switch, _proxy, _timeout, retry, _proxytype = conf.proxy()
|
||||||
@@ -402,11 +402,13 @@ def print_files(path, c_word, naming_rule, part, cn_sub, json_data, filepath, fa
|
|||||||
except IOError as e:
|
except IOError as e:
|
||||||
print("[-]Write Failed!")
|
print("[-]Write Failed!")
|
||||||
print(e)
|
print(e)
|
||||||
raise e
|
moveFailedFolder(filepath, failed_folder)
|
||||||
|
return
|
||||||
except Exception as e1:
|
except Exception as e1:
|
||||||
print(e1)
|
print(e1)
|
||||||
print("[-]Write Failed!")
|
print("[-]Write Failed!")
|
||||||
raise e1
|
moveFailedFolder(filepath, failed_folder)
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
def cutImage(imagecut, path, number, c_word):
|
def cutImage(imagecut, path, number, c_word):
|
||||||
@@ -481,12 +483,16 @@ def paste_file_to_folder_mode2(filepath, path, multi_part, number, part, c_word,
|
|||||||
print('[-]Error! Please run as administrator!')
|
print('[-]Error! Please run as administrator!')
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
def get_part(filepath, failed_folder):
|
def get_part(filepath, failed_folder):
|
||||||
if re.search('-CD\d+', filepath):
|
try:
|
||||||
return re.findall('-CD\d+', filepath)[0]
|
if re.search('-CD\d+', filepath):
|
||||||
if re.search('-cd\d+', filepath):
|
return re.findall('-CD\d+', filepath)[0]
|
||||||
return re.findall('-cd\d+', filepath)[0]
|
if re.search('-cd\d+', filepath):
|
||||||
|
return re.findall('-cd\d+', filepath)[0]
|
||||||
|
except:
|
||||||
|
print("[-]failed!Please rename the filename again!")
|
||||||
|
moveFailedFolder(filepath, failed_folder)
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
def debug_print(data: json):
|
def debug_print(data: json):
|
||||||
@@ -535,11 +541,7 @@ def core_main(file_path, number_th, conf: config.Config):
|
|||||||
# =======================================================================判断-C,-CD后缀
|
# =======================================================================判断-C,-CD后缀
|
||||||
if '-CD' in filepath or '-cd' in filepath:
|
if '-CD' in filepath or '-cd' in filepath:
|
||||||
multi_part = 1
|
multi_part = 1
|
||||||
try:
|
part = get_part(filepath, conf.failed_folder())
|
||||||
part = get_part(filepath, conf.failed_folder())
|
|
||||||
except:
|
|
||||||
print("[-]failed!Please rename the filename again!")
|
|
||||||
moveFailedFolder(filepath, conf.failed_folder(),conf.soft_link())
|
|
||||||
if '-c.' in filepath or '-C.' in filepath or '中文' in filepath or '字幕' in filepath:
|
if '-c.' in filepath or '-C.' in filepath or '中文' in filepath or '字幕' in filepath:
|
||||||
cn_sub = '1'
|
cn_sub = '1'
|
||||||
c_word = '-C' # 中文字幕影片后缀
|
c_word = '-C' # 中文字幕影片后缀
|
||||||
@@ -571,10 +573,8 @@ def core_main(file_path, number_th, conf: config.Config):
|
|||||||
cutImage(imagecut, path, number, c_word)
|
cutImage(imagecut, path, number, c_word)
|
||||||
|
|
||||||
# 打印文件
|
# 打印文件
|
||||||
try:
|
print_files(path, c_word, json_data.get('naming_rule'), part, cn_sub, json_data, filepath, conf.failed_folder(), tag, json_data.get('actor_list'), liuchu)
|
||||||
print_files(path, c_word, json_data.get('naming_rule'), part, cn_sub, json_data, filepath, conf.failed_folder(), tag, json_data.get('actor_list'), liuchu)
|
|
||||||
except:
|
|
||||||
moveFailedFolder(filepath, conf.failed_folder(), conf.soft_link())
|
|
||||||
# 移动文件
|
# 移动文件
|
||||||
paste_file_to_folder(filepath, path, number, c_word, conf)
|
paste_file_to_folder(filepath, path, number, c_word, conf)
|
||||||
elif conf.main_mode() == 2:
|
elif conf.main_mode() == 2:
|
||||||
|
|||||||
Reference in New Issue
Block a user