Skip to content

Write MUSICBRAINZ_TRACKID to file tags on "Complete tags automatically"#2056

Merged
jonaski merged 1 commit intostrawberrymusicplayer:masterfrom
VictorVow:feat/write-musicbrainz
Apr 8, 2026
Merged

Write MUSICBRAINZ_TRACKID to file tags on "Complete tags automatically"#2056
jonaski merged 1 commit intostrawberrymusicplayer:masterfrom
VictorVow:feat/write-musicbrainz

Conversation

@VictorVow
Copy link
Copy Markdown
Contributor

Problem

"Complete tags automatically" retrieves the MusicBrainz recording UUID via AcoustID, uses it to query the MusicBrainz API for metadata, then silently discards it. The UUID never enters the Result struct and cannot reach the tag-write path. Only standard metadata (title, artist, album, year, track number) is written to files.

Solution

Wire the recording UUID through the full pipeline so it is written to file tags alongside the other metadata.

Changes

src/musicbrainz/musicbrainzclient.h / .cpp

  • Result gains a musicbrainz_recording_id_ field
  • MbIdRequestFinished receives the mbid it looked up (already captured in the lambda) and stamps it onto every Result produced from that request

src/musicbrainz/tagfetcher.cpp

  • TagsFetched copies musicbrainz_recording_id_ onto the Song built from each Result

src/dialogs/trackselectiondialog.cpp

  • SaveData includes musicbrainz_recording_id in the set of fields copied to the file on user confirmation

src/tagreader/tagreadertaglib.cpp

  • ID3v2 (MP3, WAV, AIFF): TXXX frame with description MUSICBRAINZ_TRACKID
  • Vorbis comments (FLAC, OGG, Opus): MUSICBRAINZ_TRACKID field
  • APE tags (WavPack, Musepack, Monkey's Audio): MUSICBRAINZ_TRACKID item
  • MP4/iTunes (M4A, AAC): ----:com.apple.iTunes:MusicBrainz Track Id
  • ASF/WMA: MusicBrainz/Track Id attribute
  • Added TXXX read path for MUSICBRAINZ_TRACKID so tags written by this code are read back into the database on the next scan

Notes

  • All writes are guarded with !isEmpty() — no empty tags are written
  • The existing UFID read path for musicbrainz_recording_id is preserved for files tagged by external tools (Picard, beets)
  • The ASF write uses the existing SetAsfAttribute helper which already handles empty-string removal

Previously, "Complete tags automatically" retrieved the MusicBrainz
recording UUID via AcoustID, used it internally to query the MusicBrainz
API for metadata, then discarded it — the UUID never entered the Result
struct and could not reach the tag-write path. Only standard metadata
(title, artist, album, year, track number) was written to files.

This change wires the recording UUID through the full pipeline:

- MusicBrainzClient::Result gains a musicbrainz_recording_id_ field
- MbIdRequestFinished receives the mbid it looked up and stamps it onto
  every Result produced from that request
- TagFetcher::TagsFetched copies the field onto the Song built from each
  Result
- TrackSelectionDialog::SaveData includes musicbrainz_recording_id in the
  set of fields copied to the file

Tag write support added for all formats:
- ID3v2 (MP3, WAV, AIFF): TXXX frame with description "MUSICBRAINZ_TRACKID"
- Vorbis comments (FLAC, OGG, Opus): MUSICBRAINZ_TRACKID field
- APE tags (WavPack, Musepack, Monkey's Audio): MUSICBRAINZ_TRACKID item
- MP4/iTunes (M4A, AAC): ----:com.apple.iTunes:MusicBrainz Track Id
- ASF/WMA: MusicBrainz/Track Id attribute

A matching read path for the TXXX case is also added so that tags written
by this code are read back into the Strawberry database on the next scan.
@jonaski jonaski force-pushed the feat/write-musicbrainz branch from 65664e5 to 0a9448b Compare April 8, 2026 23:00
@jonaski jonaski merged commit 0908a6b into strawberrymusicplayer:master Apr 8, 2026
@jonaski
Copy link
Copy Markdown
Member

jonaski commented Apr 8, 2026

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants