This commit is contained in:
2026-06-15 17:18:47 +02:00
parent db26a40415
commit b65edb4cce
4 changed files with 35 additions and 0 deletions

View File

@@ -1352,6 +1352,7 @@ func buildTagMetadata(trackMeta map[string]any, title, source, trackID string, o
Album: album, Album: album,
Artist: artist, Artist: artist,
AlbumArtist: albumArtist, AlbumArtist: albumArtist,
OmitDiscTags: opts.forPlaylist,
TrackNumber: trackNumber, TrackNumber: trackNumber,
DiscNumber: discNumber, DiscNumber: discNumber,
TrackTotal: trackTotal, TrackTotal: trackTotal,

View File

@@ -525,6 +525,9 @@ func TestBuildTagMetadataPlaylistOmitsDiscTags(t *testing.T) {
if tags.DiscTotal != 0 { if tags.DiscTotal != 0 {
t.Fatalf("disc total = %d, want 0", tags.DiscTotal) t.Fatalf("disc total = %d, want 0", tags.DiscTotal)
} }
if !tags.OmitDiscTags {
t.Fatalf("omit disc tags = %v, want true", tags.OmitDiscTags)
}
} }
func TestTrackOutputPathFallsBackToDisc1(t *testing.T) { func TestTrackOutputPathFallsBackToDisc1(t *testing.T) {

View File

@@ -14,6 +14,7 @@ type Metadata struct {
Album string Album string
Artist string Artist string
AlbumArtist string AlbumArtist string
OmitDiscTags bool
TrackNumber int TrackNumber int
DiscNumber int DiscNumber int
TrackTotal int TrackTotal int
@@ -101,6 +102,14 @@ func buildFFmpegArgs(inputPath, outputPath string, meta Metadata, coverPath, ext
} }
args = append(args, "-metadata", k+"="+v) args = append(args, "-metadata", k+"="+v)
} }
if meta.OmitDiscTags {
args = append(args,
"-metadata", "disc=",
"-metadata", "disk=",
"-metadata", "disctotal=",
"-metadata", "totaldiscs=",
)
}
args = append(args, outputPath) args = append(args, outputPath)
return args return args

View File

@@ -96,6 +96,28 @@ func TestBuildFFmpegArgsSkipsCoverForUnsupportedContainer(t *testing.T) {
} }
} }
func TestBuildFFmpegArgsClearsDiscTagsWhenRequested(t *testing.T) {
args := buildFFmpegArgs("in.flac", "out.flac", Metadata{Title: "x", OmitDiscTags: true}, "", "flac")
want := map[string]bool{
"disc=": false,
"disk=": false,
"disctotal=": false,
"totaldiscs=": false,
}
for i := 0; i < len(args)-1; i++ {
if args[i] == "-metadata" {
if _, ok := want[args[i+1]]; ok {
want[args[i+1]] = true
}
}
}
for tag, found := range want {
if !found {
t.Fatalf("missing clear tag %q in args: %v", tag, args)
}
}
}
func TestTaggedTempPathPreservesExtension(t *testing.T) { func TestTaggedTempPathPreservesExtension(t *testing.T) {
if got := taggedTempPath("/tmp/song.flac"); got != "/tmp/song.tmp.flac" { if got := taggedTempPath("/tmp/song.flac"); got != "/tmp/song.tmp.flac" {
t.Fatalf("taggedTempPath(flac)=%q", got) t.Fatalf("taggedTempPath(flac)=%q", got)