Post-processing applies ReplayGain only to slskd/WebUI downloads — content added via Lidarr, the REST API, or by hand never got it, and there was no way to (re)apply RG to existing tracks or fix ones where analysis failed (raised in #437 + comments). New ReplayGain Filler repair job (sibling of Lyrics/Cover Art fillers): scans for tracks with no ReplayGain track-gain tag and creates a finding per track; the scan only READS tags (cheap) and no-ops when ffmpeg is absent. Applying a finding runs the same ffmpeg ebur128 analysis the import pipeline uses (gain = ref - LUFS) and writes the RG tags in place — no moves, no re-matching. Opt-in (default off), schedulable like the other maintenance jobs. Wired: job registry, repair_worker apply handler (_fix_missing_replaygain) + fixable-types, and the findings UI (label / fix-button / detail rows). Tests: pure needs_replaygain decision (missing/blank/present/+0.00-is-tagged) + the apply handler's analyze→compute→write seam with the pipeline gain formula, ffmpeg-absent + missing-file guards, and registration. 93 repair tests green.
70 lines
2.2 KiB
Python
70 lines
2.2 KiB
Python
"""Repair Jobs Registry — all available maintenance jobs for the Library Worker."""
|
|
|
|
import importlib
|
|
|
|
from core.repair_jobs.base import RepairJob, JobContext, JobResult
|
|
from utils.logging_config import get_logger
|
|
|
|
logger = get_logger("repair_jobs")
|
|
|
|
# Registry populated at import time by each job module
|
|
JOB_REGISTRY: dict[str, type[RepairJob]] = {}
|
|
|
|
_imports_done = False
|
|
|
|
|
|
def register_job(cls: type[RepairJob]) -> type[RepairJob]:
|
|
"""Decorator to register a RepairJob subclass."""
|
|
JOB_REGISTRY[cls.job_id] = cls
|
|
return cls
|
|
|
|
|
|
def get_all_jobs() -> dict[str, type[RepairJob]]:
|
|
"""Return the full job registry. Ensures all job modules are imported."""
|
|
_import_all_jobs()
|
|
return JOB_REGISTRY
|
|
|
|
|
|
_JOB_MODULES = [
|
|
'core.repair_jobs.track_number_repair',
|
|
'core.repair_jobs.cache_evictor',
|
|
'core.repair_jobs.orphan_file_detector',
|
|
'core.repair_jobs.dead_file_cleaner',
|
|
'core.repair_jobs.duplicate_detector',
|
|
'core.repair_jobs.acoustid_scanner',
|
|
'core.repair_jobs.missing_cover_art',
|
|
'core.repair_jobs.missing_lyrics',
|
|
'core.repair_jobs.replaygain_filler',
|
|
'core.repair_jobs.expired_download_cleaner',
|
|
'core.repair_jobs.metadata_gap_filler',
|
|
'core.repair_jobs.album_completeness',
|
|
'core.repair_jobs.fake_lossless_detector',
|
|
'core.repair_jobs.library_reorganize',
|
|
'core.repair_jobs.mbid_mismatch_detector',
|
|
'core.repair_jobs.single_album_dedup',
|
|
'core.repair_jobs.lossy_converter',
|
|
'core.repair_jobs.album_tag_consistency',
|
|
'core.repair_jobs.live_commentary_cleaner',
|
|
'core.repair_jobs.unknown_artist_fixer',
|
|
'core.repair_jobs.discography_backfill',
|
|
'core.repair_jobs.canonical_version_resolve',
|
|
'core.repair_jobs.library_retag',
|
|
]
|
|
|
|
|
|
def _import_all_jobs():
|
|
"""Import all job modules to trigger registration.
|
|
|
|
Each module is imported individually so that a failure in one
|
|
does not prevent the others from loading.
|
|
"""
|
|
global _imports_done
|
|
if _imports_done:
|
|
return
|
|
_imports_done = True
|
|
|
|
for module_name in _JOB_MODULES:
|
|
try:
|
|
importlib.import_module(module_name)
|
|
except Exception as e:
|
|
logger.error("Failed to import job module %s: %s", module_name, e)
|