shorter str formatting

This commit is contained in:
lededev
2021-09-22 00:47:15 +08:00
parent 3bbcc52aee
commit efc94917a6

26
core.py
View File

@@ -374,7 +374,7 @@ def paste_file_to_folder(filepath, path, number, leak_word, c_word, conf: config
houzhui = os.path.splitext(filepath)[1].replace(",","") houzhui = os.path.splitext(filepath)[1].replace(",","")
file_parent_origin_path = str(pathlib.Path(filepath).parent) file_parent_origin_path = str(pathlib.Path(filepath).parent)
try: try:
targetpath = os.path.join(path, "{}{}{}{}".format(number, leak_word, c_word , houzhui)) targetpath = os.path.join(path, f"{number}{leak_word}{c_word}{houzhui}")
# 如果soft_link=1 使用软链接 # 如果soft_link=1 使用软链接
if conf.soft_link() == 0: if conf.soft_link() == 0:
shutil.move(filepath, targetpath) shutil.move(filepath, targetpath)
@@ -395,8 +395,7 @@ def paste_file_to_folder(filepath, path, number, leak_word, c_word, conf: config
for subname in sub_res: for subname in sub_res:
if os.path.exists(filepath.replace(houzhui, subname)): # 字幕移动 if os.path.exists(filepath.replace(houzhui, subname)): # 字幕移动
shutil.move(filepath.replace(houzhui, subname), shutil.move(filepath.replace(houzhui, subname), os.path.join(path, f"{number}{leak_word}{c_word}{subname}"))
os.path.join(path, "{}{}{}{}".format(number, leak_word, c_word, subname)))
print('[+]Sub moved!') print('[+]Sub moved!')
return True return True
@@ -419,17 +418,14 @@ def paste_file_to_folder_mode2(filepath, path, multi_part, number, part, leak_wo
file_parent_origin_path = str(pathlib.Path(filepath).parent) file_parent_origin_path = str(pathlib.Path(filepath).parent)
try: try:
if conf.soft_link(): if conf.soft_link():
os.symlink(filepath, os.symlink(filepath, os.path.join(path, f"{number}{part}{leak_word}{c_word}{houzhui}"))
os.path.join(path, "{}{}{}{}{}".format(number, part, leak_word, c_word, houzhui)))
else: else:
shutil.move(filepath, shutil.move(filepath, os.path.join(path, f"{number}{part}{leak_word}{c_word}{houzhui}"))
os.path.join(path, "{}{}{}{}{}".format(number, part, leak_word, c_word, houzhui)))
sub_res = conf.sub_rule() sub_res = conf.sub_rule()
for subname in sub_res: for subname in sub_res:
if os.path.exists(filepath.replace(houzhui, subname)): # 字幕移动 if os.path.exists(filepath.replace(houzhui, subname)): # 字幕移动
shutil.move(filepath.replace(houzhui, subname), shutil.move(filepath.replace(houzhui, subname), os.path.join(path, f"{number}{part}{leak_word}{c_word}{subname}"))
os.path.join(path, "{}{}{}{}{}".format(number, part, leak_word, c_word, subname)))
print('[+]Sub moved!') print('[+]Sub moved!')
print('[!]Success') print('[!]Success')
return True return True
@@ -571,8 +567,8 @@ def core_main(file_path, number_th, conf: config.Config):
# 移动文件 # 移动文件
paste_file_to_folder(filepath, path, number, leak_word, c_word, conf) paste_file_to_folder(filepath, path, number, leak_word, c_word, conf)
poster_path = os.path.join(path, "{}{}{}-poster.jpg".format(number, leak_word, c_word)) poster_path = os.path.join(path, f"{number}{leak_word}{c_word}-poster.jpg")
thumb_path = os.path.join(path, "{}{}{}-thumb.jpg".format(number, leak_word, c_word)) thumb_path = os.path.join(path, f"{number}{leak_word}{c_word}-thumb.jpg")
if conf.is_watermark(): if conf.is_watermark():
add_mark(poster_path, thumb_path, cn_sub, leak, uncensored, conf) add_mark(poster_path, thumb_path, cn_sub, leak, uncensored, conf)
@@ -581,8 +577,8 @@ def core_main(file_path, number_th, conf: config.Config):
path = create_folder(json_data, conf) path = create_folder(json_data, conf)
# 移动文件 # 移动文件
paste_file_to_folder_mode2(filepath, path, multi_part, number, part, leak_word, c_word, conf) paste_file_to_folder_mode2(filepath, path, multi_part, number, part, leak_word, c_word, conf)
poster_path = os.path.join(path, "{}{}{}-poster.jpg".format(number, leak_word, c_word)) poster_path = os.path.join(path, f"{number}{leak_word}{c_word}-poster.jpg")
thumb_path = os.path.join(path, "{}{}{}-thumb.jpg".format(number, leak_word, c_word)) thumb_path = os.path.join(path, f"{number}{leak_word}{c_word}-thumb.jpg")
if conf.is_watermark(): if conf.is_watermark():
add_mark(poster_path, thumb_path, cn_sub, leak, uncensored, conf) add_mark(poster_path, thumb_path, cn_sub, leak, uncensored, conf)
@@ -615,7 +611,7 @@ def core_main(file_path, number_th, conf: config.Config):
print_files(path, leak_word, c_word, json_data.get('naming_rule'), part, cn_sub, json_data, filepath, conf.failed_folder(), print_files(path, leak_word, c_word, json_data.get('naming_rule'), part, cn_sub, json_data, filepath, conf.failed_folder(),
tag, json_data.get('actor_list'), liuchu, uncensored) tag, json_data.get('actor_list'), liuchu, uncensored)
poster_path = os.path.join(path, "{}{}{}-poster.jpg".format(number, leak_word, c_word)) poster_path = os.path.join(path, f"{number}{leak_word}{c_word}-poster.jpg")
thumb_path = os.path.join(path, "{}{}{}-thumb.jpg".format(number, leak_word, c_word)) thumb_path = os.path.join(path, f"{number}{leak_word}{c_word}-thumb.jpg")
if conf.is_watermark(): if conf.is_watermark():
add_mark(poster_path, thumb_path, cn_sub, leak, uncensored, conf) add_mark(poster_path, thumb_path, cn_sub, leak, uncensored, conf)