fix
This commit is contained in:
parent
b9c5c352c6
commit
1760bc82f8
2
main.py
2
main.py
@ -3,7 +3,7 @@ from utils.comic.ComicInfo import comicInfo
|
||||
import os,shutil
|
||||
|
||||
def comics():
|
||||
for x in range(0,5):
|
||||
for x in range(0,30):
|
||||
comicEntity.downladsComcis("https://rm01.xyz/books?&page="+str(x))
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
from fake_useragent import UserAgent
|
||||
import requests,os
|
||||
import requests,os,json
|
||||
from lxml import html
|
||||
import traceback
|
||||
import time
|
||||
@ -68,7 +68,8 @@ class htmlUtils:
|
||||
if type == "bytes":
|
||||
url_text = res
|
||||
if type == "json":
|
||||
url_text = res.json()
|
||||
#url_text = res.json()
|
||||
url_text = json.loads(res.text)
|
||||
cls.saveHtml(curl,res.text)
|
||||
if type == None:
|
||||
url_text = html.fromstring(res.text)
|
||||
@ -91,7 +92,9 @@ class htmlUtils:
|
||||
|
||||
@classmethod
|
||||
def getJSON(cls,url):
|
||||
return cls.getHTML(url,type="json")
|
||||
url_text = requests.get(url,headers=cls.headers, timeout=180).text
|
||||
return json.loads(url_text)
|
||||
#return cls.getHTML(url,type="json")
|
||||
|
||||
@classmethod
|
||||
def xpathData(cls,c_xpath,url=None,num=None,not_eq=None,update=False):
|
||||
|
||||
@ -249,7 +249,10 @@ class comicInfo():
|
||||
dir_name = os.path.dirname(path)
|
||||
if not os.path.exists(dir_name):
|
||||
os.makedirs(dir_name)
|
||||
|
||||
save_path = os.path.join(path)
|
||||
if os.path.exists(save_path):
|
||||
os.remove(save_path)
|
||||
data = json.dumps(data)
|
||||
if mode == None:
|
||||
mode = "w+"
|
||||
@ -261,6 +264,7 @@ class comicInfo():
|
||||
result = path + "文件写入成功"
|
||||
except:
|
||||
result = path + "文件写入失败"
|
||||
print(result)
|
||||
return result
|
||||
|
||||
@classmethod
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
import os,datetime
|
||||
from time import strftime
|
||||
class pathStr:
|
||||
base_comic_out = "COMICOUT"
|
||||
#base_comic_out = os.path.join("/mnt", "bigTComics")
|
||||
#base_comic_out = "COMICOUT"
|
||||
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")
|
||||
|
||||
@ -56,7 +56,7 @@ class comicEntity:
|
||||
@classmethod
|
||||
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)
|
||||
icon = htmlUtils.xpathData('//img[@class="img-thumbnail"]/@src',num=0)
|
||||
@ -67,7 +67,7 @@ class comicEntity:
|
||||
dep = htmlUtils.xpathData('//div[contains(@class,"bookid_bookInfo")]/p[4]/text()',num=1)
|
||||
update_date = htmlUtils.xpathData('//div[contains(@class,"bookid_bookInfo")]/p[5]/small/text()',num=1)
|
||||
chapters = htmlUtils.xpathData('//div[contains(@class,"bookid_chapterBox")]//div[contains(@class,"bookid_chapter")]/a/text()')
|
||||
chapter_href = htmlUtils.xpathData('//div[contains(@class,"bookid_chapterBox")]//div[contains(@class,"bookid_chapter")]/a/@href', update=True)
|
||||
chapter_href = htmlUtils.xpathData('//div[contains(@class,"bookid_chapterBox")]//div[contains(@class,"bookid_chapter")]/a/@href')
|
||||
|
||||
author = str(author).replace("&",",").replace(" ",",")
|
||||
comicInfo.setHomePage(c_url)
|
||||
@ -168,7 +168,6 @@ class comicEntity:
|
||||
description = x.get("description")
|
||||
images = x.get("images")
|
||||
chapterAPIPath = x.get("chapterAPIPath")
|
||||
chapterAPIPath = str(chapterAPIPath).encode('utf-8').decode('unicode_escape')
|
||||
comicInfo.setComicName(bookName)
|
||||
comicInfo.setChapterName(chapterName)
|
||||
comicInfo.setDep(description)
|
||||
@ -177,11 +176,13 @@ class comicEntity:
|
||||
#print("不存在ComicInfo.xml 生成中...")
|
||||
comicInfo.writeComicInfoXML(chapterName)
|
||||
|
||||
if chapterAPIPath != None:
|
||||
if not chapterAPIPath == None:
|
||||
chapterAPIPath = str(chapterAPIPath).encode('utf-8').decode('unicode_escape')
|
||||
base_url = comicInfo.getBaseUrl(chapter_url)
|
||||
chapterAPIUrl = base_url+chapterAPIPath
|
||||
ntfy.sendMsg(f"chapterApiUrl= {chapterAPIUrl}")
|
||||
data = json.loads(htmlUtils.getJSON(chapterAPIUrl))
|
||||
data = htmlUtils.getJSON(chapterAPIUrl)
|
||||
print(data)
|
||||
data = data.get("chapter")
|
||||
chapterName = data.get("name")
|
||||
images = data.get("images")
|
||||
@ -227,8 +228,11 @@ class comicEntity:
|
||||
ntfy.sendMsg(f"{bookName} {chapterName} 数据不完整,尝试删除配置CBZ文件后重试")
|
||||
htmlUtils.remove_HtmlCache(chapter_url)
|
||||
try:
|
||||
ntfy.sendMsg(f"删除 {cbz_path}")
|
||||
os.remove(cbz_path)
|
||||
if cbz_size < len(list_img):
|
||||
ntfy.sendMsg(f"删除 {cbz_path}")
|
||||
#os.remove(cbz_path)
|
||||
else:
|
||||
is_next = False
|
||||
except:
|
||||
ntfy(f"删除失败 {cbz_path}")
|
||||
if is_next:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user