65 lines
2.2 KiB
Python
65 lines
2.2 KiB
Python
from __future__ import annotations
|
|
|
|
from typing import List, Optional, Union
|
|
from dataclasses import dataclass
|
|
|
|
from .AlternateTitle import AlternateTitle
|
|
from .Link import Link
|
|
from .status import Status
|
|
|
|
|
|
@dataclass
|
|
class Metadata:
|
|
# set status to be either ENDED, ONGOING, HIATUS, ABANDONED
|
|
# status has to be one of the status listed in enum status
|
|
status: Optional[Status] | None = None
|
|
|
|
statusLock: bool = None
|
|
title: Optional[str] | None = None
|
|
titleLock: bool = None
|
|
titleSort: Optional[str] | None = None
|
|
titleSortLock: bool = None
|
|
summary: Optional[str] | None = None
|
|
summaryLock: bool = None
|
|
readingDirection: Optional[str] | None = None
|
|
readingDirectionLock: bool = None
|
|
publisher: Optional[str] | None = None
|
|
publisherLock: bool = None
|
|
ageRating: Optional[int] | None = None
|
|
ageRatingLock: bool = None
|
|
language: Optional[str] | None = None
|
|
languageLock: bool = None
|
|
genres: List[str] | None = None
|
|
genresLock: bool = None
|
|
tags: List[str] | None = None
|
|
tagsLock: bool = None
|
|
totalBookCount: Optional[int] | None = None
|
|
totalBookCountLock: bool = None
|
|
sharingLabels: List[str | None] = None
|
|
sharingLabelsLock: bool = None
|
|
links: List[Link] | None = None
|
|
linksLock: bool = None
|
|
alternateTitles: List[AlternateTitle] | None = None
|
|
alternateTitlesLock: bool = None
|
|
created: Optional[str] | None = None
|
|
lastModified: Optional[str] | None = None
|
|
|
|
|
|
|
|
@property
|
|
def print(self)->dict[str, Optional[Union[str, int, bool, List[str], List[str], List[str]]]]:
|
|
return {
|
|
"status": self.status,
|
|
"title": self.title,
|
|
"titleSort": self.titleSort,
|
|
"summary": self.summary,
|
|
"publisher": self.publisher,
|
|
"ageRating": self.ageRating,
|
|
"language": self.language,
|
|
"genres": ", ".join(self.genres) if self.genres else None,
|
|
"tags": ", ".join(self.tags) if self.tags else None,
|
|
"totalBookCount": self.totalBookCount,
|
|
"links": [link["url"] for link in self.links] if self.links else None,
|
|
"alternateTitles": [alternate["title"] for alternate in self.alternateTitles] if self.alternateTitles else None,
|
|
}
|