chore: snapshot current project updates
This commit is contained in:
+30
-2
@@ -49,6 +49,9 @@ class Config:
|
||||
|
||||
# Plan settings (e.g. duplicate handling when consuming analysis)
|
||||
duplicate_keep: str = "by_reputation"
|
||||
plan_max_season: int = 15
|
||||
plan_max_episode: int = 100
|
||||
plan_include_sample_files: bool = False
|
||||
|
||||
|
||||
def load_config(path: Path) -> Config:
|
||||
@@ -91,6 +94,9 @@ def load_config(path: Path) -> Config:
|
||||
|
||||
plan = data.get("plan", {})
|
||||
duplicate_keep = plan.get("duplicate_keep", "by_reputation")
|
||||
plan_max_season = int(plan.get("max_season", 15))
|
||||
plan_max_episode = int(plan.get("max_episode", 100))
|
||||
plan_include_sample_files = bool(plan.get("include_sample_files", False))
|
||||
|
||||
enrichment = data.get("enrichment")
|
||||
if enrichment is None:
|
||||
@@ -133,6 +139,9 @@ def load_config(path: Path) -> Config:
|
||||
reputation_policy=reputation.get("policy", "flag_for_review"),
|
||||
naming_title_format=naming.get("title_format", "{title_zh} {title_en}"),
|
||||
duplicate_keep=duplicate_keep,
|
||||
plan_max_season=plan_max_season,
|
||||
plan_max_episode=plan_max_episode,
|
||||
plan_include_sample_files=plan_include_sample_files,
|
||||
)
|
||||
|
||||
|
||||
@@ -175,7 +184,12 @@ def create_default_config(path: Path) -> Config:
|
||||
},
|
||||
}
|
||||
|
||||
plan_content = {"duplicate_keep": default_config.duplicate_keep}
|
||||
plan_content = {
|
||||
"duplicate_keep": default_config.duplicate_keep,
|
||||
"max_season": default_config.plan_max_season,
|
||||
"max_episode": default_config.plan_max_episode,
|
||||
"include_sample_files": default_config.plan_include_sample_files,
|
||||
}
|
||||
|
||||
yaml_content = {
|
||||
"library_root": str(default_config.library_root),
|
||||
@@ -244,6 +258,11 @@ def validate_config(config: Config) -> list[str]:
|
||||
elif not isinstance(config.series_filename_template, str):
|
||||
errors.append("series_filename_template must be a string")
|
||||
|
||||
if not isinstance(config.enrichment_max_concurrency, int):
|
||||
errors.append("enrichment_max_concurrency must be an integer")
|
||||
elif config.enrichment_max_concurrency < 1:
|
||||
errors.append("enrichment_max_concurrency must be >= 1")
|
||||
|
||||
valid_log_levels = ["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"]
|
||||
if not config.log_level:
|
||||
errors.append("log_level cannot be empty")
|
||||
@@ -326,12 +345,21 @@ def validate_config(config: Config) -> list[str]:
|
||||
errors.append("tmdb_include_adult must be a boolean")
|
||||
if config.duplicate_keep not in (
|
||||
"by_reputation",
|
||||
"by_reputation_quality_time",
|
||||
"first_seen",
|
||||
"manual",
|
||||
"by_quality",
|
||||
):
|
||||
errors.append(
|
||||
f"duplicate_keep must be one of 'by_reputation', 'first_seen', 'manual', 'by_quality', got: {config.duplicate_keep!r}"
|
||||
"duplicate_keep must be one of "
|
||||
"'by_reputation', 'by_reputation_quality_time', 'first_seen', 'manual', 'by_quality', "
|
||||
f"got: {config.duplicate_keep!r}"
|
||||
)
|
||||
if not isinstance(config.plan_max_season, int) or config.plan_max_season < 1:
|
||||
errors.append("plan_max_season must be an integer >= 1")
|
||||
if not isinstance(config.plan_max_episode, int) or config.plan_max_episode < 1:
|
||||
errors.append("plan_max_episode must be an integer >= 1")
|
||||
if not isinstance(config.plan_include_sample_files, bool):
|
||||
errors.append("plan_include_sample_files must be a boolean")
|
||||
|
||||
return errors
|
||||
|
||||
Reference in New Issue
Block a user