Fix AcoustID retag action not writing tags to audio file

The retag fix for AcoustID mismatches was only updating the DB
record (title, artist_id) without writing corrected tags to the
actual audio file. Users would click Fix, the finding disappeared,
but the file on disk stayed unchanged. Now writes title and artist
tags to the file via Mutagen after the DB update.

Also fixed artist INSERT missing server_source when creating a new
artist during retag — now uses the active media server value.
This commit is contained in:
Broque Thomas 2026-04-19 19:14:49 -07:00
parent ef8cff3c69
commit 036f284ee3
3 changed files with 22 additions and 2 deletions

View file

@ -1615,9 +1615,13 @@ class RepairWorker:
aid_artist.strip() or 'unknown'
)
new_artist_id = f"artist_local_{safe_artist_name}_{uuid.uuid4().hex[:8]}"
# Include server_source to match the active media server context
active_server = 'plex'
if self._config_manager:
active_server = self._config_manager.get('active_media_server', 'plex')
cursor.execute(
"INSERT INTO artists (id, name) VALUES (?, ?)",
(new_artist_id, aid_artist),
"INSERT INTO artists (id, name, server_source) VALUES (?, ?, ?)",
(new_artist_id, aid_artist, active_server),
)
cursor.execute("UPDATE tracks SET artist_id = ? WHERE id = ?",
(new_artist_id, track_id))
@ -1626,6 +1630,20 @@ class RepairWorker:
except Exception as e:
return {'success': False, 'error': f'DB update failed: {e}'}
# Write corrected tags to the actual audio file
if file_path:
resolved = _resolve_file_path(file_path, self.transfer_folder)
if resolved and os.path.exists(resolved):
try:
from core.tag_writer import write_tags_to_file
tag_updates = {'title': aid_title}
if aid_artist:
tag_updates['artist_name'] = aid_artist
write_tags_to_file(resolved, tag_updates)
logger.info("Wrote corrected tags to file: %s", resolved)
except Exception as tag_err:
logger.warning("Could not write tags to file %s: %s", resolved, tag_err)
return {'success': True, 'action': 'retagged',
'message': f'Updated to: "{aid_title}" by {aid_artist}'}

View file

@ -22529,6 +22529,7 @@ def get_version_info():
"• Reject Qobuz 30-second sample/preview downloads",
"• Fix library page crash on All filter — non-string soul_id broke card rendering",
"• Auto Wing It fallback for failed discovery — unmatched tracks download via Soulseek with raw metadata",
"• Fix AcoustID retag not writing corrected tags to audio file",
"• Fix wishlist albums cycle stuck at 1 concurrent worker instead of configured value",
"• Fix downloads badge dropping to 300 after opening Downloads page",
"• Fix server playlist Find & Add inserting at wrong position on Plex",

View file

@ -3603,6 +3603,7 @@ const WHATS_NEW = {
// --- April 19, 2026 ---
{ date: 'April 19, 2026' },
{ title: 'Fix Wishlist Albums Cycle Stuck at 1 Concurrent', desc: 'Auto-wishlist processing during the "albums" cycle was limited to 1 concurrent download even with higher configured settings. The max_concurrent=1 restriction is only needed for Soulseek folder-based album grabs, not individual wishlist track downloads. Albums cycle now uses the configured concurrency like singles' },
{ title: 'Fix AcoustID Retag Not Writing to File', desc: 'The AcoustID mismatch "Retag" fix action was only updating the database record without writing corrected tags to the actual audio file. Now writes title and artist tags to the file using Mutagen after updating the DB' },
{ title: 'Fix Downloads Badge Dropping to 300', desc: 'Downloads nav badge showed the correct count from WebSocket but dropped to max 300 after opening the Downloads page because it recounted from a truncated local array. Badge now stays accurate from the server-side count' },
{ title: 'Fix Server Playlist Find & Add Position', desc: 'When using "Find & add" on server playlists with Plex, the track was always appended to the end instead of inserted at the correct position. Now moves the track to the right slot after adding' },
{ title: 'Smarter Fix Modal Search Results', desc: 'The discovery Fix modal now sorts search results to prioritize standard album versions over live recordings, remixes, covers, soundtracks, remasters, and deluxe editions. Previously the first result was often a live or remix version instead of the original studio track' },