diff --git a/cbz.py b/cbz.py index 0444b61..5fd0d7c 100644 --- a/cbz.py +++ b/cbz.py @@ -6,19 +6,20 @@ import config -def create_cbz(index, title, manga_name, save_dir, cbz_dir): +def create_cbz(index, title, manga_name, save_dir, cbz_dir, path_word): pinyin = Pinyin() - xml_data = f"\n\n " \ - f"{pinyin.get_pinyin(title)}\n " \ - f"{pinyin.get_pinyin(manga_name)}\n " \ - f"{pinyin.get_pinyin(index)}\n" \ - f"" - with open(os.path.join(os.path.join(config.SETTINGS['download_path'], save_dir), "ComicInfo.xml"), "w") as file: + xml_data = f'' \ + '' \ + f'{title}' \ + f'{manga_name}' \ + f'{index}' \ + f'/ComicInfo>"' + with open(os.path.join(os.path.join(config.SETTINGS['download_path'], save_dir), "ComicInfo.xml"), "w", + encoding='utf8') as file: file.write(xml_data) start_dir = os.path.join(config.SETTINGS['download_path'], save_dir) - file_name = f"{save_dir}/{pinyin.get_pinyin(manga_name)}/{manga_name}{title}.cbz" + file_name = f"{save_dir}/{path_word}/{manga_name}{title}.cbz" file_path = os.path.join(cbz_dir, file_name) # 只添加指定类型的文件到zip文件中 diff --git a/main.py b/main.py index 131abe6..5dfeb80 100644 --- a/main.py +++ b/main.py @@ -568,7 +568,6 @@ def chapter_allocation(manga_chapter_json): time.sleep(0.5) t.join() threads.clear() - print(manga_chapter_info_json['results']['chapter']['comic_path_word']) # 实施添加下载进度 if ARGS and ARGS.subscribe == "1": save_new_update(manga_chapter_info_json['results']['chapter']['comic_path_word'], @@ -579,7 +578,8 @@ def chapter_allocation(manga_chapter_json): if config.SETTINGS['CBZ']: with console.status(f"[bold yellow]正在保存CBZ存档:[{manga_name}]{chapter_name}[/]"): create_cbz(str(int(manga_chapter_info_json['results']['chapter']['index']) + 1), chapter_name, - manga_name, f"{manga_name}/{chapter_name}/", config.SETTINGS['cbz_path']) + manga_name, f"{manga_name}/{chapter_name}/", config.SETTINGS['cbz_path'], + manga_chapter_info_json['results']['chapter']['comic_path_word']) print(f"[bold green][:white_check_mark:]已将[{manga_name}]{chapter_name}保存为CBZ存档[/]")