오랜만에 서버 정리하고 커밋. 파일 위치를 정리했다. 캘리버 DB 를 열고 정보를 열람. Pupil 을 통해 다운받은 정보를 관리하기 위해 새로운 클래스 추가
102 lines
2.8 KiB
Python
102 lines
2.8 KiB
Python
from typing import Set
|
|
import UtilPack as util
|
|
|
|
class TagInfo:
|
|
def __init__(self, name: str, url: str):
|
|
self.name = name
|
|
self.url = url
|
|
|
|
def __str__(self):
|
|
return f"#{self.name} : {self.url}"
|
|
|
|
|
|
class ImageFileInfo:
|
|
def __init__(self, path: str, height: int, width: int, hashValue: str, bWebp: bool):
|
|
self.path = path
|
|
self.height = height
|
|
self.width = width
|
|
self.hashValue = hashValue
|
|
self.bWebp = bWebp
|
|
|
|
def CehckHash(self) -> bool:
|
|
return util.VerifyIsValidFile(self.path, self.hashValue)
|
|
|
|
|
|
class CBZInfo:
|
|
def __init__(self, title: str, url: str):
|
|
self.title = title
|
|
self.url = url
|
|
self.series = ""
|
|
self.type = ""
|
|
self.Arcfilename = ""
|
|
self.torrent = ""
|
|
self.language = ""
|
|
self.gallery_id = 0
|
|
# 중복을 허용하지 않는 집합으로 초기화
|
|
self.related_galID = set[str]()
|
|
self.artists = set[str]()
|
|
self.tags = set[str]()
|
|
self.files = list[ImageFileInfo]()
|
|
|
|
def __str__(self):
|
|
strArtists = ", ".join(self.artists)
|
|
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.Arcfilename}\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.ArtistsSaveToText() + f"\r\n"
|
|
retText += self.RelatedGalleryIDsSaveToText() + f"\r\n"
|
|
retText += self.TagsSaveToText() + f"\r\n"
|
|
retText += "}"
|
|
|
|
def TagListSaveToText(self, setTags: Set[str])-> str:
|
|
RetText = "{"
|
|
for tag in setTags:
|
|
RetText += (f"\"{tag}\" ")
|
|
|
|
RetText += "}"
|
|
|
|
return RetText
|
|
|
|
def ArtistsSaveToText(self)-> str:
|
|
retText = f"Artists : "
|
|
retText += self.TagListSaveToText(self.artists)
|
|
|
|
return retText
|
|
|
|
def RelatedGalleryIDsSaveToText(self)-> str:
|
|
retText = f"Gallery_ID : "
|
|
retText += self.TagListSaveToText(self.related_galID)
|
|
|
|
return retText
|
|
|
|
def TagsSaveToText(self)-> str:
|
|
retText = f"Tags : "
|
|
retText += self.TagListSaveToText(self.tags)
|
|
|
|
return retText
|
|
|
|
def AddTag(self, strTag: str):
|
|
self.tags.add(strTag)
|
|
|
|
def RmvTag(self, strTag: str):
|
|
self.tags.discard(strTag)
|
|
|
|
def AddArtist(self, strName: str):
|
|
self.artists.add(strName)
|
|
|
|
def RmvArtist(self, strName: str):
|
|
self.artists.discard(strName)
|
|
|
|
|
|
|