This commit is contained in:
cwx
2023-01-08 17:30:08 +08:00
parent 8739e0f4c8
commit f632ba738f
16 changed files with 1230 additions and 45 deletions
+94 -30
View File
@@ -17,8 +17,14 @@ class comicInfo():
cbs = "Publisher"
lang = "LanguageISO"
comic_names = "SeriesGroup"
tags = "Tag"
tags = "Tags"
date_year = "Year"
date_month = "Month"
date_day = "Day"
page_count = "PageCount"
pages = "Pages"
web = "Web"
str_comicName = None
str_chapter = None
str_icon = None
@@ -26,7 +32,12 @@ class comicInfo():
str_listChapter = None
str_chapter_imgs = None
str_updateAt = None
str_date_year = None
str_date_month = None
str_date_day = None
str_page_count = None
str_web = None
chapter_node = None
comicName_node = None
dep_node = None
@@ -36,12 +47,18 @@ class comicInfo():
lang_node = None
comicNames_node = None
tags_node = None
date_year_node = None
date_month_node = None
date_day_node = None
page_count_node = None
pages_node = None
web_node = None
@classmethod
def setNodeAndValue(cls,node,value):
if not value == None:
if value != None:
c_node = cls.document.createElement(node)
node_text = cls.document.createTextNode(value)
node_text = cls.document.createTextNode(str(value).replace("\n",""))
c_node.appendChild(node_text)
return c_node
return None
@@ -86,7 +103,7 @@ class comicInfo():
@classmethod
def setAuthor(cls,value):
cls.author_node = cls.setNodeAndValue(cls.author,value)
cls.author_node = cls.setNodeAndValue(cls.author,cls.getListToString(value))
@classmethod
def setLang(cls,value):
@@ -94,16 +111,55 @@ class comicInfo():
@classmethod
def setTag(cls,value):
cls.tag_node = cls.setNodeAndValue(cls.tag, value)
cls.tag_node = cls.setNodeAndValue(cls.tag, cls.getListToString(value))
@classmethod
def setTags(cls,value):
cls.tags_node = cls.setNodeAndValue(cls.tags,value)
cls.tags_node = cls.setNodeAndValue(cls.tags,cls.getListToString(value))
@classmethod
def setCBS(cls,value):
cls.cbs_node = cls.setNodeAndValue(cls.cbs,value)
@classmethod
def setWeb(cls,value):
cls.str_web = value
cls.web_node = cls.setNodeAndValue(cls.web,value)
@classmethod
def getWeb(cls):
return cls.str_web
@classmethod
def setPageCount(cls,value):
cls.str_page_count = value
cls.page_count_node = cls.setNodeAndValue(cls.page_count,value)
@classmethod
def setPages(cls,value):
if value != None:
su = "."+str(value[0]).split(".")[-1]
join_list=",".join(value).replace(su,"")
value = join_list.split(",")
cls.setPageCount(str(len(value)))
root_node = cls.document.createElement(cls.pages)
for page in value:
c_node = cls.document.createElement("Page")
c_node.setAttribute("Image",page)
root_node.appendChild(c_node)
cls.pages_node = root_node
@classmethod
def setDate(cls,value,split):
values = str(value).split(split)
cls.str_date_year = values[0]
cls.str_date_month = values[1]
cls.str_date_day = values[2]
cls.date_year_node = cls.setNodeAndValue(cls.date_year,values[0])
cls.date_month_node = cls.setNodeAndValue(cls.date_month,values[1])
cls.date_day_node = cls.setNodeAndValue(cls.date_day,values[2])
@classmethod
def setIcon(cls,value):
cls.str_icon = value
@@ -124,7 +180,14 @@ class comicInfo():
@classmethod
def getUpdateAt(cls):
return cls.str_updateAt
@classmethod
def getListToString(cls,to_list):
value = to_list
if isinstance(to_list,list):
value = ",".join(to_list)
return value
'''
获取网站主页
'''
@@ -207,39 +270,40 @@ class comicInfo():
return cls.pathComicInfo
@classmethod
def writeComicInfoXML(cls,chapter):
def writeComicInfoXML(cls,chapter,path=None):
if cls.chapter == cls.fixFileName(chapter):
print(f"cls.chapter {cls.chapter} 与 chapter {chapter} 不相等,已自动跳过")
root = cls.Root()
newDocument = Document()
newDocument.appendChild(root)
if not cls.chapter_node == None:
root.appendChild(cls.chapter_node)
if not cls.comicName_node == None:
root.appendChild(cls.comicName_node)
if not cls.dep_node == None:
root.appendChild(cls.dep_node)
if not cls.author_node == None:
root.appendChild(cls.author_node)
if not cls.tag_node == None:
root.appendChild(cls.tag_node)
if not cls.cbs_node == None:
root.appendChild(cls.cbs_node)
if not cls.lang_node == None:
root.appendChild(cls.lang_node)
if not cls.comicNames_node == None:
root.appendChild(cls.comicNames_node)
if not cls.tags_node == None:
root.appendChild(cls.tags_node)
if cls.chapter_node != None: root.appendChild(cls.chapter_node)
if cls.comicName_node != None: root.appendChild(cls.comicName_node)
if cls.dep_node != None: root.appendChild(cls.dep_node)
if cls.author_node != None: root.appendChild(cls.author_node)
if cls.tag_node != None: root.appendChild(cls.tag_node)
if cls.cbs_node != None: root.appendChild(cls.cbs_node)
if cls.lang_node != None: root.appendChild(cls.lang_node)
if cls.comicNames_node != None: root.appendChild(cls.comicNames_node)
if cls.tags_node != None: root.appendChild(cls.tags_node)
if cls.date_year_node != None: root.appendChild(cls.date_year_node)
if cls.date_month_node != None: root.appendChild(cls.date_month_node)
if cls.date_day_node != None: root.appendChild(cls.date_day_node)
if cls.page_count_node != None: root.appendChild(cls.page_count_node)
if cls.pages_node != None: root.appendChild(cls.pages_node)
cls.getPathComicInfoXML()
if path != None:
cls.pathComicInfo = os.path.join(path,"ComicInfo.xml")
base_dir = os.path.dirname(cls.pathComicInfo)
if not os.path.exists(base_dir):
os.makedirs(base_dir)
if os.path.exists(cls.pathComicInfo):
print("ComicInfo.xml 已存在")
return None
with open(cls.pathComicInfo , "w", encoding="utf-8") as fo:
newDocument.writexml(fo, indent='', addindent='\t', newl='\n', encoding="utf-8")
fo.close()
#print("ComicInfo.xml 已生成 pathd=", cls.pathComicInfo)
print("ComicInfo.xml 已生成 pathd=", cls.pathComicInfo)
#文件保存
@classmethod
+1 -1
View File
@@ -2,7 +2,7 @@ import os,datetime
from time import strftime
class pathStr:
#base_comic_out = "COMICOUT"
base_comic_out = os.path.join("/mnt", "bigTComics")
base_comic_out = os.path.join("/mnt", "bigTComics","JM")
base_CBZ = os.path.join(base_comic_out,"CBZ")
base_comic_img = os.path.join(base_comic_out,"outputComic")
base_conf_path = os.path.join(base_comic_out,".conf")