45 lines
1.3 KiB
Python
45 lines
1.3 KiB
Python
## Filse used to store generic objects
|
|
from dataclasses import dataclass
|
|
from Tools import fix_url
|
|
|
|
|
|
class OjectTypeNotSupported(Exception):
|
|
"""
|
|
Raised when the object given it's not supported
|
|
"""
|
|
|
|
@dataclass
|
|
class ENTRY:
|
|
"""
|
|
album_id used when consulting the database
|
|
source_id used when consulting the database
|
|
name of the album
|
|
url of the album
|
|
available used when checking if sources from database still available
|
|
# file_list: list of urls from the files to download ?? idk if
|
|
"""
|
|
name: str = None
|
|
url: str = None
|
|
source: str = None
|
|
date_added: str = None
|
|
release_date: str = None
|
|
available: bool = False
|
|
|
|
def __post_init__(self):
|
|
# print(type(self.url))
|
|
# print(self.url)
|
|
self.name = " ".join(str(self.name).split())
|
|
self.url = fix_url(self.url)
|
|
self.source = str(self.source)
|
|
self.available = bool(self.available)
|
|
if self.date_added: self.date_added = str(self.date_added) # Eventually change to date object
|
|
if self.release_date: self.release_date = str(self.release_date)
|
|
|
|
@dataclass
|
|
class ALBUM(ENTRY):
|
|
number_of_tracks: int = None
|
|
|
|
def __post_init__(self):
|
|
super().__post_init__()
|
|
if self.number_of_tracks: self.number_of_tracks = int(self.number_of_tracks)
|