update
This commit is contained in:
+97
-161
@@ -6,7 +6,7 @@ import json,shutil
|
||||
|
||||
class comicInfo():
|
||||
document = Document()
|
||||
pathComicInfo = None
|
||||
path_comic_info = None
|
||||
|
||||
root = "ComicInfo"
|
||||
chapter = "Title"
|
||||
@@ -25,13 +25,13 @@ class comicInfo():
|
||||
pages = "Pages"
|
||||
web = "Web"
|
||||
|
||||
str_comicName = None
|
||||
str_comic_name = None
|
||||
str_chapter = None
|
||||
str_icon = None
|
||||
str_homePage = None
|
||||
str_listChapter = None
|
||||
str_homepage = None
|
||||
str_listchapter = None
|
||||
str_chapter_imgs = None
|
||||
str_updateAt = None
|
||||
str_update_at = None
|
||||
str_date_year = None
|
||||
str_date_month = None
|
||||
str_date_day = None
|
||||
@@ -44,13 +44,13 @@ class comicInfo():
|
||||
list_skip = []
|
||||
|
||||
chapter_node = None
|
||||
comicName_node = None
|
||||
comic_name_node = None
|
||||
dep_node = None
|
||||
author_node = None
|
||||
genre_node = None
|
||||
cbs_node = None
|
||||
lang_node = None
|
||||
comicNames_node = None
|
||||
comic_names_node = None
|
||||
tags_node = None
|
||||
date_year_node = None
|
||||
date_month_node = None
|
||||
@@ -69,8 +69,7 @@ class comicInfo():
|
||||
return None
|
||||
|
||||
@classmethod
|
||||
def Root(cls):
|
||||
return cls.document.createElement(cls.root)
|
||||
def root_node(cls): return cls.document.createElement(cls.root)
|
||||
|
||||
@classmethod
|
||||
def setChapterName(cls,value):
|
||||
@@ -78,86 +77,52 @@ class comicInfo():
|
||||
cls.chapter_node = cls.setNodeAndValue(cls.chapter,value)
|
||||
|
||||
@classmethod
|
||||
def setListChapter(cls, value):
|
||||
cls.str_listChapter = value
|
||||
|
||||
def setListChapter(cls, value): cls.str_list_chapter = value
|
||||
@classmethod
|
||||
def setChapterImgs(cls, value):
|
||||
cls.str_chapter_imgs = value
|
||||
|
||||
def setChapterImgs(cls, value): cls.str_chapter_imgs = value
|
||||
@classmethod
|
||||
def getChapterImgs(cls):
|
||||
return cls.str_chapter_imgs
|
||||
|
||||
def getChapterImgs(cls): return cls.str_chapter_imgs
|
||||
@classmethod
|
||||
def getLenChapters(cls):
|
||||
return len(cls.str_listChapter)
|
||||
|
||||
def getLenChapters(cls): return len(cls.str_list_chapter)
|
||||
@classmethod
|
||||
def setComicName(cls,value):
|
||||
cls.str_comicName = cls.fixFileName(value)
|
||||
cls.comicName_node = cls.setNodeAndValue(cls.comic_name, value)
|
||||
cls.str_comic_name = cls.fixFileName(value)
|
||||
cls.comic_name_node = cls.setNodeAndValue(cls.comic_name, value)
|
||||
|
||||
@classmethod
|
||||
def setComicNames(cls,value):
|
||||
cls.comicNames_node = cls.setNodeAndValue(cls.comic_names,value)
|
||||
|
||||
def setComicNames(cls,value): cls.comic_names_node = cls.setNodeAndValue(cls.comic_names,value)
|
||||
@classmethod
|
||||
def setDep(cls,value):
|
||||
cls.dep_node = cls.setNodeAndValue(cls.dep, value)
|
||||
|
||||
def setDep(cls,value): cls.dep_node = cls.setNodeAndValue(cls.dep, value)
|
||||
@classmethod
|
||||
def setAuthor(cls,value):
|
||||
cls.author_node = cls.setNodeAndValue(cls.author,cls.getListToString(value))
|
||||
|
||||
def setAuthor(cls,value): cls.author_node = cls.setNodeAndValue(cls.author,cls.getListToString(value))
|
||||
@classmethod
|
||||
def setLang(cls,value):
|
||||
cls.lang_node = cls.setNodeAndValue(cls.lang, value)
|
||||
|
||||
def setLang(cls,value): cls.lang_node = cls.setNodeAndValue(cls.lang, value)
|
||||
@classmethod
|
||||
def setGenre(cls,value):
|
||||
cls.genre_node = cls.setNodeAndValue(cls.genre, cls.getListToString(value))
|
||||
|
||||
def setGenre(cls,value): cls.genre_node = cls.setNodeAndValue(cls.genre, cls.getListToString(value))
|
||||
@classmethod
|
||||
def setTags(cls,value):
|
||||
cls.tags_node = cls.setNodeAndValue(cls.tags,cls.getListToString(value))
|
||||
|
||||
def setTags(cls,value): cls.tags_node = cls.setNodeAndValue(cls.tags,cls.getListToString(value))
|
||||
@classmethod
|
||||
def setCBS(cls,value):
|
||||
cls.cbs_node = cls.setNodeAndValue(cls.cbs,value)
|
||||
|
||||
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 setChapterListImg(cls,value):
|
||||
cls.str_list_img=value
|
||||
|
||||
def setChapterListImg(cls,value): cls.str_list_img=value
|
||||
@classmethod
|
||||
def setValue1(cls,value):
|
||||
cls.str_value1 = value
|
||||
|
||||
def setValue1(cls,value): cls.str_value1 = value
|
||||
@classmethod
|
||||
def getValue1(cls):
|
||||
return cls.str_value1
|
||||
|
||||
def getValue1(cls): return cls.str_value1
|
||||
@classmethod
|
||||
def getChapterListImg(cls):
|
||||
return cls.str_list_img
|
||||
|
||||
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=value
|
||||
@classmethod
|
||||
def getChapterFilesName(cls):
|
||||
return cls.str_files_img
|
||||
|
||||
def getChapterFilesName(cls): return cls.str_files_img
|
||||
@classmethod
|
||||
def getWeb(cls):
|
||||
return cls.str_web
|
||||
def getWeb(cls): return cls.str_web
|
||||
|
||||
@classmethod
|
||||
def setPageCount(cls,value):
|
||||
@@ -196,21 +161,13 @@ class comicInfo():
|
||||
return cls.str_icon
|
||||
|
||||
@classmethod
|
||||
def setHomePage(cls, value):
|
||||
cls.str_homePage = value
|
||||
|
||||
def setHomePage(cls, value): cls.str_homepage = value
|
||||
@classmethod
|
||||
def getHomePage(cls):
|
||||
return cls.str_homePage
|
||||
|
||||
def getHomePage(cls): return cls.str_homepage
|
||||
@classmethod
|
||||
def setUpdateAt(cls, value):
|
||||
cls.str_updateAt = value
|
||||
|
||||
def setUpdateAt(cls, value): cls.str_update_at = value
|
||||
@classmethod
|
||||
def getUpdateAt(cls):
|
||||
return cls.str_updateAt
|
||||
|
||||
def getUpdateAt(cls): return cls.str_update_at
|
||||
@classmethod
|
||||
def getListToString(cls,to_list):
|
||||
value = to_list
|
||||
@@ -219,28 +176,18 @@ class comicInfo():
|
||||
return value
|
||||
|
||||
@classmethod
|
||||
def setChapterIndex(cls,value):
|
||||
cls.str_chapter_index = value
|
||||
|
||||
def setChapterIndex(cls,value): cls.str_chapter_index = value
|
||||
@classmethod
|
||||
def getChapterIndex(cls):
|
||||
return cls.str_chapter_index
|
||||
|
||||
def getChapterIndex(cls): return cls.str_chapter_index
|
||||
@classmethod
|
||||
def setComicNameSkips(cls,value):
|
||||
return cls.list_skip.append(value)
|
||||
|
||||
def setComicNameSkips(cls,value): return cls.list_skip.append(value)
|
||||
@classmethod
|
||||
def getIsComicNameSkips(cls,value):
|
||||
return value in ",".join(cls.list_skip)
|
||||
def getIsComicNameSkips(cls,value): return value in ",".join(cls.list_skip)
|
||||
|
||||
'''
|
||||
获取网站主页
|
||||
'''
|
||||
@classmethod
|
||||
def getBaseUrl(cls,url=None):
|
||||
if url == None:
|
||||
url = cls.str_homePage
|
||||
url = cls.str_homepage
|
||||
num = 3
|
||||
index = 0
|
||||
for x in range(0, num):
|
||||
@@ -248,65 +195,65 @@ class comicInfo():
|
||||
return url[0:index-1]
|
||||
|
||||
@classmethod
|
||||
def getIcon(cls):
|
||||
return cls.str_icon
|
||||
|
||||
def getIcon(cls): return cls.str_icon
|
||||
@classmethod
|
||||
def getComicName(cls):
|
||||
return cls.str_comicName
|
||||
|
||||
def getComicName(cls): return cls.str_comic_name
|
||||
@classmethod
|
||||
def getChapter(cls):
|
||||
return cls.str_chapter
|
||||
def getChapter(cls): return cls.str_chapter
|
||||
|
||||
@classmethod
|
||||
def fixFileName(cls,filename,replace=None):
|
||||
intab = r'[?*/\|.:><]'
|
||||
str_replace = ""
|
||||
if not replace == None:
|
||||
if replace != None:
|
||||
str_replace = replace
|
||||
filename = re.sub(intab, str_replace, filename)
|
||||
count = 1
|
||||
while True:
|
||||
str_file = filename[0-count]
|
||||
if str_file == " ":
|
||||
count += 1
|
||||
else:
|
||||
filename = filename[0:len(filename)+1-count]
|
||||
break
|
||||
return filename
|
||||
|
||||
@classmethod
|
||||
def getDirConfComic(cls):
|
||||
if not cls.str_comicName == None:
|
||||
return os.path.join(pathStr.base_conf_path, cls.str_comicName)
|
||||
if cls.str_comic_name != None:
|
||||
return os.path.join(pathStr.base_conf_path(), cls.str_comic_name)
|
||||
else:
|
||||
print("comicName不存在,退出中")
|
||||
exit()
|
||||
|
||||
@classmethod
|
||||
def getDirCBZComic(cls):
|
||||
if not cls.str_comicName == None:
|
||||
return os.path.join(pathStr.base_cbz, cls.str_comicName)
|
||||
if cls.str_comic_name != None:
|
||||
return os.path.join(pathStr.base_cbz(), cls.str_comic_name)
|
||||
else:
|
||||
print("comicName不存在,退出中 getDirCBZComic")
|
||||
exit()
|
||||
|
||||
@classmethod
|
||||
def getDirCBZComicChapter(cls):
|
||||
if cls.str_comicName != None and cls.str_chapter != None:
|
||||
return os.path.join(pathStr.base_cbz,cls.str_comicName,cls.str_chapter)
|
||||
if cls.str_comic_name != None and cls.str_chapter != None:
|
||||
return os.path.join(pathStr.base_cbz(),cls.str_comic_name,cls.str_chapter)
|
||||
else:
|
||||
print("comicName不存在,退出中 getDirCBZComicChapter")
|
||||
exit()
|
||||
|
||||
@classmethod
|
||||
def getSortDirCBZComicChapter(cls):
|
||||
if cls.str_comicName != None and cls.str_chapter != None and cls.str_chapter_index != None:
|
||||
return os.path.join(pathStr.base_cbz,cls.str_comicName,str(cls.str_chapter_index)+" "+cls.str_chapter)
|
||||
if cls.str_comic_name != None and cls.str_chapter != None and cls.str_chapter_index != None:
|
||||
return os.path.join(pathStr.base_cbz(),cls.str_comic_name,str(cls.str_chapter_index)+" "+cls.str_chapter)
|
||||
else:
|
||||
print("comicName不存在,退出中 getSortDirCBZComicChapter")
|
||||
return None
|
||||
|
||||
@classmethod
|
||||
def getNewCBZComicChapter(cls,type="dir"):
|
||||
return cls.getNewToComicChapter(".CBZ", type)
|
||||
|
||||
def getNewCBZComicChapter(cls,type="dir"): return cls.getNewToComicChapter(".CBZ", type)
|
||||
@classmethod
|
||||
def getNewIconComicChapter(cls,type="dir"):
|
||||
return cls.getNewToComicChapter(".jpg", type)
|
||||
def getNewIconComicChapter(cls,type="dir"): return cls.getNewToComicChapter(".jpg", type)
|
||||
|
||||
@classmethod
|
||||
def getNewToComicChapter(cls,su,type="dir"):
|
||||
@@ -323,43 +270,40 @@ class comicInfo():
|
||||
|
||||
@classmethod
|
||||
def getDirComic(cls):
|
||||
if cls.str_comicName != None:
|
||||
return os.path.join(pathStr.base_comic_img, cls.str_comicName)
|
||||
if cls.str_comic_name != None:
|
||||
return os.path.join(pathStr.base_comic_img(), cls.str_comic_name)
|
||||
else:
|
||||
print("comicName不存在,退出中")
|
||||
exit()
|
||||
|
||||
@classmethod
|
||||
def getDirComicChapter(cls):
|
||||
if cls.str_comicName != None and cls.str_chapter != None:
|
||||
return os.path.join(pathStr.base_comic_img,cls.str_comicName,cls.str_chapter)
|
||||
if cls.str_comic_name != None and cls.str_chapter != None:
|
||||
return os.path.join(pathStr.base_comic_img(),cls.str_comic_name,cls.str_chapter)
|
||||
else:
|
||||
print("comicName与chapter 不存在,退出中")
|
||||
exit()
|
||||
@classmethod
|
||||
def getPathComicInfoXML(cls):
|
||||
try:
|
||||
cls.pathComicInfo = os.path.join(pathStr.base_comic_img,cls.str_comicName,cls.str_chapter,"ComicInfo.xml")
|
||||
cls.path_comic_info = os.path.join(pathStr.base_comic_img(),cls.str_comic_name,cls.str_chapter,"ComicInfo.xml")
|
||||
except:
|
||||
return None
|
||||
return cls.pathComicInfo
|
||||
return cls.path_comic_info
|
||||
|
||||
@classmethod
|
||||
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)
|
||||
root = cls.root_node()
|
||||
new_document = Document()
|
||||
new_document.appendChild(root)
|
||||
if cls.chapter_node != None: root.appendChild(cls.chapter_node)
|
||||
if cls.comicName_node != None: root.appendChild(cls.comicName_node)
|
||||
if cls.comic_name_node != None: root.appendChild(cls.comic_name_node)
|
||||
if cls.dep_node != None: root.appendChild(cls.dep_node)
|
||||
if cls.author_node != None: root.appendChild(cls.author_node)
|
||||
if cls.genre_node != None: root.appendChild(cls.genre_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.comic_names_node != None: root.appendChild(cls.comic_names_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)
|
||||
@@ -367,18 +311,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.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):
|
||||
if path != None: cls.path_comic_info = os.path.join(path,"ComicInfo.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 已存在")
|
||||
return None
|
||||
with open(cls.pathComicInfo , "w", encoding="utf-8") as fo:
|
||||
newDocument.writexml(fo, indent='', addindent='\t', newl='\n', encoding="utf-8")
|
||||
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.pathComicInfo)
|
||||
print("ComicInfo.xml 已生成 pathd=", cls.path_comic_info)
|
||||
|
||||
#文件保存
|
||||
@classmethod
|
||||
@@ -409,13 +351,13 @@ class comicInfo():
|
||||
@classmethod
|
||||
def nextSavePath(cls,next,data=None):
|
||||
save_path = cls.getDirConfComic()+"/"+next+cls.str_chapter
|
||||
if not data == None:
|
||||
if data != None:
|
||||
cls.file_save(save_path, data)
|
||||
return save_path
|
||||
|
||||
@classmethod
|
||||
def nextSaveInfoChapter(cls,chapter,data):
|
||||
if not cls.str_chapter == chapter:
|
||||
if cls.str_chapter != chapter:
|
||||
print(f"chapter {cls.str_chapter} 与 {chapter} 不一致,已自动跳过")
|
||||
cls.nextSavePath("info_",data)
|
||||
|
||||
@@ -444,8 +386,7 @@ class comicInfo():
|
||||
shutil.move(cbz,done)
|
||||
|
||||
@classmethod
|
||||
def nextDoneSave(cls,data):
|
||||
cls.nextSavePath("done_",data)
|
||||
def nextDoneSave(cls,data): cls.nextSavePath("done_",data)
|
||||
|
||||
@classmethod
|
||||
def nextExistsGetPath(cls,msg,remove=False):
|
||||
@@ -454,31 +395,26 @@ class comicInfo():
|
||||
if remove and is_exists:
|
||||
os.remove(path)
|
||||
return is_exists
|
||||
|
||||
|
||||
@classmethod
|
||||
def saveConfComicData(cls,fileName,data,comicName=None):
|
||||
if not comicName == None:
|
||||
cls.setComicName(comicName)
|
||||
dirConfComic = cls.getDirConfComic()
|
||||
save_path = os.path.join(dirConfComic,fileName)
|
||||
cls.file_save(save_path, data)
|
||||
|
||||
def setConfDirComicPath(cls,file_name,comic_name=None):
|
||||
if comic_name != None:
|
||||
cls.setComicName(comic_name)
|
||||
return os.path.join(cls.getDirConfComic(),file_name)
|
||||
|
||||
@classmethod
|
||||
def getPathInitConfComicData(cls,fileName,comicName=None):
|
||||
if not comicName == None:
|
||||
cls.setComicName(comicName)
|
||||
dirConfComic = cls.getDirConfComic()
|
||||
save_path = os.path.join(dirConfComic,fileName)
|
||||
return save_path
|
||||
def saveConfComicData(cls,file_name,data,comic_name=None): cls.file_save(cls.setConfDirComicPath(file_name,comic_name), data)
|
||||
@classmethod
|
||||
def getPathInitConfComicData(cls,file_name,comic_name=None): return cls.setConfDirComicPath(file_name,comic_name)
|
||||
|
||||
@classmethod
|
||||
def updateComicDate(cls,date=None):
|
||||
data = {}
|
||||
update_at = cls.str_updateAt
|
||||
update_at = cls.str_update_at
|
||||
if date != None:
|
||||
update_at = date
|
||||
comic_name = cls.str_comicName
|
||||
update_path = pathStr.base_comic_update
|
||||
comic_name = cls.str_comic_name
|
||||
update_path = pathStr.base_comic_update()
|
||||
update_dir = os.path.dirname(update_path)
|
||||
if not os.path.exists(update_dir):
|
||||
os.makedirs(update_dir)
|
||||
@@ -495,9 +431,9 @@ class comicInfo():
|
||||
def isUpdateComic(cls):
|
||||
is_update = True
|
||||
data = {}
|
||||
c_update_at = cls.str_updateAt
|
||||
comic_name = cls.str_comicName
|
||||
update_path = pathStr.base_comic_update
|
||||
c_update_at = cls.str_update_at
|
||||
comic_name = cls.str_comic_name
|
||||
update_path = pathStr.base_comic_update()
|
||||
update_dir = os.path.dirname(update_path)
|
||||
if not os.path.exists(update_dir):
|
||||
os.makedirs(update_dir)
|
||||
|
||||
+34
-11
@@ -1,22 +1,45 @@
|
||||
import os,datetime
|
||||
from time import strftime
|
||||
class pathStr:
|
||||
|
||||
comic_name = None
|
||||
comic_jm="JM"
|
||||
comic_bz="BZ"
|
||||
comic_rm="RM"
|
||||
|
||||
comic_url_main = None
|
||||
#base_comic_out = "COMICOUT"
|
||||
#base_comic_out = os.path.join("/mnt", "bigTComics","JM")
|
||||
if comic_url_main != None:
|
||||
base_comic_out = os.path.join("/mnt", "bigTComics", comic_url_main)
|
||||
base_comic_out = os.path.join("/mnt", "bigTComics")
|
||||
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")
|
||||
base_html_cache = os.path.join(base_comic_out,"html_cache")
|
||||
base_html_chapter = os.path.join(base_comic_out,"html_updated")
|
||||
base_comic_update = os.path.join(base_conf_path,"comic_update")
|
||||
|
||||
@classmethod
|
||||
def base_cbz(cls): return cls.getBaseComicPath("CBZ")
|
||||
@classmethod
|
||||
def base_comic_img(cls): return cls.getBaseComicPath("outputComic")
|
||||
@classmethod
|
||||
def base_conf_path(cls): return cls.getBaseComicPath(".conf")
|
||||
@classmethod
|
||||
def base_html_cache(cls): return cls.getBaseComicPath("html_cache")
|
||||
@classmethod
|
||||
def base_html_chapter(cls): return cls.getBaseComicPath("html_updated")
|
||||
@classmethod
|
||||
def base_comic_update(cls): return cls.getBaseComicPath("comic_update")
|
||||
|
||||
@classmethod
|
||||
def getBaseComicPath(cls,join_path): return os.path.join(cls.base_comic_out,join_path)
|
||||
|
||||
@classmethod
|
||||
def setComicMainAndPath(cls,value):
|
||||
cls.setComicMain(value)
|
||||
cls.setComicMainPath(value)
|
||||
|
||||
@classmethod
|
||||
def setComicMain(cls,value): cls.comic_name = value
|
||||
|
||||
@classmethod
|
||||
def getComicMain(cls): return cls.comic_name
|
||||
|
||||
@classmethod
|
||||
def setComicMainPath(cls,value):
|
||||
cls.comic_url_main = value
|
||||
if value != cls.comic_rm: 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