Skip to content

🎧 Your Personal Streaming Service

fix(scanner): check if aiff/wma file has cover art (#3996)

Kendall Garner0d1f2bcc8af4
diff --git a/adapters/taglib/taglib_test.go b/adapters/taglib/taglib_test.go
index ba41b2c1e..37b012763 100644
--- a/adapters/taglib/taglib_test.go
+++ b/adapters/taglib/taglib_test.go
@@ -82,15 +82,15 @@ var _ = Describe("Extractor", func() {
// TabLib 1.12 returns 18, previous versions return 39.
// See https://github.com/taglib/taglib/commit/2f238921824741b2cfe6fbfbfc9701d9827ab06b
- Expect(m.AudioProperties.BitRate).To(BeElementOf(18, 39, 40, 43, 49))
+ Expect(m.AudioProperties.BitRate).To(BeElementOf(18, 19, 39, 40, 43, 49))
Expect(m.AudioProperties.Channels).To(BeElementOf(2))
Expect(m.AudioProperties.SampleRate).To(BeElementOf(8000))
Expect(m.AudioProperties.SampleRate).To(BeElementOf(8000))
- Expect(m.HasPicture).To(BeFalse())
+ Expect(m.HasPicture).To(BeTrue())
})
DescribeTable("Format-Specific tests",
- func(file, duration string, channels, samplerate, bitdepth int, albumGain, albumPeak, trackGain, trackPeak string, id3Lyrics bool) {
+ func(file, duration string, channels, samplerate, bitdepth int, albumGain, albumPeak, trackGain, trackPeak string, id3Lyrics bool, image bool) {
file = "tests/fixtures/" + file
mds, err := e.Parse(file)
Expect(err).NotTo(HaveOccurred())
@@ -98,7 +98,7 @@ var _ = Describe("Extractor", func() {
m := mds[file]
- Expect(m.HasPicture).To(BeFalse())
+ Expect(m.HasPicture).To(Equal(image))
Expect(m.AudioProperties.Duration.String()).To(Equal(duration))
Expect(m.AudioProperties.Channels).To(Equal(channels))
Expect(m.AudioProperties.SampleRate).To(Equal(samplerate))
@@ -168,24 +168,24 @@ var _ = Describe("Extractor", func() {
},
// ffmpeg -f lavfi -i "sine=frequency=1200:duration=1" test.flac
- Entry("correctly parses flac tags", "test.flac", "1s", 1, 44100, 16, "+4.06 dB", "0.12496948", "+4.06 dB", "0.12496948", false),
+ Entry("correctly parses flac tags", "test.flac", "1s", 1, 44100, 16, "+4.06 dB", "0.12496948", "+4.06 dB", "0.12496948", false, true),
- Entry("correctly parses m4a (aac) gain tags", "01 Invisible (RED) Edit Version.m4a", "1.04s", 2, 44100, 16, "0.37", "0.48", "0.37", "0.48", false),
- Entry("correctly parses m4a (aac) gain tags (uppercase)", "test.m4a", "1.04s", 2, 44100, 16, "0.37", "0.48", "0.37", "0.48", false),
- Entry("correctly parses ogg (vorbis) tags", "test.ogg", "1.04s", 2, 8000, 0, "+7.64 dB", "0.11772506", "+7.64 dB", "0.11772506", false),
+ Entry("correctly parses m4a (aac) gain tags", "01 Invisible (RED) Edit Version.m4a", "1.04s", 2, 44100, 16, "0.37", "0.48", "0.37", "0.48", false, true),
+ Entry("correctly parses m4a (aac) gain tags (uppercase)", "test.m4a", "1.04s", 2, 44100, 16, "0.37", "0.48", "0.37", "0.48", false, true),
+ Entry("correctly parses ogg (vorbis) tags", "test.ogg", "1.04s", 2, 8000, 0, "+7.64 dB", "0.11772506", "+7.64 dB", "0.11772506", false, true),
// ffmpeg -f lavfi -i "sine=frequency=900:duration=1" test.wma
// Weird note: for the tag parsing to work, the lyrics are actually stored in the reverse order
- Entry("correctly parses wma/asf tags", "test.wma", "1.02s", 1, 44100, 16, "3.27 dB", "0.132914", "3.27 dB", "0.132914", false),
+ Entry("correctly parses wma/asf tags", "test.wma", "1.02s", 1, 44100, 16, "3.27 dB", "0.132914", "3.27 dB", "0.132914", false, true),
// ffmpeg -f lavfi -i "sine=frequency=800:duration=1" test.wv
- Entry("correctly parses wv (wavpak) tags", "test.wv", "1s", 1, 44100, 16, "3.43 dB", "0.125061", "3.43 dB", "0.125061", false),
+ Entry("correctly parses wv (wavpak) tags", "test.wv", "1s", 1, 44100, 16, "3.43 dB", "0.125061", "3.43 dB", "0.125061", false, false),
// ffmpeg -f lavfi -i "sine=frequency=1000:duration=1" test.wav
- Entry("correctly parses wav tags", "test.wav", "1s", 1, 44100, 16, "3.06 dB", "0.125056", "3.06 dB", "0.125056", true),
+ Entry("correctly parses wav tags", "test.wav", "1s", 1, 44100, 16, "3.06 dB", "0.125056", "3.06 dB", "0.125056", true, true),
// ffmpeg -f lavfi -i "sine=frequency=1400:duration=1" test.aiff
- Entry("correctly parses aiff tags", "test.aiff", "1s", 1, 44100, 16, "2.00 dB", "0.124972", "2.00 dB", "0.124972", true),
+ Entry("correctly parses aiff tags", "test.aiff", "1s", 1, 44100, 16, "2.00 dB", "0.124972", "2.00 dB", "0.124972", true, true),
)
// Skip these tests when running as root
diff --git a/adapters/taglib/taglib_wrapper.cpp b/adapters/taglib/taglib_wrapper.cpp
index 4c5a9fa1e..17c95bfc0 100644
--- a/adapters/taglib/taglib_wrapper.cpp
+++ b/adapters/taglib/taglib_wrapper.cpp
@@ -225,18 +225,25 @@ char has_cover(const TagLib::FileRef f) {
else if (TagLib::Ogg::Opus::File * opusFile{dynamic_cast<TagLib::Ogg::Opus::File *>(f.file())}) {
hasCover = !opusFile->tag()->pictureList().isEmpty();
}
- // ----- WMA
- else if (TagLib::ASF::File * asfFile{dynamic_cast<TagLib::ASF::File *>(f.file())}) {
- const TagLib::ASF::Tag *tag{asfFile->tag()};
- hasCover = tag && tag->attributeListMap().contains("WM/Picture");
- }
// ----- WAV
else if (TagLib::RIFF::WAV::File * wavFile{ dynamic_cast<TagLib::RIFF::WAV::File*>(f.file()) }) {
if (wavFile->hasID3v2Tag()) {
- const auto& frameListMap{ wavFile->ID3v2Tag()->frameListMap() };
- hasCover = !frameListMap["APIC"].isEmpty();
+ const auto& frameListMap{ wavFile->ID3v2Tag()->frameListMap() };
+ hasCover = !frameListMap["APIC"].isEmpty();
+ }
+ }
+ // ----- AIFF
+ else if (TagLib::RIFF::AIFF::File * aiffFile{ dynamic_cast<TagLib::RIFF::AIFF::File *>(f.file())}) {
+ if (aiffFile->hasID3v2Tag()) {
+ const auto& frameListMap{ aiffFile->tag()->frameListMap() };
+ hasCover = !frameListMap["APIC"].isEmpty();
}
}
+ // ----- WMA
+ else if (TagLib::ASF::File * asfFile{dynamic_cast<TagLib::ASF::File *>(f.file())}) {
+ const TagLib::ASF::Tag *tag{ asfFile->tag() };
+ hasCover = tag && asfFile->tag()->attributeListMap().contains("WM/Picture");
+ }
return hasCover;
}
diff --git a/tests/fixtures/01 Invisible (RED) Edit Version.m4a b/tests/fixtures/01 Invisible (RED) Edit Version.m4a
index c461fa0ba..005792eb5 100644
Binary files a/tests/fixtures/01 Invisible (RED) Edit Version.m4a and b/tests/fixtures/01 Invisible (RED) Edit Version.m4a differ
diff --git a/tests/fixtures/test.aiff b/tests/fixtures/test.aiff
index 6241ecd22..1435115d9 100644
Binary files a/tests/fixtures/test.aiff and b/tests/fixtures/test.aiff differ
diff --git a/tests/fixtures/test.flac b/tests/fixtures/test.flac
index 52af8a86d..6c1270fd5 100644
Binary files a/tests/fixtures/test.flac and b/tests/fixtures/test.flac differ
diff --git a/tests/fixtures/test.m4a b/tests/fixtures/test.m4a
index 8dbed0ebc..c469dd9e4 100644
Binary files a/tests/fixtures/test.m4a and b/tests/fixtures/test.m4a differ
diff --git a/tests/fixtures/test.mp3 b/tests/fixtures/test.mp3
index 7a89f19b6..7333249ad 100644
Binary files a/tests/fixtures/test.mp3 and b/tests/fixtures/test.mp3 differ
diff --git a/tests/fixtures/test.ogg b/tests/fixtures/test.ogg
index 3204d15e9..507da9050 100644
Binary files a/tests/fixtures/test.ogg and b/tests/fixtures/test.ogg differ
diff --git a/tests/fixtures/test.wav b/tests/fixtures/test.wav
index cfe34a04a..155d88bdb 100644
Binary files a/tests/fixtures/test.wav and b/tests/fixtures/test.wav differ
diff --git a/tests/fixtures/test.wma b/tests/fixtures/test.wma
index c8801adcf..2edb7260e 100644
Binary files a/tests/fixtures/test.wma and b/tests/fixtures/test.wma differ
diff --git a/tests/fixtures/test.wv b/tests/fixtures/test.wv
index 7ac544be1..3722d28a2 100644
Binary files a/tests/fixtures/test.wv and b/tests/fixtures/test.wv differ