fix
This commit is contained in:
+74
-47
@@ -2,9 +2,17 @@ from xml.dom.minidom import Document
|
||||
import os,re
|
||||
from utils.comic.PathStr import pathStr
|
||||
import json,shutil
|
||||
|
||||
from utils.FileUtils import dbUtils
|
||||
|
||||
class comicInfo():
|
||||
COMIC_ICON_NAME = "cover"
|
||||
COMIC_INFO_XML = "ComicInfo.xml"
|
||||
PROGRESS_INFO = "info"
|
||||
PROGRESS_DOWN = "download"
|
||||
PROGRESS_IMG = "download"
|
||||
PROGRESS_CBZ = "cbz"
|
||||
PROGRESS_DONE = "done"
|
||||
|
||||
document = Document()
|
||||
path_comic_info = None
|
||||
|
||||
@@ -75,11 +83,18 @@ class comicInfo():
|
||||
def setChapterName(cls,value):
|
||||
cls.str_chapter = cls.fixFileName(value)
|
||||
cls.chapter_node = cls.setNodeAndValue(cls.chapter,value)
|
||||
|
||||
|
||||
@classmethod
|
||||
def setListChapter(cls, value): cls.str_list_chapter = value
|
||||
def setComicValue(cls,value):
|
||||
result = None
|
||||
if value != None or value != "":
|
||||
result = value
|
||||
return result
|
||||
|
||||
@classmethod
|
||||
def setChapterImgs(cls, value): cls.str_chapter_imgs = value
|
||||
def setListChapter(cls, value): cls.str_list_chapter = cls.setComicValue(value)
|
||||
@classmethod
|
||||
def setChapterImgs(cls, value): cls.str_chapter_imgs = cls.setComicValue(value)
|
||||
@classmethod
|
||||
def getChapterImgs(cls): return cls.str_chapter_imgs
|
||||
@classmethod
|
||||
@@ -106,11 +121,11 @@ class comicInfo():
|
||||
|
||||
@classmethod
|
||||
def setWeb(cls,value):
|
||||
cls.str_web = value
|
||||
cls.web_node = cls.setNodeAndValue(cls.web,value)
|
||||
cls.str_web = cls.setComicValue(value)
|
||||
cls.web_node = cls.setNodeAndValue(cls.web,cls.setComicValue(value))
|
||||
|
||||
@classmethod
|
||||
def setChapterListImg(cls,value): cls.str_list_img=value
|
||||
def setChapterListImg(cls,value): cls.str_list_img=cls.setComicValue(value)
|
||||
@classmethod
|
||||
def setValue1(cls,value): cls.str_value1 = value
|
||||
@classmethod
|
||||
@@ -118,7 +133,7 @@ class comicInfo():
|
||||
@classmethod
|
||||
def getChapterListImg(cls): return cls.str_list_img
|
||||
@classmethod
|
||||
def setChapterFilesName(cls,value): cls.str_files_img=value
|
||||
def setChapterFilesName(cls,value): cls.str_files_img=cls.setComicValue(value)
|
||||
@classmethod
|
||||
def getChapterFilesName(cls): return cls.str_files_img
|
||||
@classmethod
|
||||
@@ -126,8 +141,8 @@ class comicInfo():
|
||||
|
||||
@classmethod
|
||||
def setPageCount(cls,value):
|
||||
cls.str_page_count = value
|
||||
cls.page_count_node = cls.setNodeAndValue(cls.page_count,value)
|
||||
cls.str_page_count = cls.setComicValue(int(value)+1)
|
||||
cls.page_count_node = cls.setNodeAndValue(cls.page_count,cls.str_page_count)
|
||||
|
||||
@classmethod
|
||||
def setPages(cls,value):
|
||||
@@ -137,6 +152,11 @@ class comicInfo():
|
||||
value = join_list.split(",")
|
||||
cls.setPageCount(str(len(value)))
|
||||
root_node = cls.document.createElement(cls.pages)
|
||||
#添加封面
|
||||
icon_node = cls.document.createElement("Page")
|
||||
icon_node.setAttribute("Image","cover")
|
||||
icon_node.setAttribute("Type","FrontCover")
|
||||
root_node.appendChild(icon_node)
|
||||
for page in value:
|
||||
c_node = cls.document.createElement("Page")
|
||||
page = page.split("_")[-1]
|
||||
@@ -157,15 +177,15 @@ class comicInfo():
|
||||
|
||||
@classmethod
|
||||
def setIcon(cls,value):
|
||||
cls.str_icon = value
|
||||
cls.str_icon = cls.setComicValue(value)
|
||||
return cls.str_icon
|
||||
|
||||
@classmethod
|
||||
def setHomePage(cls, value): cls.str_homepage = value
|
||||
def setHomePage(cls, value): cls.str_homepage = cls.setComicValue(value)
|
||||
@classmethod
|
||||
def getHomePage(cls): return cls.str_homepage
|
||||
@classmethod
|
||||
def setUpdateAt(cls, value): cls.str_update_at = value
|
||||
def setUpdateAt(cls, value): cls.str_update_at = cls.setComicValue(value)
|
||||
@classmethod
|
||||
def getUpdateAt(cls): return cls.str_update_at
|
||||
@classmethod
|
||||
@@ -176,7 +196,7 @@ class comicInfo():
|
||||
return value
|
||||
|
||||
@classmethod
|
||||
def setChapterIndex(cls,value): cls.str_chapter_index = value
|
||||
def setChapterIndex(cls,value): cls.str_chapter_index = cls.setComicValue(value)
|
||||
@classmethod
|
||||
def getChapterIndex(cls): return cls.str_chapter_index
|
||||
@classmethod
|
||||
@@ -286,7 +306,7 @@ class comicInfo():
|
||||
@classmethod
|
||||
def getPathComicInfoXML(cls):
|
||||
try:
|
||||
cls.path_comic_info = os.path.join(pathStr.base_comic_img(),cls.str_comic_name,cls.str_chapter,"ComicInfo.xml")
|
||||
cls.path_comic_info = os.path.join(pathStr.base_comic_img(),cls.str_comic_name,cls.str_chapter, cls.COMIC_INFO_XML)
|
||||
except:
|
||||
return None
|
||||
return cls.path_comic_info
|
||||
@@ -311,16 +331,16 @@ class comicInfo():
|
||||
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.path_comic_info = os.path.join(path,"ComicInfo.xml")
|
||||
if path != None: cls.path_comic_info = os.path.join(path,cls.COMIC_INFO_XML)
|
||||
base_dir = os.path.dirname(cls.path_comic_info)
|
||||
if not os.path.exists(base_dir): os.makedirs(base_dir)
|
||||
if os.path.exists(cls.path_comic_info):
|
||||
print("ComicInfo.xml 已存在")
|
||||
print(f"{cls.COMIC_INFO_XML} 已存在")
|
||||
return None
|
||||
with open(cls.path_comic_info , "w", encoding="utf-8") as fo:
|
||||
new_document.writexml(fo, indent='', addindent='\t', newl='\n', encoding="utf-8")
|
||||
fo.close()
|
||||
print("ComicInfo.xml 已生成 pathd=", cls.path_comic_info)
|
||||
print(f"{cls.COMIC_INFO_XML} 已生成 pathd=", cls.path_comic_info)
|
||||
|
||||
#文件保存
|
||||
@classmethod
|
||||
@@ -359,47 +379,37 @@ class comicInfo():
|
||||
def nextSaveInfoChapter(cls,chapter,data):
|
||||
if cls.str_chapter != chapter:
|
||||
print(f"chapter {cls.str_chapter} 与 {chapter} 不一致,已自动跳过")
|
||||
cls.setProgress(cls.PROGRESS_INFO)
|
||||
cls.nextSavePath("info_",data)
|
||||
|
||||
@classmethod
|
||||
def nextInfoToImgChapter(cls):
|
||||
info = cls.nextSavePath("info_")
|
||||
img = cls.nextSavePath("img_")
|
||||
shutil.move(info,img)
|
||||
|
||||
def nextInfoToImgChapter(cls): cls.setProgress(cls.PROGRESS_IMG)
|
||||
@classmethod
|
||||
def nextImgToDownloadChapter(cls):
|
||||
img = cls.nextSavePath("img_")
|
||||
download = cls.nextSavePath("down_")
|
||||
shutil.move(img, download)
|
||||
|
||||
def nextImgToDownloadChapter(cls): cls.setProgress(cls.PROGRESS_DOWN)
|
||||
@classmethod
|
||||
def nextDownloadToCBZChapter(cls):
|
||||
download = cls.nextSavePath("down_")
|
||||
cbz = cls.nextSavePath("cbz_")
|
||||
shutil.move(download, cbz)
|
||||
|
||||
def nextDownloadToCBZChapter(cls): cls.setProgress(cls.PROGRESS_CBZ)
|
||||
@classmethod
|
||||
def nextCBZToDoneChapter(cls):
|
||||
cbz = cls.nextSavePath("cbz_")
|
||||
done = cls.nextSavePath("done_")
|
||||
shutil.move(cbz,done)
|
||||
|
||||
def nextCBZToDoneChapter(cls): cls.setProgress(cls.PROGRESS_DONE)
|
||||
@classmethod
|
||||
def nextDoneSave(cls,data): cls.nextSavePath("done_",data)
|
||||
@classmethod
|
||||
def setProgress(cls,progress):
|
||||
dbUtils.setComic(cls.str_chapter,progress,cls.str_comic_name)
|
||||
|
||||
@classmethod
|
||||
def nextExistsGetPath(cls,msg,remove=False):
|
||||
path = cls.nextSavePath(msg)
|
||||
is_exists = os.path.exists(path)
|
||||
if remove and is_exists:
|
||||
os.remove(path)
|
||||
return is_exists
|
||||
def isProgress(cls,progress,remove=None):
|
||||
if remove: cls.setProgress("None")
|
||||
return dbUtils.query(cls.str_chapter,progress,cls.str_comic_name)
|
||||
|
||||
@classmethod
|
||||
def iconDB(cls): dbUtils.setComic(cls.str_comic_name,cls.str_icon,"icons")
|
||||
|
||||
@classmethod
|
||||
def equIcon(cls): return dbUtils.query(cls.str_comic_name,cls.str_icon,"icons")
|
||||
|
||||
@classmethod
|
||||
def setConfDirComicPath(cls,file_name,comic_name=None):
|
||||
if comic_name != None:
|
||||
cls.setComicName(comic_name)
|
||||
if comic_name != None: cls.setComicName(comic_name)
|
||||
return os.path.join(cls.getDirConfComic(),file_name)
|
||||
|
||||
@classmethod
|
||||
@@ -451,4 +461,21 @@ class comicInfo():
|
||||
@classmethod
|
||||
def comicChapterDownload(cls,imgs,names):
|
||||
cls.setChapterListImg(imgs)
|
||||
cls.setChapterFilesName(names)
|
||||
cls.setChapterFilesName(names)
|
||||
|
||||
@classmethod
|
||||
def setComicInfo(cls,comicname=None,homepage=None,alias=None,author=None,icon=None,tags=None,
|
||||
dep=None,genre=None,lang=None,chapters=None,update_at=None):
|
||||
author = str(author).replace("&",",").replace(" ",",")
|
||||
cls.setHomePage(homepage)
|
||||
cls.setComicName(str(comicname))
|
||||
if alias != None: comicInfo.setComicNames(alias)
|
||||
cls.setAuthor(author)
|
||||
cls.setIcon(icon)
|
||||
cls.setTags(tags)
|
||||
cls.setDep(dep)
|
||||
#comicInfo.setCBS("韩漫")
|
||||
if genre != None: cls.setGenre(genre)
|
||||
cls.setLang(lang)
|
||||
cls.setListChapter(chapters)
|
||||
cls.setUpdateAt(update_at)
|
||||
@@ -8,7 +8,7 @@ class pathStr:
|
||||
comic_rm="RM"
|
||||
|
||||
comic_url_main = None
|
||||
base_comic_out = os.path.join("/mnt", "bigTComics")
|
||||
base_comic_out = os.path.join("/mnt", "Comics")
|
||||
|
||||
@classmethod
|
||||
def base_cbz(cls): return cls.getBaseComicPath("CBZ")
|
||||
@@ -22,6 +22,8 @@ class pathStr:
|
||||
def base_html_chapter(cls): return cls.getBaseComicPath("html_updated")
|
||||
@classmethod
|
||||
def base_comic_update(cls): return cls.getBaseComicPath("comic_update")
|
||||
@classmethod
|
||||
def base_db(cls): return cls.getBaseComicPath("db")
|
||||
|
||||
@classmethod
|
||||
def getBaseComicPath(cls,join_path): return os.path.join(cls.base_comic_out,join_path)
|
||||
@@ -39,7 +41,8 @@ class pathStr:
|
||||
|
||||
@classmethod
|
||||
def setComicMainPath(cls,value):
|
||||
if value != cls.comic_rm: cls.base_comic_out = os.path.join(cls.base_comic_out, value)
|
||||
#if value != cls.comic_rm: cls.base_comic_out = os.path.join(cls.base_comic_out, value)
|
||||
cls.base_comic_out = os.path.join(cls.base_comic_out, value)
|
||||
|
||||
@classmethod
|
||||
def base_html_week(cls):
|
||||
|
||||
Reference in New Issue
Block a user