update files, add issue templates,

This commit is contained in:
2025-05-18 19:06:04 +02:00
parent 5aece5c5db
commit 0d24c0a95c
5 changed files with 146 additions and 8 deletions

View File

@@ -1,8 +1,11 @@
from dataclasses import dataclass
from typing import List, Optional
import os
from omegaconf import OmegaConf
from omegaconf import DictConfig
from omegaconf import OmegaConf, DictConfig
from pathlib import Path
from komconfig import CONFIG_PATH
SETTINGS_PATH = os.path.join(CONFIG_PATH, "config.yaml")
@dataclass
@@ -14,6 +17,7 @@ class Komga:
password: str
media_path: str
api_key: str = None
libraries: dict[str, str] = None
def getattr(self, name):
return getattr(self, name)
@@ -58,20 +62,93 @@ class Aria2:
@dataclass
class KomGrabber:
"""KomGrabber settings."""
class EbookSettings:
min_filesize: int
max_filesize: int
data_directory: str
skip_parameters: List[str]
valid_file_extensions: List[str]
download_location: str
def __post_init__(self):
self.skip_parameters = [
param.lower() for param in self.skip_parameters if param is not None
]
def getattr(self, name):
return getattr(self, name)
def _setattr(self, name, value):
setattr(self, name, value)
@dataclass
class ComicSettings:
min_filesize: int
max_filesize: int
data_directory: str
valid_file_extensions: List[str]
skip_parameters: List[str]
def __post_init__(self):
self.skip_parameters = [
param.lower() for param in self.skip_parameters if param is not None
]
def getattr(self, name):
return getattr(self, name)
def _setattr(self, name, value):
setattr(self, name, value)
@dataclass
class KomGrabber:
"""
Configs used by the KomGrabber.
Attributes
----------
download_location : str | Path
The location to download the files to.
get_chapters : bool
Whether to get chapters or not.
skip_parameters : List[str]
A list of parameters to skip.
aria2 : Aria2
The aria2 settings. see Aria2 class.
tag_interactive : bool
Whether to use interactive tagging or not.
ebook : EbookSettings
The ebook settings. see EbookSettings class.
manga : ComicSettings
The manga settings. see ComicSettings class.
check_interval : int
The interval to check for new files.
use_cache : bool
Whether to use cache or not.
cache_check_interval : int
The days an entry will not be checked based on the last change in the cache.
"""
download_location: Path
get_chapters: bool
skip_parameters: List[str]
aria2: Aria2
tag_interactive: bool
min_filesize: int
ebook: EbookSettings
manga: ComicSettings
check_interval: int
use_cache: bool
cache_check_interval: int
def __post_init__(self):
self.skip_parameters = [param.lower() for param in self.skip_parameters]
if "~" in self.download_location:
self.download_location = os.path.expanduser(self.download_location)
if isinstance(self.download_location, str):
self.download_location = Path(self.download_location)
def getattr(self, name):
return getattr(self, name)
@@ -186,7 +263,7 @@ class Settings:
_config: Optional[DictConfig] = None
def __init__(self, config_path: str = "~/.config/KomSuite/config.yaml"):
def __init__(self, config_path: str = SETTINGS_PATH):
"""
Loads the configuration file and stores it for future access.
@@ -196,7 +273,9 @@ class Settings:
Raises:
FileNotFoundError: Configuration file not found
"""
if not os.path.exists(os.path.expanduser(config_path)):
if "~" in config_path:
config_path = os.path.expanduser(config_path)
if not os.path.exists(config_path):
raise FileNotFoundError(f"Configuration file not found: {config_path}")
self._config = OmegaConf.load(os.path.expanduser(config_path))
self.config_path = config_path