Update DataClass.py, GetArc_Hitomi.py, and 2 more files...
작업한거 일단 커밋. 딱히 기능을 추가한건 없지만, 정리는 조금 했다. 정리 더 해야 하는데, 윈도우에서 작업하려고....커밋!!
This commit is contained in:
@@ -14,7 +14,10 @@ class CBZInfo:
|
||||
self.tags = set()
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.title} by {self.author} ({self.publication_year})"
|
||||
strArtists = ", ".join(self.artists)
|
||||
strTags = ", ".join(self.tags)
|
||||
|
||||
return f"ID : {self.gallery_id} - {self.title} by {strArtists} - #{strTags}"
|
||||
|
||||
def AddTag(self, name):
|
||||
self.tags.add(name)
|
||||
|
||||
@@ -5,6 +5,8 @@ from selenium.webdriver.support import expected_conditions as EC
|
||||
from selenium.common.exceptions import TimeoutException
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
import time
|
||||
|
||||
import UtilPack as util
|
||||
import DataClass as info
|
||||
|
||||
@@ -13,15 +15,16 @@ import DataClass as info
|
||||
def GetSearchResult(searchWord):
|
||||
url = getSiteUrl(searchWord)
|
||||
|
||||
util.DbgOut("Hitomi : " + url)
|
||||
|
||||
util.DbgOut("Hitomi : " + url, True)
|
||||
|
||||
driver = webdriver.Chrome()
|
||||
driver.get(url)
|
||||
|
||||
# 웹페이지가 로드될 때까지 기다리기
|
||||
try:
|
||||
WebDriverWait(driver, 30).until(
|
||||
EC.presence_of_element_located((By.CLASS_NAME, 'lillie'))
|
||||
WebDriverWait(driver, 10).until(
|
||||
#EC.presence_of_element_located((By.CLASS_NAME, 'lillie'))
|
||||
lambda d: d.execute_script("return document.readyState") == "complete"
|
||||
)
|
||||
except TimeoutException:
|
||||
util.DbgOut("페이지가 로드되지 않았거나 요소를 찾을 수 없습니다.")
|
||||
@@ -29,21 +32,49 @@ def GetSearchResult(searchWord):
|
||||
return
|
||||
|
||||
strContent = driver.page_source
|
||||
|
||||
listRet = parseMangaInfos(strContent)
|
||||
|
||||
for Idx in range(len(listRet)):
|
||||
print(f"{Idx} : {listRet[Idx]}")
|
||||
|
||||
driver.quit()
|
||||
|
||||
def GetListSearchResult(list_ID):
|
||||
driver = webdriver.Chrome()
|
||||
|
||||
# 웹페이지가 로드될 때까지 기다리기
|
||||
try:
|
||||
for id in list_ID:
|
||||
url = getSiteUrl(id)
|
||||
util.DbgOut("Hitomi : " + url, True)
|
||||
|
||||
driver.get(url)
|
||||
|
||||
WebDriverWait(driver, 10).until(
|
||||
lambda d: d.execute_script("return document.readyState") == "complete"
|
||||
)
|
||||
|
||||
time.sleep(2)
|
||||
|
||||
strContent = driver.page_source
|
||||
listRet = parseMangaInfos(strContent)
|
||||
|
||||
parseMangaInfos(strContent)
|
||||
|
||||
pass
|
||||
|
||||
for Idx in range(len(listRet)):
|
||||
print(f"{Idx} : {listRet[Idx]}")
|
||||
|
||||
except Exception as e:
|
||||
util.DbgOut("Hitomi Loading Error : ", e)
|
||||
finally:
|
||||
driver.quit()
|
||||
#
|
||||
def getSiteUrl(searchWord):
|
||||
strRet = "https://hitomi.la/"
|
||||
|
||||
if False == util.IsEmptyStr(searchWord):
|
||||
if False == searchWord.isdigit():
|
||||
strRet = strRet + "search.html?" + searchWord
|
||||
else:
|
||||
strRet = strRet + "galleries/" + searchWord + ".html"
|
||||
if False == searchWord.isdigit():
|
||||
strRet = f"{strRet}search.html?{searchWord}"
|
||||
else:
|
||||
strRet = f"{strRet}galleries/{searchWord}.html"
|
||||
|
||||
return strRet
|
||||
|
||||
@@ -57,8 +88,8 @@ def parseMangaInfos(html_doc):
|
||||
for element in gallery_elements:
|
||||
listDJ = djParse(element)
|
||||
listDJs.extend(listDJ)
|
||||
|
||||
print(len(listDJs))
|
||||
|
||||
return listDJs
|
||||
|
||||
|
||||
def djParse(soup_element):
|
||||
@@ -83,8 +114,8 @@ def djTitleParse(input_element):
|
||||
a_tag = element.find('a')
|
||||
url = a_tag.get('href')
|
||||
|
||||
util.DbgOut("title : " + title)
|
||||
util.DbgOut("URl : " + url)
|
||||
#util.DbgOut("title : " + title)
|
||||
#util.DbgOut("URl : " + url)
|
||||
|
||||
return info.CBZInfo(title, url)
|
||||
|
||||
@@ -127,7 +158,7 @@ def djDescParse(input_element, retPtr):
|
||||
|
||||
outMsg += f" {tag_name} {tag_url}\r\n"
|
||||
|
||||
util.DbgOut(outMsg)
|
||||
#util.DbgOut(outMsg)
|
||||
|
||||
#
|
||||
if "Series" == tds[0]:
|
||||
|
||||
66
UI.py
66
UI.py
@@ -4,6 +4,7 @@ import UtilPack as util
|
||||
import MgrCalibreDB as calDB
|
||||
import MgrCalibreLibs as calLib
|
||||
import pupildata as pupil
|
||||
import GetArc_Hitomi as hitomi
|
||||
|
||||
from io import BytesIO
|
||||
|
||||
@@ -131,36 +132,48 @@ class MyApp(QMainWindow):
|
||||
|
||||
|
||||
def on_click_SrcAdd(self):
|
||||
# 폴더 선택 창을 띄움
|
||||
folder_path = QFileDialog.getExistingDirectory(self, '폴더 선택', '')
|
||||
|
||||
if None == folder_path or True == util.IsEmptyStr(folder_path):
|
||||
return
|
||||
|
||||
# 소스 폴더 목록에 추가
|
||||
self.list_SrcPath.addItem(folder_path)
|
||||
self.AddSourceFoldertoList(folder_path)
|
||||
|
||||
#캘리버 서재 폴더인가?
|
||||
|
||||
def AddSourceFoldertoList(self, folder_path):
|
||||
#캘리버 서재 DB 파일을 먼저 확인
|
||||
pathCalDB = os.path.join( folder_path, "metadata.db")
|
||||
if True == os.path.exists(pathCalDB):
|
||||
db = calDB.MgrCalibreDB(pathCalDB)
|
||||
db.init()
|
||||
listBooks = db.GetBookListforUI_ArcList()
|
||||
for book in listBooks:
|
||||
# 이름은 폴더/DB 파일이름
|
||||
FolderName = util.GetParentDirName(folder_path, 0)
|
||||
item = QListWidgetItem(f"{FolderName}/{book[0]}")
|
||||
self.AddSourceCalibreDB(pathCalDB)
|
||||
else:
|
||||
self.AddSourceFolderContents(folder_path)
|
||||
|
||||
bookpath = os.path.join(folder_path, book[1])
|
||||
listfiles = util.FindFileFromExt(bookpath, "cbz")
|
||||
if 0 < len(listfiles):
|
||||
bookpath = os.path.join(bookpath, listfiles[0])
|
||||
|
||||
def AddSourceCalibreDB(self, pathCalDB):
|
||||
db = calDB.MgrCalibreDB(pathCalDB)
|
||||
|
||||
item.setData(Qt.UserRole, bookpath)
|
||||
self.list_ArcList.addItem(item)
|
||||
|
||||
if None == db:
|
||||
return
|
||||
|
||||
db.init()
|
||||
listBooks = db.GetBookListforUI_ArcList()
|
||||
for book in listBooks:
|
||||
# 이름은 폴더/DB 파일이름
|
||||
FolderName = util.GetParentDirName(pathCalDB, 0)
|
||||
item = QListWidgetItem(f"{FolderName}/{book[0]}")
|
||||
|
||||
bookpath = os.path.join(pathCalDB, book[1])
|
||||
listfiles = util.FindFileFromExt(bookpath, "cbz")
|
||||
if 0 < len(listfiles):
|
||||
bookpath = os.path.join(bookpath, listfiles[0])
|
||||
|
||||
item.setData(Qt.UserRole, bookpath)
|
||||
self.list_ArcList.addItem(item)
|
||||
|
||||
return
|
||||
|
||||
def AddSourceFolderContents(self, folder_path):
|
||||
# 폴더 내의 자식 폴더 목록을 가져온다.
|
||||
listFolders = util.ListSubDirectories(folder_path)
|
||||
listFolders.append(folder_path)
|
||||
@@ -197,8 +210,7 @@ class MyApp(QMainWindow):
|
||||
# 폴더 경로를 따로 저장
|
||||
item.setData(Qt.UserRole, folder)
|
||||
self.list_ArcList.addItem(item)
|
||||
|
||||
return
|
||||
|
||||
|
||||
def on_click_SrcDel(self):
|
||||
items = self.list_SrcPath.selectedItems()
|
||||
@@ -214,7 +226,21 @@ class MyApp(QMainWindow):
|
||||
|
||||
|
||||
def on_click_SrcRead(self):
|
||||
pass
|
||||
list_id = []
|
||||
for idx in range(self.list_ArcList.count()):
|
||||
item = self.list_ArcList.item(idx)
|
||||
|
||||
# 일단 파일 이름에 포함된 Hitomi ID 를 추출해 낸다.
|
||||
results = util.GetTextInBrakets(item.text())
|
||||
if 0 >= len(results):
|
||||
continue
|
||||
|
||||
if False == results[0].isdigit() or 0 >= int(results[0]):
|
||||
continue
|
||||
|
||||
list_id.append(results[0])
|
||||
|
||||
hitomi.GetListSearchResult(list_id)
|
||||
|
||||
|
||||
def on_Item_SelChanged_listArc(self):
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import os
|
||||
import re
|
||||
import time
|
||||
import uuid
|
||||
import rarfile
|
||||
@@ -16,7 +17,8 @@ listDbgStr = []
|
||||
|
||||
#
|
||||
def IsEmptyStr(string):
|
||||
return 0 == len(string.strip())
|
||||
temp = f"{string}"
|
||||
return 0 == len(temp.strip())
|
||||
|
||||
|
||||
#
|
||||
@@ -303,4 +305,6 @@ def UUIDGenRandom():
|
||||
def UUIDGenName(SeedName):
|
||||
namespace_uuid = uuid.uuid5(uuid.NAMESPACE_DNS, SeedName)
|
||||
return namespace_uuid
|
||||
|
||||
|
||||
def GetTextInBrakets(text):
|
||||
return re.findall(r'\[(.*?)\]', text)
|
||||
Reference in New Issue
Block a user