Skip to content

Commit

Permalink
删除cbz使用的Pinyin库(bug多)
Browse files Browse the repository at this point in the history
  • Loading branch information
misaka10843 committed Jan 28, 2024
1 parent 6b944da commit 91dc7ba
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
19 changes: 10 additions & 9 deletions cbz.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"<?xml version=\"1.0\"?>\n<ComicInfo xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" " \
f"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n " \
f"<Title>{pinyin.get_pinyin(title)}</Title>\n " \
f"<Series>{pinyin.get_pinyin(manga_name)}</Series>\n " \
f"<Number>{pinyin.get_pinyin(index)}</Number>\n" \
f"</ComicInfo>"
with open(os.path.join(os.path.join(config.SETTINGS['download_path'], save_dir), "ComicInfo.xml"), "w") as file:
xml_data = f'<?xml version="1.0"?>' \
'<ComicInfo xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">' \
f'<Title>{title}</Title>' \
f'<Series>{manga_name}</Series>' \
f'<Number>{index}</Number>' \
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文件中
Expand Down
4 changes: 2 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand All @@ -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存档[/]")


Expand Down

0 comments on commit 91dc7ba

Please sign in to comment.