From efc94917a6d8810658930caa7c7452470e6be349 Mon Sep 17 00:00:00 2001 From: lededev Date: Wed, 22 Sep 2021 00:47:15 +0800 Subject: [PATCH] shorter str formatting --- core.py | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/core.py b/core.py index 07e6c00..7c131bf 100755 --- a/core.py +++ b/core.py @@ -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(",","") file_parent_origin_path = str(pathlib.Path(filepath).parent) 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 使用软链接 if conf.soft_link() == 0: 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: if os.path.exists(filepath.replace(houzhui, subname)): # 字幕移动 - shutil.move(filepath.replace(houzhui, subname), - os.path.join(path, "{}{}{}{}".format(number, leak_word, c_word, subname))) + shutil.move(filepath.replace(houzhui, subname), os.path.join(path, f"{number}{leak_word}{c_word}{subname}")) print('[+]Sub moved!') 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) try: if conf.soft_link(): - os.symlink(filepath, - os.path.join(path, "{}{}{}{}{}".format(number, part, leak_word, c_word, houzhui))) + os.symlink(filepath, os.path.join(path, f"{number}{part}{leak_word}{c_word}{houzhui}")) else: - shutil.move(filepath, - os.path.join(path, "{}{}{}{}{}".format(number, part, leak_word, c_word, houzhui))) + shutil.move(filepath, os.path.join(path, f"{number}{part}{leak_word}{c_word}{houzhui}")) sub_res = conf.sub_rule() for subname in sub_res: if os.path.exists(filepath.replace(houzhui, subname)): # 字幕移动 - shutil.move(filepath.replace(houzhui, subname), - os.path.join(path, "{}{}{}{}{}".format(number, part, leak_word, c_word, subname))) + shutil.move(filepath.replace(houzhui, subname), os.path.join(path, f"{number}{part}{leak_word}{c_word}{subname}")) print('[+]Sub moved!') print('[!]Success') 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) - poster_path = os.path.join(path, "{}{}{}-poster.jpg".format(number, leak_word, c_word)) - thumb_path = os.path.join(path, "{}{}{}-thumb.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, f"{number}{leak_word}{c_word}-thumb.jpg") if conf.is_watermark(): 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) # 移动文件 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)) - thumb_path = os.path.join(path, "{}{}{}-thumb.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, f"{number}{leak_word}{c_word}-thumb.jpg") if conf.is_watermark(): 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(), tag, json_data.get('actor_list'), liuchu, uncensored) - poster_path = os.path.join(path, "{}{}{}-poster.jpg".format(number, leak_word, c_word)) - thumb_path = os.path.join(path, "{}{}{}-thumb.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, f"{number}{leak_word}{c_word}-thumb.jpg") if conf.is_watermark(): add_mark(poster_path, thumb_path, cn_sub, leak, uncensored, conf)