feat(metadata)!: authoritative id resolver and keyless imdb provider

Supplied IDs resolve directly via a shared resolve_by_ids and never fall back to title search; metadata_providers gains per-kind ordering and a disable_metadata switch stops all automatic lookups while explicit IDs keep working.
BREAKING: --tmdb/--imdb/--tvdb are now mutually exclusive and require a usable provider; --enrich also overwrites original language; the imdbapi provider and imdb_api_enabled are replaced by a keyless imdb provider.
This commit is contained in:
imSp4rky
2026-08-11 15:07:24 -06:00
parent 0cec6c9686
commit ebb4e74318
22 changed files with 1035 additions and 293 deletions
+4 -48
View File
@@ -12,13 +12,9 @@ from unshackle.core import binaries
from unshackle.core.config import config
from unshackle.core.providers import (
ExternalIds,
MetadataResult,
enrich_ids,
fetch_external_ids,
fuzzy_match,
get_available_providers,
get_provider,
search_metadata,
resolve_by_ids,
)
from unshackle.core.titles.episode import Episode
from unshackle.core.titles.movie import Movie
@@ -118,53 +114,13 @@ def tag_file(
if config.tag_imdb_tmdb:
try:
providers = get_available_providers()
if not providers and tvdb_id is None:
has_ids = tmdb_id is not None or imdb_id is not None or tvdb_id is not None
if not get_available_providers() and not has_ids:
log.debug("No metadata providers available; skipping tag lookup")
apply_tags(path, custom_tags)
return
result: Optional[MetadataResult] = None
# Direct ID lookup path
if imdb_id:
imdbapi = get_provider("imdbapi")
if imdbapi:
result = imdbapi.get_by_id(imdb_id, kind)
if not result:
# IMDxAPI is off or had no answer; the ID alone still resolves the others
result = MetadataResult(title=name, year=year, kind=kind)
result.external_ids.imdb_id = imdb_id
enrich_ids(result)
elif tmdb_id is not None:
tmdb = get_provider("tmdb")
if tmdb:
result = tmdb.get_by_id(tmdb_id, kind)
if result:
ext = tmdb.get_external_ids(tmdb_id, kind)
result.external_ids = ext
enrich_ids(result)
else:
# Search across providers in priority order
result = search_metadata(name, year, kind)
# If we got a TMDB ID from search but not the other IDs, fetch them
if (
result
and result.external_ids.tmdb_id
and not (result.external_ids.imdb_id and result.external_ids.tvdb_id)
):
ext = fetch_external_ids(result.external_ids.tmdb_id, kind)
if ext.imdb_id and not result.external_ids.imdb_id:
result.external_ids.imdb_id = ext.imdb_id
if ext.tvdb_id and not result.external_ids.tvdb_id:
result.external_ids.tvdb_id = ext.tvdb_id
enrich_ids(result)
if tvdb_id is not None:
if result is None:
result = MetadataResult(kind=kind)
result.external_ids.tvdb_id = tvdb_id
result = resolve_by_ids(tmdb_id, imdb_id, tvdb_id, title=name, year=year, kind=kind)
if result and result.external_ids:
standard_tags = _build_tags_from_ids(result.external_ids, kind)