feat: support male chara

This commit is contained in:
RedDeadDepresso
2024-10-06 23:43:33 +01:00
parent 097d9c77ba
commit d078a93deb
6 changed files with 80 additions and 51 deletions

32
util/classifier.py Normal file
View File

@@ -0,0 +1,32 @@
from enum import Enum
from pathlib import Path
from typing import Union
class CardType(Enum):
UNKNOWN = "UNKNOWN"
KK = "KK"
KKSP = "KKSP"
KKS = "KKS"
def get_card_type(card: Union[str, Path, bytes]):
if isinstance(card, (str, Path)):
card = Path(card).read_bytes()
card_type = CardType.UNKNOWN
if b"KoiKatuChara" in card:
card_type = CardType.KK
if b"KoiKatuCharaSP" in card:
card_type = CardType.KKSP
elif b"KoiKatuCharaSun" in card:
card_type = CardType.KKS
return card_type
def is_male(image_bytes: bytes):
return b'sex\x00' in image_bytes
def is_coordinate(image_bytes: bytes):
return 'b"KoiKatuClothes"' in image_bytes