from app.models import JobRun from app.services import pipeline_runner async def set_artist_genre(artist: str, genre: str, changed_by: str, dry_run: bool = False) -> JobRun: """Wraps the existing fix-genre.sh (per-format FLAC/MP3/MP4/OGG tag writing + GENRE_LOCK + beets DB sync) rather than reimplementing its mutagen logic here -- it's already tested and handles every format this library contains. No manual_fix_audit row: this is an artist-wide bulk edit (could touch dozens of tracks), not a single beets_item_id the audit table's schema is shaped for. The job_runs row (with its full log) is the audit trail for this action instead. """ args = [] if dry_run: args.append("--dry") args.extend([artist, genre]) return await pipeline_runner.run_lib_script( "manual:fix_genre", "fix-genre.sh", args, triggered_by=f"manual:{changed_by}" )