코드 리뷰, .lownload 파일 작성 함수 추가
This commit is contained in:
+1
-1
@@ -170,7 +170,7 @@ class PupilData:
|
|||||||
|
|
||||||
# pupil 의 JSON 을 파싱해서 ImageFileList 를 반환한다.
|
# pupil 의 JSON 을 파싱해서 ImageFileList 를 반환한다.
|
||||||
def GetImgFileList(self) -> list[info.ImageFileInfo]:
|
def GetImgFileList(self) -> list[info.ImageFileInfo]:
|
||||||
listRet = set(info.ImageFileInfo)
|
listRet = list[info.ImageFileInfo]()
|
||||||
|
|
||||||
if None != self.m_data:
|
if None != self.m_data:
|
||||||
listFiles = self.m_data[GALINFO]["files"]
|
listFiles = self.m_data[GALINFO]["files"]
|
||||||
|
|||||||
+15
-13
@@ -81,17 +81,18 @@ class GetArc_Hitomi:
|
|||||||
strContent = driver.page_source
|
strContent = driver.page_source
|
||||||
listRet = self.parseMangaInfos(strContent)
|
listRet = self.parseMangaInfos(strContent)
|
||||||
|
|
||||||
#for Idx in range(len(listRet)):
|
|
||||||
# print(f"{Idx} : {listRet[Idx]}")
|
|
||||||
|
|
||||||
try:
|
|
||||||
for Idx in range(len(listRet)):
|
for Idx in range(len(listRet)):
|
||||||
print(f"{Idx} : {listRet[Idx]}")
|
util.DbgOut(f"{Idx} : {listRet[Idx]}", True)
|
||||||
with open( f"{id}.txt", 'w') as file:
|
|
||||||
for item in listRet[Idx]:
|
if True == bSave and 0 < len(listRet):
|
||||||
file.write( + "\n")
|
strFileName = f"{nID}.txt"
|
||||||
|
try:
|
||||||
|
with open(strFileName, 'w', encoding="utf-8") as file:
|
||||||
|
for item in listRet:
|
||||||
|
file.write(f"{item}\n")
|
||||||
|
util.DbgOut(f"Saved to {strFileName}", True)
|
||||||
except IOError:
|
except IOError:
|
||||||
util.DbgOut(f"Error: Could not write to the file at {id}.txt.", True)
|
util.DbgOut(f"Error: Could not write to the file at {strFileName}.", True)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
util.DbgOut(f"Hitomi Loading Error : {e}", True)
|
util.DbgOut(f"Hitomi Loading Error : {e}", True)
|
||||||
@@ -182,11 +183,12 @@ class GetArc_Hitomi:
|
|||||||
#util.DbgOut(outMsg)
|
#util.DbgOut(outMsg)
|
||||||
|
|
||||||
#
|
#
|
||||||
if "Series" == tds[0]:
|
strLabel = tds[0].text.strip()
|
||||||
retPtr.serires = listTags[-1].name
|
if "Series" == strLabel:
|
||||||
elif "Type" == tds[0]:
|
retPtr.series = listTags[-1].name
|
||||||
|
elif "Type" == strLabel:
|
||||||
retPtr.type = listTags[-1].name
|
retPtr.type = listTags[-1].name
|
||||||
elif "Language" == tds[0]:
|
elif "Language" == strLabel:
|
||||||
retPtr.language = listTags[-1].name
|
retPtr.language = listTags[-1].name
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
|
|||||||
+35
-1
@@ -1,5 +1,6 @@
|
|||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
import json
|
||||||
import shutil
|
import shutil
|
||||||
import UtilPack as util
|
import UtilPack as util
|
||||||
import DataClass_Pupil as pupil
|
import DataClass_Pupil as pupil
|
||||||
@@ -580,7 +581,40 @@ class MyApp(QMainWindow):
|
|||||||
|
|
||||||
#
|
#
|
||||||
def on_btn_MakeDownList_clicked(self):
|
def on_btn_MakeDownList_clicked(self):
|
||||||
pass
|
itemCount = self.tableWidget_Src.rowCount()
|
||||||
|
if itemCount <= 0:
|
||||||
|
util.DbgOut("파싱된 만화가 없습니다.", True)
|
||||||
|
return
|
||||||
|
|
||||||
|
pathSave = QFileDialog.getSaveFileName(self, '다운로드 리스트 저장', 'download.json', 'JSON Files (*.json)')[0]
|
||||||
|
if util.IsEmptyStr(pathSave):
|
||||||
|
return
|
||||||
|
|
||||||
|
dictDownload: dict[str, str] = {}
|
||||||
|
for idx in range(itemCount):
|
||||||
|
itemID = self.tableWidget_Src.item(idx, 2)
|
||||||
|
itemTitle = self.tableWidget_Src.item(idx, 1)
|
||||||
|
if itemID is None or itemTitle is None:
|
||||||
|
continue
|
||||||
|
|
||||||
|
strID = itemID.text()
|
||||||
|
strTitle = itemTitle.text()
|
||||||
|
if util.IsEmptyStr(strID) or util.IsEmptyStr(strTitle):
|
||||||
|
continue
|
||||||
|
|
||||||
|
dictDownload[strID] = f"[{strID}] {strTitle}"
|
||||||
|
|
||||||
|
if 0 >= len(dictDownload):
|
||||||
|
util.DbgOut("작성할 다운로드 리스트 항목이 없습니다.", True)
|
||||||
|
return
|
||||||
|
|
||||||
|
try:
|
||||||
|
with open(pathSave, "w", encoding="utf-8") as file:
|
||||||
|
json.dump(dictDownload, file, ensure_ascii=False, indent=2)
|
||||||
|
util.DbgOut(f"다운로드 리스트 저장 완료: {pathSave}", True)
|
||||||
|
except Exception as e:
|
||||||
|
util.DbgOut(f"다운로드 리스트 저장 중 오류 발생: {e}", True)
|
||||||
|
QMessageBox.critical(self, "Error", str(e))
|
||||||
|
|
||||||
"""
|
"""
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
Reference in New Issue
Block a user