From f1345e277062d82ac951a4f6991088052a4d720e Mon Sep 17 00:00:00 2001 From: Lee Young Hoon Date: Tue, 15 Jul 2025 11:14:05 +0900 Subject: [PATCH] =?UTF-8?q?=EC=9D=BC=EB=8B=A8=20=EC=A0=95=EB=A6=AC..?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DataClass.py | 48 +++++++++++++++++++++++++++++++++++++++++++++--- GetArc_Hitomi.py | 14 ++++++++++++-- UI.py | 45 ++++++++++++++++++++++++++------------------- UtilPack.py | 42 ++++++++++++++++++------------------------ 4 files changed, 101 insertions(+), 48 deletions(-) diff --git a/DataClass.py b/DataClass.py index a3c97f3..232b37a 100644 --- a/DataClass.py +++ b/DataClass.py @@ -2,7 +2,7 @@ class CBZInfo: def __init__(self, title, url): self.title = title self.url = url - self.serires = "" + self.series = "" self.type = "" self.filename = "" self.torrent = "" @@ -18,6 +18,48 @@ class CBZInfo: strTags = ", ".join(self.tags) return f"ID : {self.gallery_id} - {self.title} by {strArtists} - #{strTags}" + + def SaveToText(self): + retText = "\{" + retText += f"Title : {self.title}\r\n" + retText += f"URL : {self.url}\r\n" + retText += f"Series : {self.series}\r\n" + retText += f"Type : {self.type}\r\n" + retText += f"Filename : {self.filename}\r\n" + retText += f"Torrent : {self.torrent}\r\n" + retText += f"Language : {self.language}\r\n" + retText += f"Gallery ID : {self.gallery_id}\r\n" + retText += self.SaveToTextArtists() + f"\r\n" + retText += self.SavetToTextRelatedGalleryID() + f"\r\n" + retText += self.SavetToTextTags() + f"\r\n" + retText += "\}" + + def SaveToTextTagList(self, listTags): + RetText = "\{" + for tag in listTags: + RetText += (f"\"{tag.name}\" ") + + RetText += "\}" + + return RetText + + def SaveToTextArtists(self): + retText = f"Artists : " + retText += self.SaveToTextTagList(self.artists) + + return retText + + def SavetToTextRelatedGalleryID(self): + retText = f"Gallery_ID : " + retText += self.SaveToTextTagList(self.related_galID) + + return retText + + def SavetToTextTags(self): + retText = f"Tags : " + retText += self.SaveToTextTagList(self.tags) + + return retText def AddTag(self, name): self.tags.add(name) @@ -38,9 +80,9 @@ class TagInfo: self.url = url def __str__(self): - return f"{self.name} : {self.url}" + return f"#{self.name} : {self.url}" + - class ImageFileInfo: def __init__(self, name, height, width, hashValue, bWebp): self.name = name diff --git a/GetArc_Hitomi.py b/GetArc_Hitomi.py index 66d191d..8c3f3d2 100644 --- a/GetArc_Hitomi.py +++ b/GetArc_Hitomi.py @@ -60,8 +60,18 @@ def GetListSearchResult(list_ID): strContent = driver.page_source listRet = parseMangaInfos(strContent) - for Idx in range(len(listRet)): - print(f"{Idx} : {listRet[Idx]}") + #for Idx in range(len(listRet)): + # print(f"{Idx} : {listRet[Idx]}") + + try: + for Idx in range(len(listRet)): + print(f"{Idx} : {listRet[Idx]}") + with open( f"{id}.txt", 'w') as file: + for item in listRet[Idx]: + file.write( + "\n") + file.close() + except IOError: + util.DbgOut(f"Error: Could not write to the file at {id}.txt.", True) except Exception as e: util.DbgOut("Hitomi Loading Error : ", e) diff --git a/UI.py b/UI.py index 9a59878..da8fe4b 100644 --- a/UI.py +++ b/UI.py @@ -8,7 +8,7 @@ import GetArc_Hitomi as hitomi from io import BytesIO -from PyQt5.QtCore import Qt, QUrl, QSettings, QSize, QPoint, QByteArray +from PyQt5.QtCore import Qt, QUrl, QSettings, QSize, QPoint, QByteArray, QRect from PyQt5.QtWidgets import QApplication, QWidget, QMainWindow, QPushButton, QVBoxLayout, QLineEdit, QHBoxLayout, QListWidget, QListWidgetItem, QLabel, QFileDialog from PyQt5.QtGui import QPixmap, QKeyEvent @@ -21,16 +21,28 @@ class MyApp(QMainWindow): self.initUI() self.loadINI() - + # def closeEvent(self, event): self.saveINI() event.accept() - + # def resizeEvent(self, event): super().resizeEvent(event) - + rcDesktop = QApplication.primaryScreen().availableGeometry() + rcWnd = self.geometry() + if False == rcDesktop.contains(rcWnd): + self.setGeometry(rcDesktop) + + pixmap = self.label_Image.pixmap() + if None != pixmap: + pixmapScaled = pixmap.scaled(self.label_Image.size()) + self.label_Image.setPixmap(pixmapScaled) + + self.update() + + # def initUI(self): layout = self.MakeUI() @@ -108,10 +120,6 @@ class MyApp(QMainWindow): # show Image in middle Layout self.label_Image = QLabel(self) - # Load Default Image - pixmap = QPixmap("layoutImg.jpeg") - self.label_Image.setMaximumWidth(self.screen().size().width()-(self.list_ArcList.width()+400)) - layout_R = self.MakeUI_Right() # 레이아웃 설정 @@ -121,16 +129,8 @@ class MyApp(QMainWindow): layout.addLayout(layout_R, stretch = 1) return layout - - - def GetFitSize(self, szTarget): - szDesktop = self.screen().size() - szWindow = self.size() - - nTrgHeight = self.list_Items.height() - nTrgWidth = szWindow.width() - ( self.list_ArcList.width() + self.list_Items.width() ) - +# def on_click_SrcAdd(self): folder_path = QFileDialog.getExistingDirectory(self, '폴더 선택', '') @@ -272,6 +272,7 @@ class MyApp(QMainWindow): elif fileExt.lower() == ".rar": listContents = [] + elif True == os.path.isdir(pathTarget): listContents = util.ListFileExtRcr(pathTarget, [".jpg", ".jpeg", ".png", ".webp"]) @@ -301,8 +302,14 @@ class MyApp(QMainWindow): pixmap.load(selItemText) self.label_Image.setPixmap(pixmap) - scaled_pixmap = pixmap.scaled(self.label_Image.size(), Qt.KeepAspectRatio, Qt.SmoothTransformation) - self.label_Image.setPixmap(scaled_pixmap) + + # + def GetFitSize(self, szTarget): + szDesktop = self.screen().size() + szWindow = self.size() + + nTrgHeight = self.list_Items.height() + nTrgWidth = szWindow.width() - ( self.list_ArcList.width() + self.list_Items.width() ) if __name__ == '__main__': diff --git a/UtilPack.py b/UtilPack.py index 501b272..733e3ff 100644 --- a/UtilPack.py +++ b/UtilPack.py @@ -10,17 +10,14 @@ import subprocess from pathlib import Path - m_dbgLevel = 0 listDbgStr = [] - # def IsEmptyStr(string): temp = f"{string}" return 0 == len(temp.strip()) - # def GetCurrentTime(): # 현재 시간을 구하고 구조체로 변환 @@ -38,7 +35,6 @@ def GetCurrentTime(): return strRet - #for debug def DbgOut(strInput, bPrint = False): strMsg = (f"{GetCurrentTime()} : {strInput}") @@ -46,12 +42,21 @@ def DbgOut(strInput, bPrint = False): if True == bPrint: print(strMsg) - + +# def printDbgMessages(): for line in listDbgStr: print(line) - - + +# +def SaveDbgMessages(Path): + try: + with open(Path, 'w') as file: + for line in listDbgStr: + file.write(line + "\n") + except IOError: + DbgOut(f"Error: Could not write to the file at {Path}.", True) + # 입력된 경로의 자식 폴더를 찾아 반환한다. # 반환하는 리스트는 리커시브 - 손자, 증손자 폴더까지 전부 포함한다 def ListSubDirectories(root_dir): @@ -68,7 +73,6 @@ def ListSubDirectories(root_dir): return subdirectories - # 자식 폴더를 구해온다. 직계 자식만 def ListChildDirectories(pathDir): listRet = [] @@ -79,7 +83,6 @@ def ListChildDirectories(pathDir): return listRet - # 파일목록만 구해온다. 자식 폴더에 있는건 무시. def ListContainFiles(pathDir): listRet = [] @@ -90,7 +93,7 @@ def ListContainFiles(pathDir): return listRet - +# def ListFileExtRcr(pathTrg, listExt): listRet= [] @@ -107,8 +110,7 @@ def ListFileExtRcr(pathTrg, listExt): return listRet - -# 입력된 패스에서 부모 폴더를 찾는다. 0 은 자기자신 1은 부모, 숫자대로 위로. +# 입력된 경로에서 부모 폴더를 찾는다. 0 은 자기자신 1은 부모, 숫자대로 위로. def GetParentDirName(FullPath, nUp): parts = FullPath.split(os.sep) @@ -122,7 +124,6 @@ def GetParentDirName(FullPath, nUp): return parts[nTrgIdx] - # 입력된 경로가 자식 폴더를 가지고 있는지 판단한다.- 최종 폴더인지 여부 # 자식이 없으면 True, 자식이 있으면 False def IsFinalFolder(path): @@ -136,7 +137,6 @@ def IsFinalFolder(path): return bRet; - # 어떤 경로 안에서 특정 확장자의 파일을 뽑아내어 그 리스트를 반환한다. def FindFileFromExt(path, ext): bDot = False @@ -158,7 +158,6 @@ def FindFileFromExt(path, ext): return listRet - # 파일 이름에서 확장자를 뽑아낸다. True : '.' 을 포함한다. def GetExtStr(file_path, bDot = True): retStr = "" @@ -174,7 +173,6 @@ def GetExtStr(file_path, bDot = True): return retStr - # 문자열에 포함된 단어를 지운다. def RmvSubString(mainString, subString): # 문자열에서 부분 문자열의 인덱스를 찾습니다. @@ -187,12 +185,11 @@ def RmvSubString(mainString, subString): # 부분 문자열을 제거하고 새로운 문자열을 반환합니다. return mainString[:strIdx] + mainString[endIdx:] - +# def ExtractZIP(zip_file, extract_to): with zipfile.ZipFile(zip_file, 'r') as zf: zf.extractall(extract_to) - # def CreateZIP(output_zip, *files): with zipfile.ZipFile(output_zip, 'w') as zf: @@ -236,7 +233,6 @@ def CreateZIPShell(zipName, *files, bRmvRPath = True): return bRet - # 특정 확장자만 쉘을 이용해서 압축한다 def CreateZIPShExt(zipName, TrgExt): command = f"zip -j {zipName} *.{TrgExt}" @@ -249,7 +245,6 @@ def CreateZIPShExt(zipName, TrgExt): return bRet - # 압축 파일 내의 모든 파일 및 디렉토리 목록 가져오기 def GetZipContentList(path): if None == path or not os.path.isfile(path): @@ -261,7 +256,7 @@ def GetZipContentList(path): return listRet - +# def GetZippedFileByte(pathZip, FileName): if None == pathZip or not os.path.isfile(pathZip): return None @@ -275,7 +270,6 @@ def GetZippedFileByte(pathZip, FileName): retBytes = file.read() return retBytes - # JSON 을 트리 구조로 출력한다. def PrintJSONTree(data, indent=0): @@ -289,13 +283,12 @@ def PrintJSONTree(data, indent=0): else: print(' ' * indent + str(data)) - +# def IsPathWithin(base_path: str, target_path: str) -> bool: base = Path(base_path).resolve() target = Path(target_path).resolve() return target.is_relative_to(base) - # 랜덤 UUID 생성 def UUIDGenRandom(): random_uuid = uuid.uuid4() @@ -306,5 +299,6 @@ def UUIDGenName(SeedName): namespace_uuid = uuid.uuid5(uuid.NAMESPACE_DNS, SeedName) return namespace_uuid +# def GetTextInBrakets(text): return re.findall(r'\[(.*?)\]', text) \ No newline at end of file