fix rouman
This commit is contained in:
1 parent
fd694cce81
commit
41a1e81fef
7 files changed
+81
-21
No files matched your search
@@ -1,16 +1,9 @@
|
|||||||
from utils.entity.JMTI import comicEntity
|
from utils.entity.RouMan import comicEntity
|
||||||
from utils.comic.ComicInfo import comicInfo
|
from utils.comic.ComicInfo import comicInfo
|
||||||
import os,shutil
|
|
||||||
|
|
||||||
def comics():
|
def comics():
|
||||||
for x in range(1,2):
|
for x in range(0,50):
|
||||||
comicEntity.downladsComcis("https://jmcomic.moe/albums/hanman?page="+str(x))
|
comicEntity.downladsComcis("https://rm01.xyz/books?&page="+str(x))
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
# os.environ["http_proxy"] = "http://127.0.0.1:7890"
|
comics()
|
||||||
# os.environ["https_proxy"] = "http://127.0.0.1:7890"
|
|
||||||
# url = "https://rm01.xyz/books/3700b70b-c5a9-4328-9ae3-cffda6a77339/15"
|
|
||||||
# comicEntity.comicChapter(url,scramble=True)
|
|
||||||
# comicEntity.oneComic("https://rm01.xyz/books/c94f80c1-a673-4c74-bb5e-ad5ac7dd766b")
|
|
||||||
# comicEntity.oneComic("https://jmcomic2.onl/album/403327/")
|
|
||||||
comicEntity.downladsComcis("https://jmcomic2.onl/albums/hanman?shunt=2")
|
|
||||||
+3
-3
@@ -75,7 +75,7 @@ class htmlUtils:
|
|||||||
if count <= 3:
|
if count <= 3:
|
||||||
try:
|
try:
|
||||||
print(f"请求地址:{curl}")
|
print(f"请求地址:{curl}")
|
||||||
res = s.get(curl,stream=True, headers=cls.headers, timeout=1000)
|
res = s.get(curl,stream=True, headers=cls.headers, timeout=180,allow_redirects=True)
|
||||||
if type == "bytes":
|
if type == "bytes":
|
||||||
url_text = res
|
url_text = res
|
||||||
if type == "json":
|
if type == "json":
|
||||||
@@ -85,8 +85,8 @@ class htmlUtils:
|
|||||||
if type == None:
|
if type == None:
|
||||||
url_text = html.fromstring(res.text)
|
url_text = html.fromstring(res.text)
|
||||||
cls.saveHtml(curl,res.text)
|
cls.saveHtml(curl,res.text)
|
||||||
# if res.status_code != 200:
|
if res.status_code != 200:
|
||||||
# cls.remove_HtmlCache(curl)
|
cls.remove_HtmlCache(curl)
|
||||||
except:
|
except:
|
||||||
print(f'Retry! 第{count}次')
|
print(f'Retry! 第{count}次')
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|||||||
+55
-1
@@ -1,4 +1,5 @@
|
|||||||
import base64,hashlib,os,shutil
|
import base64,hashlib,os,shutil
|
||||||
|
import math
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
||||||
@@ -143,4 +144,57 @@ class imageUtils:
|
|||||||
scrambleFileCache = cls.scrambleImage(path)
|
scrambleFileCache = cls.scrambleImage(path)
|
||||||
if not scrambleFileCache == None:
|
if not scrambleFileCache == None:
|
||||||
if os.path.exists(scrambleFileCache):
|
if os.path.exists(scrambleFileCache):
|
||||||
os.remove(scrambleFileCache)
|
os.remove(scrambleFileCache)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def encode_scramble_image(cls,imgpath):
|
||||||
|
image = Image.open(imgpath)
|
||||||
|
w, h = image.size
|
||||||
|
#image.show()
|
||||||
|
file_str = str(imgpath).split("=")
|
||||||
|
#10_29.jpg
|
||||||
|
base_dir = file_str[0].replace("scramble","")
|
||||||
|
base_name = file_str[-1]
|
||||||
|
base_fn = base_name.split("_")
|
||||||
|
save_name = base_fn[1]
|
||||||
|
save_name_delesu = save_name.split(".")[0]
|
||||||
|
blocks = int(base_fn[0])
|
||||||
|
img_type = os.path.basename(imgpath).split('.')[-1]
|
||||||
|
save_path = os.path.join(os.path.dirname(imgpath),save_name_delesu+"."+img_type)
|
||||||
|
# print(type(aid),type(img_name))
|
||||||
|
if blocks:
|
||||||
|
s = blocks # 随机值
|
||||||
|
# print(s)
|
||||||
|
l = h % s # 切割最后多余的值
|
||||||
|
box_list = []
|
||||||
|
hz = 0
|
||||||
|
for i in range(s):
|
||||||
|
c = math.floor(h / s)
|
||||||
|
g = i * c
|
||||||
|
hz += c
|
||||||
|
h2 = h - c * (i + 1) - l
|
||||||
|
if i == 0:
|
||||||
|
c += l;hz += l
|
||||||
|
else:
|
||||||
|
g += l
|
||||||
|
box_list.append((0, h2, w, h - g))
|
||||||
|
|
||||||
|
# print(box_list,len(box_list))
|
||||||
|
item_width = w
|
||||||
|
# box_list.reverse() #还原切图可以倒序列表
|
||||||
|
# print(box_list, len(box_list))
|
||||||
|
newh = 0
|
||||||
|
image_list = [image.crop(box) for box in box_list]
|
||||||
|
# print(box_list)
|
||||||
|
newimage = Image.new("RGB", (w, h))
|
||||||
|
for image in image_list:
|
||||||
|
# image.show()
|
||||||
|
b_w, b_h = image.size
|
||||||
|
newimage.paste(image, (0, newh))
|
||||||
|
|
||||||
|
newh += b_h
|
||||||
|
newimage.save(save_path)
|
||||||
|
print("解密成功=",save_path)
|
||||||
|
if os.path.exists(imgpath):
|
||||||
|
os.remove(imgpath)
|
||||||
|
print("remove=",imgpath)
|
||||||
@@ -145,6 +145,7 @@ class comicInfo():
|
|||||||
root_node = cls.document.createElement(cls.pages)
|
root_node = cls.document.createElement(cls.pages)
|
||||||
for page in value:
|
for page in value:
|
||||||
c_node = cls.document.createElement("Page")
|
c_node = cls.document.createElement("Page")
|
||||||
|
page = page.split("_")[-1]
|
||||||
c_node.setAttribute("Image",page)
|
c_node.setAttribute("Image",page)
|
||||||
root_node.appendChild(c_node)
|
root_node.appendChild(c_node)
|
||||||
cls.pages_node = root_node
|
cls.pages_node = root_node
|
||||||
|
|||||||
@@ -2,7 +2,8 @@ import os,datetime
|
|||||||
from time import strftime
|
from time import strftime
|
||||||
class pathStr:
|
class pathStr:
|
||||||
#base_comic_out = "COMICOUT"
|
#base_comic_out = "COMICOUT"
|
||||||
base_comic_out = os.path.join("/mnt", "bigTComics","JM")
|
#base_comic_out = os.path.join("/mnt", "bigTComics","JM")
|
||||||
|
base_comic_out = os.path.join("/mnt", "bigTComics")
|
||||||
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")
|
||||||
|
|||||||
@@ -12,12 +12,21 @@ from utils.downloader import download_images
|
|||||||
from utils.Ntfy import ntfy
|
from utils.Ntfy import ntfy
|
||||||
from utils.VerUtils import verUtils
|
from utils.VerUtils import verUtils
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
import get_jm_url
|
||||||
|
|
||||||
class comicEntity:
|
class comicEntity:
|
||||||
count_chapter = 0
|
count_chapter = 0
|
||||||
aid = None
|
aid = None
|
||||||
repeat = 0
|
repeat = 0
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def baseReUrl(cls,url):
|
||||||
|
newurl_list=get_jm_url.app()
|
||||||
|
if newurl_list:
|
||||||
|
if re.findall(r'https://(.*?)/\w+/\d+/',url)[0] not in newurl_list:
|
||||||
|
for newurl in newurl_list:
|
||||||
|
url = re.sub(re.findall(r'https://(.*?)/\w+/\d+/', url)[0], newurl, url)
|
||||||
|
return url
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def downladsComcis(cls,url):
|
def downladsComcis(cls,url):
|
||||||
|
|||||||
@@ -152,7 +152,8 @@ class comicEntity:
|
|||||||
isScramble = str(img).startswith("scramble=")
|
isScramble = str(img).startswith("scramble=")
|
||||||
if isScramble:
|
if isScramble:
|
||||||
c_path = os.path.join(chapter_dir, img)
|
c_path = os.path.join(chapter_dir, img)
|
||||||
imageUtils.getScrambleImage(c_path)
|
#imageUtils.getScrambleImage(c_path)
|
||||||
|
imageUtils.encode_scramble_image(c_path)
|
||||||
#进入下一阶段
|
#进入下一阶段
|
||||||
comicInfo.nextImgToDownloadChapter()
|
comicInfo.nextImgToDownloadChapter()
|
||||||
return is_next
|
return is_next
|
||||||
@@ -172,10 +173,6 @@ class comicEntity:
|
|||||||
comicInfo.setComicName(bookName)
|
comicInfo.setComicName(bookName)
|
||||||
comicInfo.setChapterName(chapterName)
|
comicInfo.setChapterName(chapterName)
|
||||||
comicInfo.setDep(description)
|
comicInfo.setDep(description)
|
||||||
pathComicInfo = comicInfo.getPathComicInfoXML()
|
|
||||||
if not os.path.exists(pathComicInfo):
|
|
||||||
#print("不存在ComicInfo.xml 生成中...")
|
|
||||||
comicInfo.writeComicInfoXML(chapterName)
|
|
||||||
|
|
||||||
if not chapterAPIPath == None:
|
if not chapterAPIPath == None:
|
||||||
chapterAPIPath = str(chapterAPIPath).encode('utf-8').decode('unicode_escape')
|
chapterAPIPath = str(chapterAPIPath).encode('utf-8').decode('unicode_escape')
|
||||||
@@ -237,6 +234,11 @@ class comicEntity:
|
|||||||
except:
|
except:
|
||||||
ntfy(f"删除失败 {cbz_path}")
|
ntfy(f"删除失败 {cbz_path}")
|
||||||
if is_next:
|
if is_next:
|
||||||
|
pathComicInfo = comicInfo.getPathComicInfoXML()
|
||||||
|
if not os.path.exists(pathComicInfo):
|
||||||
|
#print("不存在ComicInfo.xml 生成中...")
|
||||||
|
comicInfo.setPages(list_fileName)
|
||||||
|
comicInfo.writeComicInfoXML(chapterName)
|
||||||
ntfy.sendMsg(f"{bookName} {chapterName} 下载中")
|
ntfy.sendMsg(f"{bookName} {chapterName} 下载中")
|
||||||
download_images(list_img,comicInfo.getDirComicChapter(), filesName=list_fileName)
|
download_images(list_img,comicInfo.getDirComicChapter(), filesName=list_fileName)
|
||||||
return is_next
|
return is_next
|
||||||
Reference in new issue
Block a user