mirror of
https://git.sr.ht/~joren/streamrip-go
synced 2026-06-17 15:05:39 +02:00
yes
This commit is contained in:
@@ -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,
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user