2024-04-24 16:59:33 +00:00
|
|
|
from typing import Dict
|
|
|
|
|
2023-02-17 06:02:21 +00:00
|
|
|
from core.config import CoreConfig
|
|
|
|
|
2023-03-09 16:38:58 +00:00
|
|
|
|
|
|
|
class Mai2ServerConfig:
|
2023-02-17 06:02:21 +00:00
|
|
|
def __init__(self, parent: "Mai2Config") -> None:
|
|
|
|
self.__config = parent
|
|
|
|
|
|
|
|
@property
|
|
|
|
def enable(self) -> bool:
|
2023-03-09 16:38:58 +00:00
|
|
|
return CoreConfig.get_config_field(
|
|
|
|
self.__config, "mai2", "server", "enable", default=True
|
|
|
|
)
|
|
|
|
|
2023-02-17 06:02:21 +00:00
|
|
|
@property
|
|
|
|
def loglevel(self) -> int:
|
2023-03-09 16:38:58 +00:00
|
|
|
return CoreConfig.str_to_loglevel(
|
|
|
|
CoreConfig.get_config_field(
|
|
|
|
self.__config, "mai2", "server", "loglevel", default="info"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
2023-05-10 06:31:30 +00:00
|
|
|
class Mai2DeliverConfig:
|
|
|
|
def __init__(self, parent: "Mai2Config") -> None:
|
|
|
|
self.__config = parent
|
|
|
|
|
|
|
|
@property
|
|
|
|
def enable(self) -> bool:
|
|
|
|
return CoreConfig.get_config_field(
|
|
|
|
self.__config, "mai2", "deliver", "enable", default=False
|
|
|
|
)
|
|
|
|
|
|
|
|
@property
|
|
|
|
def udbdl_enable(self) -> bool:
|
|
|
|
return CoreConfig.get_config_field(
|
|
|
|
self.__config, "mai2", "deliver", "udbdl_enable", default=False
|
|
|
|
)
|
|
|
|
|
|
|
|
@property
|
2023-05-13 02:05:05 +00:00
|
|
|
def content_folder(self) -> int:
|
2023-05-10 06:31:30 +00:00
|
|
|
return CoreConfig.get_config_field(
|
2023-08-31 05:24:41 +00:00
|
|
|
self.__config, "mai2", "deliver", "content_folder", default=""
|
2023-05-10 06:31:30 +00:00
|
|
|
)
|
|
|
|
|
2023-06-25 23:10:34 +00:00
|
|
|
class Mai2UploadsConfig:
|
|
|
|
def __init__(self, parent: "Mai2Config") -> None:
|
|
|
|
self.__config = parent
|
|
|
|
|
|
|
|
@property
|
|
|
|
def photos(self) -> bool:
|
|
|
|
return CoreConfig.get_config_field(
|
|
|
|
self.__config, "mai2", "uploads", "photos", default=False
|
|
|
|
)
|
|
|
|
|
|
|
|
@property
|
|
|
|
def photos_dir(self) -> str:
|
|
|
|
return CoreConfig.get_config_field(
|
|
|
|
self.__config, "mai2", "uploads", "photos_dir", default=""
|
|
|
|
)
|
|
|
|
|
|
|
|
@property
|
|
|
|
def movies(self) -> bool:
|
|
|
|
return CoreConfig.get_config_field(
|
|
|
|
self.__config, "mai2", "uploads", "movies", default=False
|
|
|
|
)
|
|
|
|
|
|
|
|
@property
|
|
|
|
def movies_dir(self) -> str:
|
|
|
|
return CoreConfig.get_config_field(
|
|
|
|
self.__config, "mai2", "uploads", "movies_dir", default=""
|
|
|
|
)
|
|
|
|
|
2023-02-17 06:02:21 +00:00
|
|
|
|
2024-04-24 16:59:33 +00:00
|
|
|
class Mai2CryptoConfig:
|
|
|
|
def __init__(self, parent_config: "Mai2Config") -> None:
|
|
|
|
self.__config = parent_config
|
|
|
|
|
|
|
|
@property
|
|
|
|
def keys(self) -> Dict[int, list[str]]:
|
|
|
|
"""
|
|
|
|
in the form of:
|
|
|
|
internal_version: [key, iv, salt]
|
|
|
|
key and iv are hex strings
|
|
|
|
salt is a normal UTF-8 string
|
|
|
|
"""
|
|
|
|
return CoreConfig.get_config_field(
|
|
|
|
self.__config, "mai2", "crypto", "keys", default={}
|
|
|
|
)
|
|
|
|
|
|
|
|
@property
|
|
|
|
def encrypted_only(self) -> bool:
|
|
|
|
return CoreConfig.get_config_field(
|
|
|
|
self.__config, "mai2", "crypto", "encrypted_only", default=False
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2023-02-17 06:02:21 +00:00
|
|
|
class Mai2Config(dict):
|
|
|
|
def __init__(self) -> None:
|
2023-03-09 16:38:58 +00:00
|
|
|
self.server = Mai2ServerConfig(self)
|
2023-05-10 06:31:30 +00:00
|
|
|
self.deliver = Mai2DeliverConfig(self)
|
2023-06-25 23:10:34 +00:00
|
|
|
self.uploads = Mai2UploadsConfig(self)
|
2024-04-24 16:59:33 +00:00
|
|
|
self.crypto = Mai2CryptoConfig(self)
|