update version
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
import json
|
||||
from utils.NetUtils import htmlUtils
|
||||
from common.ComicInfo import ComicInfoUtils as ciUtils
|
||||
from common.BaseComicEntity import baseComic
|
||||
|
||||
class comicEntity:
|
||||
@classmethod
|
||||
def baseComicData(cls,url,update=False):
|
||||
data = htmlUtils.xpathData('//script[@id="__NEXT_DATA__"]/text()',url=url,update=update)
|
||||
data = json.loads(data[0])
|
||||
data = data.get("props")
|
||||
x = data.get("pageProps")
|
||||
return x
|
||||
|
||||
@classmethod
|
||||
def downladsComcis(cls,url):
|
||||
#漫画名
|
||||
x = cls.baseComicData(url)
|
||||
books = x.get("books")
|
||||
len_books = len(books)
|
||||
base_url = ciUtils.getBaseUrl(url)
|
||||
for x in range(0, len_books):
|
||||
book = books[x]
|
||||
book_id = book.get("id")
|
||||
book_name = book.get("name")
|
||||
updated = book.get("updatedAt")
|
||||
comic_href = base_url+"/books/"+book_id
|
||||
href = baseComic.downladsComcis(book_name=book_name,comic_href=comic_href,updated=updated)
|
||||
cls.oneComic(href)
|
||||
ciUtils.updateComicDate()
|
||||
|
||||
@classmethod
|
||||
def oneComic(cls,c_url,sleep=None):
|
||||
#漫画名
|
||||
title = htmlUtils.xpathData('//div[@class="gb-inside-container"]/h1[contains(@class,"gb-headline-text")]/text()',url=c_url,update=True,num=0)
|
||||
#别名
|
||||
#alias = htmlUtils.xpathData('//span[contains(@class,"bookid_alias")]/text()',num=1)
|
||||
#icon = htmlUtils.xpathData('//div[contains(@class,"gb-container")]/div[@class="gb-inside-container"]/img[contains(@class,"dynamic-featured-image")]/@src')
|
||||
icon = htmlUtils.xpathData('//noscript/img[contains(@class,"dynamic-featured-image")]/@src',num=0)
|
||||
author = htmlUtils.xpathData('//div[@class="gb-inside-container"]/div[@class="author-content"]/a/text()', num=0)
|
||||
tags = htmlUtils.xpathData('//div[@class="gb-inside-container"]/div[@class="genres-content"]/a/text()')
|
||||
dep = htmlUtils.xpathData('//div[@class="gb-inside-container"]/div/p/text()')
|
||||
dep = "".join(dep)
|
||||
#update_date = htmlUtils.xpathData('//div[@class="chapter-content-listing"]//a[@class="wp-manga-chapterlist"]//span[@class="chapter-release-date"]/i/text()')
|
||||
chapters_url = htmlUtils.xpathData('//div[@class="chapter-content-listing"]//a[@class="c-chapter-readmore"]/@href',url=c_url,num=0)
|
||||
chapters = htmlUtils.xpathData('//div[@class="chapter-content-listing"]//a[@class="wp-manga-chapterlist"]/text()',not_eq=' ',url=chapters_url)
|
||||
chapter_href = htmlUtils.xpathData('//div[@class="chapter-content-listing"]//a[@class="wp-manga-chapterlist"]/@href',url=chapters_url)
|
||||
|
||||
baseComic.oneComic(url=c_url,title=title,author=author,
|
||||
icon=icon,tags=tags,dep=dep,chapters=chapters,chapter_href=chapter_href,
|
||||
alias=None)
|
||||
@@ -0,0 +1,11 @@
|
||||
from domain.down.Baozi import DomainDown as baozi
|
||||
from domain.down.RouMan import DomainDown as rouman
|
||||
from common.Constant import pathStr
|
||||
|
||||
class domains:
|
||||
@classmethod
|
||||
def setdomain(cls,url):
|
||||
comic_main = pathStr.getComicMain()
|
||||
if comic_main == pathStr.comic_bz: baozi.comicChapterDownload(url)
|
||||
if comic_main == pathStr.comic_rm: rouman.comicChapterDownload(url)
|
||||
if comic_main == None: print("comic_main为空,退出中...") & exit()
|
||||
@@ -0,0 +1,47 @@
|
||||
from common.Constant import pathStr
|
||||
from common.Comic import ListComic
|
||||
from common.Comic import Comic
|
||||
from common.BaseComicEntity import baseComic
|
||||
from utils.NetUtils import htmlUtils
|
||||
|
||||
class comicEntity:
|
||||
@classmethod
|
||||
def downladsComcis(cls,url):
|
||||
str_xpath='//script[@id="__NEXT_DATA__"]/text()'
|
||||
str_exec="props.pageProps.books"
|
||||
books = htmlUtils.setXpathData(url,xpath=str_xpath,num=0,exec=str_exec)
|
||||
#comic_names = htmlUtils.setXpathData(url,xpath=str_xpath,num=0,exec=str_exec,result_type="list",type="name")
|
||||
#chapter_links = htmlUtils.setXpathData(url,xpath=str_xpath,num=0,exec=str_exec,result_type="list",type="id"
|
||||
# ,start_add=pathStr.getBaseUrl(url)+"/books/")
|
||||
#update_at= htmlUtils.setXpathData(url,xpath=str_xpath,num=0,exec=str_exec,result_type="list",type="updateAt")
|
||||
#ciUtils.setListComicsLinksUpdateAt(comic_names,chapter_links,update_at)
|
||||
ListComic.setListComicName(books,"name")
|
||||
ListComic.setListComicChapterLink(books,"id",start_add=pathStr.getBaseUrl(url)+"/books/")
|
||||
ListComic.setListComicUpdateAt(books,"updateAt")
|
||||
return baseComic.updateComics(chapters_xpath='//div[contains(@class,"bookid_chapterBox")]//div[contains(@class,"bookid_chapter")]/a/text()')
|
||||
|
||||
@classmethod
|
||||
def oneComic(cls,sleep=None):
|
||||
c_url = Comic.getCurrentDownLink()
|
||||
if c_url == None: return None
|
||||
title = htmlUtils.getXpathData('//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.getXpathData('//img[@class="img-thumbnail"]/@src',num=0)
|
||||
author = htmlUtils.getXpathData('//div[contains(@class,"bookid_bookInfo")]/p[1]/text()',num=1)
|
||||
tags = htmlUtils.getXpathData('//div[contains(@class,"bookid_bookInfo")]/p[3]/b/text()',num=0)
|
||||
action = htmlUtils.getXpathData('//div[contains(@class,"bookid_bookInfo")]/p[2]/text()',num=1)
|
||||
dep = htmlUtils.getXpathData('//div[contains(@class,"bookid_bookInfo")]/p[4]/text()',num=1)
|
||||
update_date = htmlUtils.getXpathData('//div[contains(@class,"bookid_bookInfo")]/p[5]/small/text()',num=1)
|
||||
chapters = htmlUtils.getXpathData('//div[contains(@class,"bookid_chapterBox")]//div[contains(@class,"bookid_chapter")]/a/text()')
|
||||
chapter_href = htmlUtils.getXpathData('//div[contains(@class,"bookid_chapterBox")]//div[contains(@class,"bookid_chapter")]/a/@href')
|
||||
|
||||
baseComic.oneComic(url=c_url,title=title,author=author,
|
||||
icon=icon,tags=tags,dep=dep,chapters=chapters,chapter_href=chapter_href,
|
||||
genre="韩漫",age_rating="R18+")
|
||||
|
||||
@classmethod
|
||||
def start(cls,url):
|
||||
pathStr.setComicMainAndPath(pathStr.comic_rm)
|
||||
cls.downladsComcis(url)
|
||||
cls.oneComic()
|
||||
@@ -0,0 +1,23 @@
|
||||
from common.ComicInfo import ComicInfoUtils as ciUtils
|
||||
from common.ComicInfo import ComicInfo as ci
|
||||
from common.Comic import Comic
|
||||
from utils.NetUtils import htmlUtils
|
||||
|
||||
class DomainDown:
|
||||
@classmethod
|
||||
def comicChapterDownload(cls,chapter_url):
|
||||
imgs_url =htmlUtils.xpathData("//div[@class='gb-inside-container']/img/@data-src",url=chapter_url,update=True)
|
||||
# pages_imgs =htmlUtils.xpathData("//div[@class='center scramble-page']/@id",url=chapter_url)
|
||||
#print("img_list:",len(img_list))
|
||||
list_img = []
|
||||
list_file_name = []
|
||||
count = 1
|
||||
for i in imgs_url:
|
||||
img_su = str(i).split('.')[-1]
|
||||
count_image = "{:0>3d}".format(count)
|
||||
list_file_name.append(count_image+"."+img_su)
|
||||
list_img.append(count_image)
|
||||
count += 1
|
||||
ci.setPages(list_img)
|
||||
ci.writeComicInfoXML(Comic.getChapterName())
|
||||
ciUtils.comicChapterDownload(imgs_url,list_file_name)
|
||||
@@ -0,0 +1,44 @@
|
||||
from common.ComicInfo import ComicInfo as ci
|
||||
from common.ComicInfo import Comic
|
||||
from common.ComicInfo import ComicInfoUtils as ciUtils
|
||||
from common.Constant import pathStr
|
||||
from utils.FileUtils import imageUtils
|
||||
from utils.NetUtils import htmlUtils
|
||||
from utils.ComicUtils import ntfy
|
||||
|
||||
class DomainDown:
|
||||
@classmethod
|
||||
def comicChapterDownload(cls,chapter_url):
|
||||
str_xpath='//script[@id="__NEXT_DATA__"]/text()'
|
||||
str_exec="props.pageProps"
|
||||
book = htmlUtils.setXpathData(chapter_url,xpath=str_xpath,num=0,exec=str_exec)
|
||||
Comic.setComicName(book,"bookName")
|
||||
Comic.setChapterName(book,"chapterName")
|
||||
#alias = x.get("alias")
|
||||
Comic.setDep(book,"description")
|
||||
images = Comic.getValue(book,"images")
|
||||
chapter_api_url = ci.parseExec(book,"chapterAPIPath",start_add=pathStr.getBaseUrl(chapter_url))
|
||||
|
||||
if chapter_api_url != None:
|
||||
ntfy.sendMsg(f"chapterApiUrl= {chapter_api_url}",alert=False)
|
||||
data = htmlUtils.getJSON(chapter_api_url,update=True)
|
||||
if data != None:
|
||||
Comic.setChapterName(data,"chapter.name")
|
||||
images = Comic.getValue(data,"chapter.images")
|
||||
if len(images) == 0:
|
||||
ntfy.sendMsg(f"未获取到章节图像 comic_name={Comic.getComicName()} chapter={Comic.getChapterName()}")
|
||||
|
||||
count = 1
|
||||
list_img,list_file_name = [[],[]]
|
||||
for image in images:
|
||||
(image_src,scramble) = [image.get("src"),image.get("scramble")]
|
||||
count_image = "{:0>3d}".format(count)
|
||||
list_img.append(image_src)
|
||||
image_src_prefix = "."+str(image_src).split(".")[-1]
|
||||
if scramble:
|
||||
de_str = str(image_src).split("/")[-1].replace(image_src_prefix,"==")
|
||||
blocks_num = imageUtils.encodeImage(de_str)
|
||||
count_image = "scramble="+str(blocks_num)+"_"+count_image
|
||||
list_file_name.append(count_image+image_src_prefix)
|
||||
count+=1
|
||||
ciUtils.comicChapterDownload(list_img,list_file_name)
|
||||
Reference in New Issue
Block a user