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