fix: imported FLAC, Ogg and Opus files keep their track and disc numbers (#6171)
release / govulncheck (push) Successful in 14s
release / web (push) Successful in 1m21s
release / go (push) Successful in 1m29s
release / integration (push) Successful in 5m1s
release / android (push) Successful in 5m5s
release / Build signed APK (releases and dev) (push) Successful in 5m21s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Successful in 16s
release / Verify release artifacts (tag releases only) (push) Skipped
release / govulncheck (push) Successful in 14s
release / web (push) Successful in 1m21s
release / go (push) Successful in 1m29s
release / integration (push) Successful in 5m1s
release / android (push) Successful in 5m5s
release / Build signed APK (releases and dev) (push) Successful in 5m21s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Successful in 16s
release / Verify release artifacts (tag releases only) (push) Skipped
The importer wrote track=N/M for every format, which ffmpeg stores in a Vorbis comment as TRACKNUMBER=3/20; dhowden/tag reads a Vorbis TRACKNUMBER with a bare Atoi, so it came back 0. All 245 tracks imported since 2026-10-10 (Humanz, Plastic Beach, the Gorillaz super deluxe and twelve more albums) have no track or disc number, and their album pages have no order. - The importer writes a Vorbis track and disc number alone, with TRACKTOTAL and DISCTOTAL, as Picard does. ID3 and MP4 keep N/M. - ReadTrackAndDisc takes the number before a slash when the Vorbis reader returns 0, for the scanner and for the import's own check of a download. - tagReadVersion 6 re-reads the files already held (tag reads only). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -133,8 +133,7 @@ func readFile(ctx context.Context, root, path string) File {
|
||||
return f
|
||||
}
|
||||
f.Title, f.Artist, f.AlbumArtist, f.Album = m.Title(), m.Artist(), m.AlbumArtist(), m.Album()
|
||||
f.Track, _ = m.Track()
|
||||
f.Disc, _ = m.Disc()
|
||||
f.Track, f.Disc = library.ReadTrackAndDisc(m)
|
||||
ids := library.ReadTagMBIDs(m)
|
||||
f.GroupMBID, f.ReleaseMBID, f.RecordingMBID = ids.ReleaseGroup, ids.Release, ids.Recording
|
||||
return f
|
||||
|
||||
@@ -38,16 +38,32 @@ type Tags struct {
|
||||
// ID3 takes Picard's TXXX descriptions, which ffmpeg writes for any key it
|
||||
// has no frame for. MP4's freeform atoms ffmpeg cannot write, so an M4A
|
||||
// gets the plain names only.
|
||||
//
|
||||
// A Vorbis track or disc number is the number alone, its count in
|
||||
// TRACKTOTAL and DISCTOTAL, as Picard writes them: dhowden/tag reads
|
||||
// TRACKNUMBER "3/20" as 0, and every album imported before #6171 lost its
|
||||
// order that way. ID3 and MP4 take "3/20", which their readers parse.
|
||||
func (t Tags) args(ext string) []string {
|
||||
vorbis := ext == ".flac" || ext == ".ogg" || ext == ".opus"
|
||||
track, disc := ofN(t.Track, t.Tracks), ofN(t.Disc, t.Discs)
|
||||
if vorbis {
|
||||
track, disc = ofN(t.Track, 0), ofN(t.Disc, 0)
|
||||
}
|
||||
kv := [][2]string{
|
||||
{"title", t.Title}, {"artist", t.Artist}, {"album", t.Album}, {"album_artist", t.AlbumArtist},
|
||||
{"track", ofN(t.Track, t.Tracks)}, {"disc", ofN(t.Disc, t.Discs)},
|
||||
{"track", track}, {"disc", disc},
|
||||
}
|
||||
if t.Year > 0 {
|
||||
kv = append(kv, [2]string{"date", strconv.Itoa(t.Year)})
|
||||
}
|
||||
switch ext {
|
||||
case ".flac", ".ogg", ".opus":
|
||||
if t.Track > 0 && t.Tracks > 0 {
|
||||
kv = append(kv, [2]string{"TRACKTOTAL", strconv.Itoa(t.Tracks)})
|
||||
}
|
||||
if t.Disc > 0 && t.Discs > 0 {
|
||||
kv = append(kv, [2]string{"DISCTOTAL", strconv.Itoa(t.Discs)})
|
||||
}
|
||||
kv = append(kv,
|
||||
[2]string{"MUSICBRAINZ_ALBUMID", t.ReleaseMBID},
|
||||
[2]string{"MUSICBRAINZ_RELEASEGROUPID", t.GroupMBID},
|
||||
|
||||
@@ -212,11 +212,21 @@ func TestTagsArgs(t *testing.T) {
|
||||
tg := Tags{Title: "Get Lucky", Artist: "Daft Punk", Track: 8, Tracks: 13, Disc: 1, Discs: 1, Year: 2013,
|
||||
RecordingMBID: "rec-08", GroupMBID: "rg-ram"}
|
||||
flac := strings.Join(tg.args(".flac"), " ")
|
||||
for _, s := range []string{"title=Get Lucky", "track=8/13", "date=2013", "MUSICBRAINZ_TRACKID=rec-08", "MUSICBRAINZ_RELEASEGROUPID=rg-ram"} {
|
||||
for _, s := range []string{
|
||||
"title=Get Lucky", "track=8 ", "TRACKTOTAL=13", "disc=1 ", "DISCTOTAL=1", "date=2013",
|
||||
"MUSICBRAINZ_TRACKID=rec-08", "MUSICBRAINZ_RELEASEGROUPID=rg-ram",
|
||||
} {
|
||||
if !strings.Contains(flac, s) {
|
||||
t.Errorf("flac args lack %q: %s", s, flac)
|
||||
}
|
||||
}
|
||||
// dhowden/tag reads a Vorbis TRACKNUMBER of "8/13" as 0 (#6171).
|
||||
if strings.Contains(flac, "/13") {
|
||||
t.Errorf("flac track number carries its count: %s", flac)
|
||||
}
|
||||
if mp3 := strings.Join(tg.args(".mp3"), " "); !strings.Contains(mp3, "track=8/13") {
|
||||
t.Errorf("mp3 track should be 8/13, which ID3 readers parse: %s", mp3)
|
||||
}
|
||||
if strings.Contains(flac, "MUSICBRAINZ_ALBUMID") {
|
||||
t.Errorf("an empty release id was written: %s", flac)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user