Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Haoyi-Han committed Apr 7, 2024
2 parents c10d10c + 35b644d commit 24e27b7
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.5.3
0.5.5
12 changes: 9 additions & 3 deletions moe_utils/comic_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

MoxBookType: list[str] = ["其他", "單行本", "番外篇", "連載話"]

all_volume_pattern: str = r"全[01234567890零一二三四五六七八九十百千萬億万亿壹貳叄肆伍陸柒捌玖拾佰仟贰叁陆]+[卷話冊]"


class MoxBook:
"""
Expand Down Expand Up @@ -46,7 +48,11 @@ def booktype(self) -> str:

@staticmethod
def _full_count(vol: str) -> int:
return cn2an_simple(vol.replace("全", "").replace("卷", ""))
vol = vol.replace("全", "")
for vol_mark in "卷話冊":
if vol_mark in vol:
vol = vol.replace(vol_mark, "")
return cn2an_simple(vol)

@staticmethod
def _full_count_str(vol: str) -> str:
Expand All @@ -73,7 +79,7 @@ def _serial_diff_count(vol: str) -> int:
def number(self) -> str:
pattern_actions = {
r"卷\d+": MoxBook._volume_count_str,
r"全[01234567890零一二三四五六七八九十百千萬億万亿壹貳叄肆伍陸柒捌玖拾佰仟贰叁陆]+卷": MoxBook._full_count_str,
all_volume_pattern: MoxBook._full_count_str,
r"話(\d+?-\d+)": MoxBook._serial_count,
}

Expand All @@ -87,7 +93,7 @@ def number(self) -> str:
def count(self) -> int:
pattern_actions = {
r"卷\d+": MoxBook._volume_count,
r"全[01234567890零一二三四五六七八九十百千萬億万亿壹貳叄肆伍陸柒捌玖拾佰仟贰叁陆]+卷": MoxBook._full_count,
all_volume_pattern: MoxBook._full_count,
r"話(\d+?-\d+)": MoxBook._serial_diff_count,
}

Expand Down
3 changes: 2 additions & 1 deletion moe_utils/file_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@ def make_archive(
if root_dir is not None:
_root_dir = make_path(root_dir)
assert _root_dir is not None
filelist = make_paths(list(_root_dir.rglob("*.*")), resolve=False)
# 7z 不能接受过长路径,因此改为传递整个文件夹
filelist = make_paths([_root_dir], resolve=False)

self._make_args_a(zipfile=_zipfile, filelist=filelist)
sevenz_args = self.sevenz_a_args
Expand Down
8 changes: 6 additions & 2 deletions moe_utils/manga_repacker.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,12 @@ def pack_folder(self) -> Path:
self._cbz_file = self._cbz_file.parent / f"{self.comic_name}.cbz"
comic_base: Path = self._cbz_file.with_suffix("")

# 由于文档的时间戳随获取方式有别,故以文档内封面图片的时间戳为准
comic_cover: Path = self._pack_from_dir / "cover.jpg"

# 修改漫画文件夹时间戳为原 EPUB 文档内部的时间戳
copy_file_timestamp(comic_cover, self._pack_from_dir)

if self._use_extern_7z:
self._extern_7z.make_archive(self._cbz_file, root_dir=self._pack_from_dir)
else:
Expand All @@ -437,8 +443,6 @@ def pack_folder(self) -> Path:
cbz_path = self._cbz_file

# 修改新建立的 CBZ 文件时间戳为原 EPUB 文档内部的时间戳
# 由于文档的时间戳随获取方式有别,故以文档内封面图片的时间戳为准
comic_cover: Path = self._pack_from_dir / "cover.jpg"
copy_file_timestamp(comic_cover, cbz_path)

self.log(f"{self.comic_name} => [green]打包完成")
Expand Down

0 comments on commit 24e27b7

Please sign in to comment.