mirror of
https://git.sr.ht/~joren/streamrip-go
synced 2026-06-17 15:05:39 +02:00
yes
This commit is contained in:
@@ -14,6 +14,7 @@ type Metadata struct {
|
||||
Album string
|
||||
Artist string
|
||||
AlbumArtist string
|
||||
OmitDiscTags bool
|
||||
TrackNumber int
|
||||
DiscNumber int
|
||||
TrackTotal int
|
||||
@@ -101,6 +102,14 @@ func buildFFmpegArgs(inputPath, outputPath string, meta Metadata, coverPath, ext
|
||||
}
|
||||
args = append(args, "-metadata", k+"="+v)
|
||||
}
|
||||
if meta.OmitDiscTags {
|
||||
args = append(args,
|
||||
"-metadata", "disc=",
|
||||
"-metadata", "disk=",
|
||||
"-metadata", "disctotal=",
|
||||
"-metadata", "totaldiscs=",
|
||||
)
|
||||
}
|
||||
|
||||
args = append(args, outputPath)
|
||||
return args
|
||||
|
||||
@@ -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) {
|
||||
if got := taggedTempPath("/tmp/song.flac"); got != "/tmp/song.tmp.flac" {
|
||||
t.Fatalf("taggedTempPath(flac)=%q", got)
|
||||
|
||||
Reference in New Issue
Block a user