convert Chinese
This commit is contained in:
parent
a549944e94
commit
2030325844
@ -27,7 +27,7 @@ class comicEntity:
|
|||||||
#漫画名
|
#漫画名
|
||||||
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)
|
||||||
#别名
|
#别名
|
||||||
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)
|
||||||
author = htmlUtils.xpathData('//div[contains(@class,"bookid_bookInfo")]/p[1]/text()',num=1)
|
author = htmlUtils.xpathData('//div[contains(@class,"bookid_bookInfo")]/p[1]/text()',num=1)
|
||||||
tags = htmlUtils.xpathData('//div[contains(@class,"bookid_bookInfo")]/p[3]/b/text()',num=0)
|
tags = htmlUtils.xpathData('//div[contains(@class,"bookid_bookInfo")]/p[3]/b/text()',num=0)
|
||||||
@ -39,5 +39,5 @@ class comicEntity:
|
|||||||
|
|
||||||
baseComic.oneComic(url=c_url,title=title,author=author,
|
baseComic.oneComic(url=c_url,title=title,author=author,
|
||||||
icon=icon,tags=tags,dep=dep,chapters=chapters,chapter_href=chapter_href,
|
icon=icon,tags=tags,dep=dep,chapters=chapters,chapter_href=chapter_href,
|
||||||
alias=alias,genre="韩漫",age_rating="R18+")
|
genre="韩漫",age_rating="R18+")
|
||||||
comicInfo.updateComicDate(date=date)
|
comicInfo.updateComicDate(date=date)
|
||||||
@ -7,6 +7,7 @@ from utils.comic.ComicInfo import comicInfo
|
|||||||
from utils.Ntfy import ntfy
|
from utils.Ntfy import ntfy
|
||||||
from utils.FileUtils import fileUtils as fu
|
from utils.FileUtils import fileUtils as fu
|
||||||
from utils.comic.PathStr import pathStr
|
from utils.comic.PathStr import pathStr
|
||||||
|
from utils.OldUtils import OldUtils
|
||||||
|
|
||||||
class CBZUtils:
|
class CBZUtils:
|
||||||
|
|
||||||
@ -135,7 +136,7 @@ class CBZUtils:
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def updateOldCBZ(cls,filesname,result=False):
|
def updateOldCBZ(cls,filesname,result=False):
|
||||||
old_zipfile_path = os.path.join(pathStr.old_cbz_path,comicInfo.str_comic_name,comicInfo.str_chapter+".CBZ")
|
old_zipfile_path = os.path.join(pathStr.old_cbz_path,OldUtils.getOldComicName(),OldUtils.getOldChapter()+".CBZ")
|
||||||
#判断是否存在已下载CBZ文件
|
#判断是否存在已下载CBZ文件
|
||||||
if fu.exists(old_zipfile_path) and fu.notExists(CBZUtils.getCBZ_Path()):
|
if fu.exists(old_zipfile_path) and fu.notExists(CBZUtils.getCBZ_Path()):
|
||||||
print(f"存在CBZ文件{old_zipfile_path},解压中...")
|
print(f"存在CBZ文件{old_zipfile_path},解压中...")
|
||||||
|
|||||||
6
utils/ComicUtils.py
Normal file
6
utils/ComicUtils.py
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
from opencc import OpenCC
|
||||||
|
|
||||||
|
class fontUtils:
|
||||||
|
@classmethod
|
||||||
|
def ChineseConvert(cls, text,convert='t2s'):
|
||||||
|
return OpenCC(convert).convert(text) # convert from Simplified Chinese to Traditional Chinese
|
||||||
16
utils/OldUtils.py
Normal file
16
utils/OldUtils.py
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
|
||||||
|
class OldUtils:
|
||||||
|
old_comic_name=None
|
||||||
|
old_chapter = None
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def setOldComicName(cls,value): cls.old_comic_name = value
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def setOldChapter(cls,value): cls.old_chapter=value
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def getOldComicName(cls): return cls.old_comic_name
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def getOldChapter(cls): return cls.old_chapter
|
||||||
@ -45,8 +45,7 @@ class baseComic:
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def oneComic(cls,url,title,author,icon,tags,dep,chapters,chapter_href,alias=None,genre=None,lang="zh",age_rating=None,sleep=None):
|
def oneComic(cls,url,title,author,icon,tags,dep,chapters,chapter_href,alias=None,genre=None,lang="zh",age_rating=None,sleep=None):
|
||||||
ci.setComicInfo(homepage=url,comicname=title,alias=ci.setComicNames(title+","+alias),
|
ci.setComicInfo(homepage=url,comicname=title,author=author,icon=icon,tags=tags,dep=dep,genre=genre,lang=lang,age_rating=age_rating,chapters=chapters)
|
||||||
author=author,icon=icon,tags=tags,dep=dep,genre=genre,lang=lang,age_rating=age_rating,chapters=chapters)
|
|
||||||
cls.count_chapter = 0
|
cls.count_chapter = 0
|
||||||
for href in chapter_href:
|
for href in chapter_href:
|
||||||
ci.setChapterName(chapters[cls.count_chapter])
|
ci.setChapterName(chapters[cls.count_chapter])
|
||||||
|
|||||||
@ -3,6 +3,8 @@ import os,re
|
|||||||
from utils.comic.PathStr import pathStr
|
from utils.comic.PathStr import pathStr
|
||||||
import json,shutil
|
import json,shutil
|
||||||
from utils.FileUtils import dbUtils
|
from utils.FileUtils import dbUtils
|
||||||
|
from utils.ComicUtils import fontUtils
|
||||||
|
from utils.OldUtils import OldUtils
|
||||||
|
|
||||||
class comicInfo():
|
class comicInfo():
|
||||||
COMIC_ICON_NAME = "000"
|
COMIC_ICON_NAME = "000"
|
||||||
@ -77,7 +79,7 @@ class comicInfo():
|
|||||||
def setNodeAndValue(cls,node,value):
|
def setNodeAndValue(cls,node,value):
|
||||||
if value != None:
|
if value != None:
|
||||||
c_node = cls.document.createElement(node)
|
c_node = cls.document.createElement(node)
|
||||||
node_text = cls.document.createTextNode(str(value).replace("\n",""))
|
node_text = cls.document.createTextNode(fontUtils.ChineseConvert(str(value).replace("\n","")))
|
||||||
c_node.appendChild(node_text)
|
c_node.appendChild(node_text)
|
||||||
return c_node
|
return c_node
|
||||||
return None
|
return None
|
||||||
@ -87,7 +89,8 @@ class comicInfo():
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setChapterName(cls,value):
|
def setChapterName(cls,value):
|
||||||
cls.str_chapter = cls.fixFileName(value)
|
cls.str_chapter = fontUtils.ChineseConvert(cls.fixFileName(value))
|
||||||
|
OldUtils.setOldChapter(cls.fixFileName(value))
|
||||||
cls.chapter_node = cls.setNodeAndValue(cls.chapter,value)
|
cls.chapter_node = cls.setNodeAndValue(cls.chapter,value)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -110,13 +113,14 @@ class comicInfo():
|
|||||||
def getLenChapters(cls): return len(cls.str_list_chapter)
|
def getLenChapters(cls): return len(cls.str_list_chapter)
|
||||||
@classmethod
|
@classmethod
|
||||||
def setComicName(cls,value):
|
def setComicName(cls,value):
|
||||||
cls.str_comic_name = cls.fixFileName(value)
|
cls.str_comic_name = fontUtils.ChineseConvert(cls.fixFileName(value))
|
||||||
|
OldUtils.setOldComicName(cls.fixFileName(value))
|
||||||
cls.comic_name_node = cls.setNodeAndValue(cls.comic_name, value)
|
cls.comic_name_node = cls.setNodeAndValue(cls.comic_name, value)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setComicNames(cls,value):
|
def setComicNames(cls,value):
|
||||||
#去重
|
#去重
|
||||||
value = ",".join(set(str(value).split(",")))
|
value = ",".join(set(str(fontUtils.ChineseConvert(value)).split(",")))
|
||||||
cls.comic_names_node = cls.setNodeAndValue(cls.comic_names,value)
|
cls.comic_names_node = cls.setNodeAndValue(cls.comic_names,value)
|
||||||
@classmethod
|
@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)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user