refactor enrichment to tmdb-only and fix review findings
This commit is contained in:
+9
-8
@@ -30,15 +30,13 @@ class Config:
|
||||
enrichment_enabled: bool = True
|
||||
enrichment_incremental: bool = True
|
||||
enrichment_refresh_mode: str = "manual"
|
||||
enrichment_providers: list[str] = field(default_factory=lambda: ["tmdb", "douban"])
|
||||
enrichment_providers: list[str] = field(default_factory=lambda: ["tmdb"])
|
||||
enrichment_cache_db: Path = field(default_factory=lambda: Path.home() / ".vlm" / "enrichment_cache.db")
|
||||
enrichment_max_concurrency: int = 6
|
||||
enrichment_min_match_score: float = 0.75
|
||||
translation_mode: str = "bidirectional"
|
||||
translation_fallback_machine: bool = True
|
||||
tmdb_api_key: Optional[str] = None
|
||||
douban_api_key: Optional[str] = None
|
||||
douban_api_endpoint: Optional[str] = None
|
||||
openai_api_key: Optional[str] = None
|
||||
reputation_min_votes: int = 50
|
||||
reputation_low_score_threshold: float = 6.0
|
||||
@@ -103,7 +101,7 @@ def load_config(path: Path) -> Config:
|
||||
enrichment_enabled=enrichment.get("enabled", True),
|
||||
enrichment_incremental=enrichment.get("incremental", True),
|
||||
enrichment_refresh_mode=enrichment.get("refresh_mode", "manual"),
|
||||
enrichment_providers=enrichment.get("providers", ["tmdb", "douban"]),
|
||||
enrichment_providers=enrichment.get("providers", ["tmdb"]),
|
||||
enrichment_cache_db=Path(
|
||||
enrichment.get("cache_db", str(Path.home() / ".vlm" / "enrichment_cache.db"))
|
||||
).expanduser(),
|
||||
@@ -112,8 +110,6 @@ def load_config(path: Path) -> Config:
|
||||
translation_mode=translation.get("mode", "bidirectional"),
|
||||
translation_fallback_machine=translation.get("fallback_machine", True),
|
||||
tmdb_api_key=api_keys.get("tmdb"),
|
||||
douban_api_key=api_keys.get("douban"),
|
||||
douban_api_endpoint=enrichment.get("douban_endpoint"),
|
||||
openai_api_key=api_keys.get("openai"),
|
||||
reputation_min_votes=reputation.get("min_votes", 50),
|
||||
reputation_low_score_threshold=reputation.get("low_score_threshold", 6.0),
|
||||
@@ -155,10 +151,8 @@ def create_default_config(path: Path) -> Config:
|
||||
},
|
||||
"api_keys": {
|
||||
"tmdb": default_config.tmdb_api_key,
|
||||
"douban": default_config.douban_api_key,
|
||||
"openai": default_config.openai_api_key,
|
||||
},
|
||||
"douban_endpoint": default_config.douban_api_endpoint,
|
||||
"reputation": {
|
||||
"min_votes": default_config.reputation_min_votes,
|
||||
"low_score_threshold": default_config.reputation_low_score_threshold,
|
||||
@@ -276,6 +270,13 @@ def validate_config(config: Config) -> list[str]:
|
||||
errors.append("enrichment_cache_db must be a Path object")
|
||||
if not isinstance(config.enrichment_providers, list) or not config.enrichment_providers:
|
||||
errors.append("enrichment_providers must be a non-empty list")
|
||||
else:
|
||||
allowed_providers = {"tmdb"}
|
||||
invalid = [provider for provider in config.enrichment_providers if provider.lower() not in allowed_providers]
|
||||
if invalid:
|
||||
errors.append(
|
||||
f"enrichment_providers contains unsupported providers: {invalid}; supported providers: ['tmdb']"
|
||||
)
|
||||
if config.enrichment_max_concurrency < 1:
|
||||
errors.append("enrichment_max_concurrency must be >= 1")
|
||||
if not (0.0 <= config.enrichment_min_match_score <= 1.0):
|
||||
|
||||
Reference in New Issue
Block a user