add update CBZ ComicInfo.xml

This commit is contained in:
cwx
2025-02-10 12:18:30 +08:00
parent 0d5e26662f
commit 97449dca0b
2 changed files with 213 additions and 4 deletions
+13 -1
View File
@@ -205,6 +205,7 @@ class ImageInfo:
# Define the ComicInfo and ComicPageInfo classes
class ComicInfo:
# ComicInfo.xml 中的选项
def __init__(self):
self.Title: str = ""
"""标题"""
@@ -247,6 +248,7 @@ class ComicInfo:
self.Pages: List[ComicPageInfo] = []
class ComicPageInfo:
# ComicInfo.xml 中的<Page>
def __init__(self):
self.Image: int = -1
self.Type: str = "Story"
@@ -269,6 +271,9 @@ class ComicPageInfo:
return data
class ComicInfoXml:
"""
生成ComicInfo.xml
"""
def _save_xml_to_file(self, xml_string, filename):
"""
Save the XML string to a file
@@ -365,9 +370,14 @@ class ComicInfoXml:
#print(xml_data)
def _required_attributes(self):
"""
必需值,如果为空刚报错
"""
return ["Title", "Series", "Number", "PageCount", "Writer"]
def _gen_pageinfo(self, image_names, save_dir):
""" 获取PageInfo数据
"""
pages = []
# Adding pages to the comic
for image_name in image_names:
@@ -377,8 +387,10 @@ class ComicInfoXml:
# 图像属性 文件名 大小 长
pages.append(page)
return pages
def scrapy_xml_by_json(self, json_data, save_dir=None, xsd_file=XSD_FILE):
""" 根据Json数据生成ComicInfo.xml
"""
comic = ComicInfo()
comic.Title = json_data.get("chapter", "")
comic.Series = json_data.get("name", "")