This commit is contained in:
2026-01-31 19:00:04 -08:00
parent dcf16e0cc4
commit 6513a3ad04
25 changed files with 617 additions and 397 deletions

View File

@@ -4,6 +4,10 @@ import subprocess
import sys
import shutil
from SYS.logger import log, debug
import logging
logger = logging.getLogger(__name__)
from pathlib import Path
from typing import Any, Dict, Iterable, List, Optional, Sequence, Set, Tuple
@@ -651,7 +655,7 @@ def write_tags(
)
sidecar = media_path.parent / f"{fallback_base}.tag"
except Exception:
pass
logger.exception("Failed to determine fallback .tag sidecar base for %s", media_path)
# Write via consolidated function
try:
@@ -1258,15 +1262,16 @@ def embed_metadata_in_file(
stderr_text = result.stderr.decode("utf-8", errors="replace")[:200]
debug(f"FFmpeg stderr: {stderr_text}", file=sys.stderr)
except Exception:
pass
logger.exception("Failed to decode FFmpeg stderr for %s", file_path)
return False
except Exception as exc:
if temp_file.exists():
try:
temp_file.unlink()
except Exception:
pass
logger.exception("Failed to remove FFmpeg temp file %s after error", temp_file)
debug(f"❌ Error embedding metadata: {exc}", file=sys.stderr)
logger.exception("Error embedding metadata into %s", file_path)
return False
@@ -2236,7 +2241,7 @@ def enrich_playlist_entries(entries: list, extractor: str) -> list:
enriched.append(full_info)
continue
except Exception:
pass
logger.exception("Failed to fetch full metadata for entry URL: %s", entry_url)
# Fallback to original entry if fetch failed
enriched.append(entry)
@@ -2306,7 +2311,7 @@ def extract_title_from_tags(tags_list: List[str]) -> Optional[str]:
if extracted:
return extracted
except Exception:
pass
logger.exception("extract_title failed while extracting title from tags")
for t in tags_list:
if isinstance(t, str) and t.lower().startswith("title:"):
@@ -2563,9 +2568,9 @@ def scrape_url_metadata(
}
)
except json_module.JSONDecodeError:
pass
logger.debug("Failed to decode flat playlist line %d as JSON: %r", idx, line[:200])
except Exception:
pass # Silently ignore if we can't get playlist entries
logger.exception("yt-dlp flat-playlist extraction failed for URL: %s", url)
# Fallback: if still no tags detected, get from first item
if not tags:
@@ -2751,6 +2756,7 @@ def apply_mutagen_metadata(path: Path, metadata: dict[str, str], fmt: str) -> No
audio[target_key] = [value]
changed = True
except Exception: # pragma: no cover - best effort only
logger.exception("mutagen: failed to set field %s for %s", target_key, path)
continue
if not changed:
return
@@ -2758,6 +2764,7 @@ def apply_mutagen_metadata(path: Path, metadata: dict[str, str], fmt: str) -> No
audio.save()
except Exception as exc: # pragma: no cover - best effort only
log(f"mutagen save failed: {exc}", file=sys.stderr)
logger.exception("mutagen save failed for %s", path)
def build_ffmpeg_command(