fix
This commit is contained in:
1 parent
fd8d056105
commit
9ec2963a61
5 files changed
+80
-13
No files matched your search
+4
-1
@@ -56,7 +56,10 @@ class CBZUtils:
|
|||||||
except:
|
except:
|
||||||
print(f"删除 {file} 发生错误,已跳过")
|
print(f"删除 {file} 发生错误,已跳过")
|
||||||
try:
|
try:
|
||||||
cls.zip_compression(chapter_path,packCBZ_path+".CBZ")
|
size_zip = cls.zip_compression(chapter_path,packCBZ_path+".CBZ")
|
||||||
|
size_imgs = len(comicInfo.getChapterImgs())
|
||||||
|
if size_zip -1 == size_zip:
|
||||||
|
ntfy.sendMsg(f"打包校验成功: {packCBZ_path}")
|
||||||
except:
|
except:
|
||||||
ntfy.sendMsg("CBZ打包失败")
|
ntfy.sendMsg("CBZ打包失败")
|
||||||
comicInfo.nextCBZToDoneChapter()
|
comicInfo.nextCBZToDoneChapter()
|
||||||
|
|||||||
+10
-2
@@ -17,7 +17,7 @@ class htmlUtils:
|
|||||||
def getPathSaveHtml(cls,url,type=None):
|
def getPathSaveHtml(cls,url,type=None):
|
||||||
rstr = r"[\/\\\:\*\?\"\<\>\|\.]" # '/ \ : * ? " < > |'
|
rstr = r"[\/\\\:\*\?\"\<\>\|\.]" # '/ \ : * ? " < > |'
|
||||||
file_url = re.sub(rstr, "", url)
|
file_url = re.sub(rstr, "", url)
|
||||||
file_path = os.path.join(pathStr.base_html_data(),file_url)
|
file_path = os.path.join(pathStr.base_html_cache,file_url)
|
||||||
if type == "new":
|
if type == "new":
|
||||||
return file_path
|
return file_path
|
||||||
if os.path.exists(file_path):
|
if os.path.exists(file_path):
|
||||||
@@ -85,12 +85,20 @@ class htmlUtils:
|
|||||||
return cls.getHTML(url,type="json")
|
return cls.getHTML(url,type="json")
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def xpathData(cls,c_xpath,url=None,num=None,not_eq=None):
|
def xpathData(cls,c_xpath,url=None,num=None,not_eq=None,update=False):
|
||||||
if url == None:
|
if url == None:
|
||||||
url = cls.temp_url
|
url = cls.temp_url
|
||||||
else:
|
else:
|
||||||
cls.temp_url = url
|
cls.temp_url = url
|
||||||
result = []
|
result = []
|
||||||
|
if update:
|
||||||
|
html_cache_path = cls.getPathSaveHtml(url,"new")
|
||||||
|
if os.path.exists(html_cache_path):
|
||||||
|
try:
|
||||||
|
os.remove(html_cache_path)
|
||||||
|
ntfy.sendMsg(f"html_cache更新成功 {html_cache_path}")
|
||||||
|
except:
|
||||||
|
ntfy.sendMsg(f"html_cache更新失败 {html_cache_path}")
|
||||||
#获取html实体数据
|
#获取html实体数据
|
||||||
et = cls.getHTML(url)
|
et = cls.getHTML(url)
|
||||||
#比对数据
|
#比对数据
|
||||||
|
|||||||
@@ -25,7 +25,8 @@ class comicInfo():
|
|||||||
str_homePage = None
|
str_homePage = None
|
||||||
str_listChapter = None
|
str_listChapter = None
|
||||||
str_chapter_imgs = None
|
str_chapter_imgs = None
|
||||||
|
str_updateAt = None
|
||||||
|
|
||||||
chapter_node = None
|
chapter_node = None
|
||||||
comicName_node = None
|
comicName_node = None
|
||||||
dep_node = None
|
dep_node = None
|
||||||
@@ -116,6 +117,14 @@ class comicInfo():
|
|||||||
def getHomePage(cls):
|
def getHomePage(cls):
|
||||||
return cls.str_homePage
|
return cls.str_homePage
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def setUpdateAt(cls, value):
|
||||||
|
cls.str_updateAt = value
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def getUpdateAt(cls):
|
||||||
|
return cls.str_updateAt
|
||||||
|
|
||||||
'''
|
'''
|
||||||
获取网站主页
|
获取网站主页
|
||||||
'''
|
'''
|
||||||
@@ -310,4 +319,43 @@ class comicInfo():
|
|||||||
cls.setComicName(comicName)
|
cls.setComicName(comicName)
|
||||||
dirConfComic = cls.getDirConfComic()
|
dirConfComic = cls.getDirConfComic()
|
||||||
save_path = os.path.join(dirConfComic,fileName)
|
save_path = os.path.join(dirConfComic,fileName)
|
||||||
return save_path
|
return save_path
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def updateComicDate(cls):
|
||||||
|
data = {}
|
||||||
|
update_at = cls.str_updateAt
|
||||||
|
comic_name = cls.str_comicName
|
||||||
|
update_path = pathStr.base_comic_update
|
||||||
|
update_dir = os.path.dirname(update_path)
|
||||||
|
if not os.path.exists(update_dir):
|
||||||
|
os.makedirs(update_dir)
|
||||||
|
if os.path.exists(update_path):
|
||||||
|
with open(update_path,"r") as fs:
|
||||||
|
data = json.loads(fs.read())
|
||||||
|
fs.close()
|
||||||
|
data[comic_name] = update_at
|
||||||
|
with open(update_path,"w") as fs:
|
||||||
|
fs.write(json.dumps(data))
|
||||||
|
fs.close()
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def isUpdateComic(cls):
|
||||||
|
is_update = True
|
||||||
|
data = {}
|
||||||
|
c_update_at = cls.str_updateAt
|
||||||
|
comic_name = cls.str_comicName
|
||||||
|
update_path = pathStr.base_comic_update
|
||||||
|
update_dir = os.path.dirname(update_path)
|
||||||
|
if not os.path.exists(update_dir):
|
||||||
|
os.makedirs(update_dir)
|
||||||
|
try:
|
||||||
|
with open(update_path,"r") as fs:
|
||||||
|
data = json.loads(fs.read())
|
||||||
|
fs.close()
|
||||||
|
except:
|
||||||
|
data = {}
|
||||||
|
comic_update = data.get(comic_name)
|
||||||
|
if comic_name != None and comic_update == c_update_at:
|
||||||
|
is_update = False
|
||||||
|
return is_update
|
||||||
@@ -6,10 +6,12 @@ class pathStr:
|
|||||||
base_CBZ = os.path.join(base_comic_out,"CBZ")
|
base_CBZ = os.path.join(base_comic_out,"CBZ")
|
||||||
base_comic_img = os.path.join(base_comic_out,"outputComic")
|
base_comic_img = os.path.join(base_comic_out,"outputComic")
|
||||||
base_conf_path = os.path.join(base_comic_out,".conf")
|
base_conf_path = os.path.join(base_comic_out,".conf")
|
||||||
#base_html_data = os.path.join(base_comic_out,"html_"+str(date))
|
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
|
@classmethod
|
||||||
def base_html_data(cls):
|
def base_html_week(cls):
|
||||||
date_path = cls.getDatePath()
|
date_path = cls.getDatePath()
|
||||||
return os.path.join(cls.base_comic_out,"html_"+str(date_path))
|
return os.path.join(cls.base_comic_out,"html_"+str(date_path))
|
||||||
|
|
||||||
|
|||||||
+12
-6
@@ -13,8 +13,8 @@ class comicEntity:
|
|||||||
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def baseComicData(cls,url):
|
def baseComicData(cls,url,update=False):
|
||||||
data = htmlUtils.xpathData('//script[@id="__NEXT_DATA__"]/text()',url=url)
|
data = htmlUtils.xpathData('//script[@id="__NEXT_DATA__"]/text()',url=url,update=update)
|
||||||
data = json.loads(data[0])
|
data = json.loads(data[0])
|
||||||
data = data.get("props")
|
data = data.get("props")
|
||||||
x = data.get("pageProps")
|
x = data.get("pageProps")
|
||||||
@@ -23,7 +23,7 @@ class comicEntity:
|
|||||||
@classmethod
|
@classmethod
|
||||||
def downladsComcis(cls,url):
|
def downladsComcis(cls,url):
|
||||||
#漫画名
|
#漫画名
|
||||||
x = cls.baseComicData(url)
|
x = cls.baseComicData(url,update=True)
|
||||||
books = x.get("books")
|
books = x.get("books")
|
||||||
len_books = len(books)
|
len_books = len(books)
|
||||||
base_url = comicInfo.getBaseUrl(url)
|
base_url = comicInfo.getBaseUrl(url)
|
||||||
@@ -32,6 +32,8 @@ class comicEntity:
|
|||||||
book_id = book.get("id")
|
book_id = book.get("id")
|
||||||
book_name = book.get("name")
|
book_name = book.get("name")
|
||||||
updated = book.get("updatedAt")
|
updated = book.get("updatedAt")
|
||||||
|
comicInfo.setComicName(book_name)
|
||||||
|
comicInfo.setUpdateAt(updated)
|
||||||
comic_href = base_url+"/books/"+book_id
|
comic_href = base_url+"/books/"+book_id
|
||||||
random_int = random.randint(5,20)
|
random_int = random.randint(5,20)
|
||||||
comicInfo.setComicName(book_name)
|
comicInfo.setComicName(book_name)
|
||||||
@@ -41,8 +43,12 @@ class comicEntity:
|
|||||||
time.sleep(random_int)
|
time.sleep(random_int)
|
||||||
else:
|
else:
|
||||||
ntfy.sendMsg(f"已存在 漫画:{book_name}")
|
ntfy.sendMsg(f"已存在 漫画:{book_name}")
|
||||||
cls.oneComic(comic_href, random.uniform(0,3))
|
if comicInfo.isUpdateComic():
|
||||||
|
cls.oneComic(comic_href, random.uniform(0,3))
|
||||||
|
comicInfo.updateComicDate()
|
||||||
|
else:
|
||||||
|
ntfy.sendMsg(f"{book_name} 已是最新")
|
||||||
|
|
||||||
print(books)
|
print(books)
|
||||||
#for comicHref in comicsHref:
|
#for comicHref in comicsHref:
|
||||||
# cls.oneComic(comicHref,random.uniform(10,20))
|
# cls.oneComic(comicHref,random.uniform(10,20))
|
||||||
@@ -50,7 +56,7 @@ class comicEntity:
|
|||||||
@classmethod
|
@classmethod
|
||||||
def oneComic(cls,c_url,sleep=None):
|
def oneComic(cls,c_url,sleep=None):
|
||||||
#漫画名
|
#漫画名
|
||||||
title = htmlUtils.xpathData('//div[@class="col"]/h5/text()',url=c_url,num=0)
|
title = htmlUtils.xpathData('//div[@class="col"]/h5/text()',url=c_url,num=0,update=True)
|
||||||
#别名
|
#别名
|
||||||
alias = htmlUtils.xpathData('//span[contains(@class,"bookid_alias")]/text()',num=1)
|
alias = htmlUtils.xpathData('//span[contains(@class,"bookid_alias")]/text()',num=1)
|
||||||
icon = htmlUtils.xpathData('//img[@class="img-thumbnail"]/@src',num=0)
|
icon = htmlUtils.xpathData('//img[@class="img-thumbnail"]/@src',num=0)
|
||||||
|
|||||||
Reference in new issue
Block a user