🎧 Your Personal Streaming Service
Go airsonicmadsonicmedia-servermusicmusic-servernavidromeopensubsonicraspberry-piself-hostedstreamerstreaming-apistreaming-audiosubsonicsubsonic-server
Add more replaygain tests, fix wma (#2356)
Kendall Garner3debd31b1281
diff --git a/scanner/metadata/metadata_test.go b/scanner/metadata/metadata_test.goindex 0b1a78554..dba52ed77 100644--- a/scanner/metadata/metadata_test.go+++ b/scanner/metadata/metadata_test.go@@ -56,15 +56,15 @@ var _ = Describe("Tags", func() {m = mds["tests/fixtures/test.ogg"]Expect(err).To(BeNil())- Expect(m.Title()).To(BeEmpty())+ Expect(m.Title()).To(Equal("Title"))Expect(m.HasPicture()).To(BeFalse())Expect(m.Duration()).To(BeNumerically("~", 1.04, 0.01))Expect(m.Suffix()).To(Equal("ogg"))Expect(m.FilePath()).To(Equal("tests/fixtures/test.ogg"))- Expect(m.Size()).To(Equal(int64(5178)))+ Expect(m.Size()).To(Equal(int64(6333)))// TabLib 1.12 returns 18, previous versions return 39.// See https://github.com/taglib/taglib/commit/2f238921824741b2cfe6fbfbfc9701d9827ab06b- Expect(m.BitRate()).To(BeElementOf(18, 39, 40))+ Expect(m.BitRate()).To(BeElementOf(18, 39, 40, 49))})})})diff --git a/scanner/metadata/taglib/taglib_test.go b/scanner/metadata/taglib/taglib_test.goindex 342cb03c8..bc0cfd630 100644--- a/scanner/metadata/taglib/taglib_test.go+++ b/scanner/metadata/taglib/taglib_test.go@@ -52,6 +52,10 @@ var _ = Describe("Extractor", func() {Expect(m).To(HaveKeyWithValue("comment", []string{"Comment1\nComment2"}))Expect(m).To(HaveKeyWithValue("lyrics", []string{"Lyrics 1\rLyrics 2"}))Expect(m).To(HaveKeyWithValue("bpm", []string{"123"}))+ Expect(m).To(HaveKeyWithValue("replaygain_album_gain", []string{"+3.21518 dB"}))+ Expect(m).To(HaveKeyWithValue("replaygain_album_peak", []string{"0.9125"}))+ Expect(m).To(HaveKeyWithValue("replaygain_track_gain", []string{"-1.48 dB"}))+ Expect(m).To(HaveKeyWithValue("replaygain_track_peak", []string{"0.4512"}))Expect(m).To(HaveKeyWithValue("tracknumber", []string{"2/10"}))m = m.Map(e.CustomMappings())@@ -59,7 +63,6 @@ var _ = Describe("Extractor", func() {m = mds["tests/fixtures/test.ogg"]Expect(err).To(BeNil())- Expect(m).ToNot(HaveKey("title"))Expect(m).ToNot(HaveKey("has_picture"))Expect(m).To(HaveKeyWithValue("duration", []string{"1.04"}))Expect(m).To(HaveKeyWithValue("fbpm", []string{"141.7"}))@@ -67,11 +70,11 @@ var _ = Describe("Extractor", func() {// TabLib 1.12 returns 18, previous versions return 39.// See https://github.com/taglib/taglib/commit/2f238921824741b2cfe6fbfbfc9701d9827ab06bExpect(m).To(HaveKey("bitrate"))- Expect(m["bitrate"][0]).To(BeElementOf("18", "39", "40"))+ Expect(m["bitrate"][0]).To(BeElementOf("18", "39", "40", "49"))})- DescribeTable("ReplayGain",- func(file, albumGain, albumPeak, trackGain, trackPeak string) {+ DescribeTable("Format-Specific tests",+ func(file, duration, channels, albumGain, albumPeak, trackGain, trackPeak string) {file = "tests/fixtures/" + filemds, err := e.Parse(file)Expect(err).NotTo(HaveOccurred())@@ -83,10 +86,54 @@ var _ = Describe("Extractor", func() {Expect(m).To(HaveKeyWithValue("replaygain_album_peak", []string{albumPeak}))Expect(m).To(HaveKeyWithValue("replaygain_track_gain", []string{trackGain}))Expect(m).To(HaveKeyWithValue("replaygain_track_peak", []string{trackPeak}))++ Expect(m).To(HaveKeyWithValue("title", []string{"Title", "Title"}))+ Expect(m).To(HaveKeyWithValue("album", []string{"Album", "Album"}))+ Expect(m).To(HaveKeyWithValue("artist", []string{"Artist", "Artist"}))+ Expect(m).To(HaveKeyWithValue("albumartist", []string{"Album Artist"}))+ Expect(m).To(HaveKeyWithValue("compilation", []string{"1"}))+ Expect(m).To(HaveKeyWithValue("genre", []string{"Rock"}))+ Expect(m).To(HaveKeyWithValue("date", []string{"2014", "2014"}))++ Expect(m).To(HaveKey("discnumber"))+ discno := m["discnumber"]+ Expect(discno).To(HaveLen(1))+ Expect(discno[0]).To(BeElementOf([]string{"1", "1/2"}))++ Expect(m).NotTo(HaveKeyWithValue("has_picture", []string{"true"}))+ Expect(m).To(HaveKeyWithValue("duration", []string{duration}))++ Expect(m).To(HaveKeyWithValue("channels", []string{channels}))+ Expect(m).To(HaveKeyWithValue("comment", []string{"Comment1\nComment2"}))+ Expect(m).To(HaveKeyWithValue("lyrics", []string{"Lyrics1\nLyrics 2"}))+ Expect(m).To(HaveKeyWithValue("bpm", []string{"123"}))++ Expect(m).To(HaveKey("tracknumber"))+ trackNo := m["tracknumber"]+ Expect(trackNo).To(HaveLen(1))+ Expect(trackNo[0]).To(BeElementOf([]string{"3", "3/10"}))},- Entry("Correctly parses m4a (aac) gain tags", "01 Invisible (RED) Edit Version.m4a", "0.37", "0.48", "0.37", "0.48"),- Entry("correctly parses mp3 tags", "test.mp3", "+3.21518 dB", "0.9125", "-1.48 dB", "0.4512"),- Entry("correctly parses ogg (vorbis) tags", "test.ogg", "+7.64 dB", "0.11772506", "+7.64 dB", "0.11772506"),++ // ffmpeg -f lavfi -i "sine=frequency=1200:duration=1" test.flac+ Entry("correctly parses flac tags", "test.flac", "1.00", "1", "+4.06 dB", "0.12496948", "+4.06 dB", "0.12496948"),++ Entry("Correctly parses m4a (aac) gain tags", "01 Invisible (RED) Edit Version.m4a", "1.04", "2", "0.37", "0.48", "0.37", "0.48"),++ Entry("correctly parses ogg (vorbis) tags", "test.ogg", "1.04", "2", "+7.64 dB", "0.11772506", "+7.64 dB", "0.11772506"),++ // ffmpeg -f lavfi -i "sine=frequency=900:duration=1" test.wma+ Entry("correctly parses wma/asf tags", "test.wma", "1.02", "1", "3.27 dB", "0.132914", "3.27 dB", "0.132914"),++ // ffmpeg -f lavfi -i "sine=frequency=800:duration=1" test.wv+ Entry("correctly parses wv (wavpak) tags", "test.wv", "1.00", "1", "3.43 dB", "0.125061", "3.43 dB", "0.125061"),++ // TODO - these breaks in the pipeline as it uses TabLib 1.11. Once Ubuntu 24.04 is released we can uncomment these tests+ // ffmpeg -f lavfi -i "sine=frequency=1000:duration=1" test.wav+ //Entry("correctly parses wav tags", "test.wav", "1.00", "1", "3.06 dB", "0.125056", "3.06 dB", "0.125056"),++ // ffmpeg -f lavfi -i "sine=frequency=1400:duration=1" test.aiff+ //Entry("correctly parses aiff tags", "test.aiff", "1.00", "1", "2.00 dB", "0.124972", "2.00 dB", "0.124972"),+)})diff --git a/scanner/metadata/taglib/taglib_wrapper.cpp b/scanner/metadata/taglib/taglib_wrapper.cppindex 3f111c137..b5ea60569 100644--- a/scanner/metadata/taglib/taglib_wrapper.cpp+++ b/scanner/metadata/taglib/taglib_wrapper.cpp@@ -100,6 +100,29 @@ int taglib_read(const FILENAME_CHAR_T *filename, unsigned long id) {}}+ // WMA/ASF files may have additional tags not captured by the general iterator+ TagLib::ASF::File *asfFile(dynamic_cast<TagLib::ASF::File *>(f.file()));+ if (asfFile != NULL)+ {+ const TagLib::ASF::Tag *asfTags{asfFile->tag()};+ const auto itemListMap = asfTags->attributeListMap();+ for (const auto item : itemListMap) {+ char *key = ::strdup(item.first.toCString(true));+ char *val = ::strdup(item.second.front().toString().toCString());+ go_map_put_str(id, key, val);+ free(key);+ free(val);+ }++ // Compilation tag needs to be handled differently+ const auto compilation = asfTags->attribute("WM/IsCompilation");+ if (!compilation.isEmpty()) {+ char *val = ::strdup(compilation.front().toString().toCString());+ go_map_put_str(id, (char *)"compilation", val);+ free(val);+ }+ }+if (has_cover(f)) {go_map_put_str(id, (char *)"has_picture", (char *)"true");}diff --git a/scanner/tag_scanner_test.go b/scanner/tag_scanner_test.goindex 215e06bc3..a798570c0 100644--- a/scanner/tag_scanner_test.go+++ b/scanner/tag_scanner_test.go@@ -10,9 +10,14 @@ var _ = Describe("TagScanner", func() {It("return all audio files from the folder", func() {files, err := loadAllAudioFiles("tests/fixtures")Expect(err).ToNot(HaveOccurred())- Expect(files).To(HaveLen(5))- Expect(files).To(HaveKey("tests/fixtures/test.ogg"))+ Expect(files).To(HaveLen(10))+ Expect(files).To(HaveKey("tests/fixtures/test.aiff"))+ Expect(files).To(HaveKey("tests/fixtures/test.flac"))Expect(files).To(HaveKey("tests/fixtures/test.mp3"))+ Expect(files).To(HaveKey("tests/fixtures/test.ogg"))+ Expect(files).To(HaveKey("tests/fixtures/test.wav"))+ Expect(files).To(HaveKey("tests/fixtures/test.wma"))+ Expect(files).To(HaveKey("tests/fixtures/test.wv"))Expect(files).To(HaveKey("tests/fixtures/test_no_read_permission.ogg"))Expect(files).To(HaveKey("tests/fixtures/01 Invisible (RED) Edit Version.mp3"))Expect(files).To(HaveKey("tests/fixtures/01 Invisible (RED) Edit Version.m4a"))diff --git a/scanner/walk_dir_tree_test.go b/scanner/walk_dir_tree_test.goindex 163754a69..e0cea0078 100644--- a/scanner/walk_dir_tree_test.go+++ b/scanner/walk_dir_tree_test.go@@ -35,7 +35,7 @@ var _ = Describe("walk_dir_tree", func() {Expect(collected[baseDir]).To(MatchFields(IgnoreExtras, Fields{"Images": BeEmpty(),"HasPlaylist": BeFalse(),- "AudioFilesCount": BeNumerically("==", 6),+ "AudioFilesCount": BeNumerically("==", 11),}))Expect(collected[filepath.Join(baseDir, "artist", "an-album")]).To(MatchFields(IgnoreExtras, Fields{"Images": ConsistOf("cover.jpg", "front.png", "artist.png"),diff --git a/tests/fixtures/01 Invisible (RED) Edit Version.m4a b/tests/fixtures/01 Invisible (RED) Edit Version.m4aindex 55d360d89..80474aa35 100644Binary files a/tests/fixtures/01 Invisible (RED) Edit Version.m4a and b/tests/fixtures/01 Invisible (RED) Edit Version.m4a differdiff --git a/tests/fixtures/test.aiff b/tests/fixtures/test.aiffnew file mode 100644index 000000000..148de3693Binary files /dev/null and b/tests/fixtures/test.aiff differdiff --git a/tests/fixtures/test.flac b/tests/fixtures/test.flacnew file mode 100644index 000000000..a3cf5e986Binary files /dev/null and b/tests/fixtures/test.flac differdiff --git a/tests/fixtures/test.ogg b/tests/fixtures/test.oggindex 9a5490d31..306d3bb13 100644Binary files a/tests/fixtures/test.ogg and b/tests/fixtures/test.ogg differdiff --git a/tests/fixtures/test.wav b/tests/fixtures/test.wavnew file mode 100644index 000000000..2bb8dd96cBinary files /dev/null and b/tests/fixtures/test.wav differdiff --git a/tests/fixtures/test.wma b/tests/fixtures/test.wmanew file mode 100644index 000000000..5d08ab3c4Binary files /dev/null and b/tests/fixtures/test.wma differdiff --git a/tests/fixtures/test.wv b/tests/fixtures/test.wvnew file mode 100644index 000000000..2b479ef7aBinary files /dev/null and b/tests/fixtures/test.wv differ