fix(tags): prevent metadata lookup failures from skipping group tag

Wrapped metadata provider lookup in try/except so custom tags (Group) are always applied even when IMDB/TMDB lookups fail. Also log mkvpropedit errors instead of silently discarding them.
This commit is contained in:
imSp4rky
2026-04-12 22:21:02 +00:00
parent 2e7fc1720d
commit 4179b9045e

View File

@@ -33,12 +33,15 @@ def apply_tags(path: Path, tags: dict[str, str]) -> None:
f.write("\n".join(xml_lines))
tmp_path = Path(f.name)
try:
subprocess.run(
result = subprocess.run(
[str(binaries.Mkvpropedit), str(path), "--tags", f"global:{tmp_path}"],
check=False,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
capture_output=True,
text=True,
)
if result.returncode != 0:
log.warning("mkvpropedit failed (exit %d): %s", result.returncode, result.stderr.strip())
else:
log.debug("Tags applied via mkvpropedit")
finally:
tmp_path.unlink(missing_ok=True)
@@ -92,6 +95,7 @@ def tag_file(
standard_tags: dict[str, str] = {}
if config.tag_imdb_tmdb:
try:
providers = get_available_providers()
if not providers:
log.debug("No metadata providers available; skipping tag lookup")
@@ -129,6 +133,8 @@ def tag_file(
if result and result.external_ids:
standard_tags = _build_tags_from_ids(result.external_ids, kind)
except Exception as e:
log.warning("Metadata lookup failed, applying custom tags only: %s", e)
apply_tags(path, {**custom_tags, **standard_tags})