From 73719c3abd4ee4c9114bf0f49a8375b9ada7d098 Mon Sep 17 00:00:00 2001 From: Deluan Date: Tue, 20 Dec 2022 16:07:05 -0500 Subject: [PATCH] Fix cover detection on M4A containers --- scanner/metadata/ffmpeg/ffmpeg.go | 2 +- scanner/metadata/ffmpeg/ffmpeg_test.go | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/scanner/metadata/ffmpeg/ffmpeg.go b/scanner/metadata/ffmpeg/ffmpeg.go index c8d47023..4ad768b0 100644 --- a/scanner/metadata/ffmpeg/ffmpeg.go +++ b/scanner/metadata/ffmpeg/ffmpeg.go @@ -77,7 +77,7 @@ var ( audioStreamRx = regexp.MustCompile(`^\s{2,4}Stream #\d+:\d+.*: Audio: (.*), (.* Hz), ([\w\.]+),*(.*.,)*`) // Stream #0:1: Video: mjpeg, yuvj444p(pc, bt470bg/unknown/unknown), 600x600 [SAR 1:1 DAR 1:1], 90k tbr, 90k tbn, 90k tbc` - coverRx = regexp.MustCompile(`^\s{2,4}Stream #\d+:\d+: (Video):.*`) + coverRx = regexp.MustCompile(`^\s{2,4}Stream #\d+:.+: (Video):.*`) ) func (e *Extractor) parseOutput(output string) map[string]string { diff --git a/scanner/metadata/ffmpeg/ffmpeg_test.go b/scanner/metadata/ffmpeg/ffmpeg_test.go index 94ad196c..e4bc96f0 100644 --- a/scanner/metadata/ffmpeg/ffmpeg_test.go +++ b/scanner/metadata/ffmpeg/ffmpeg_test.go @@ -54,7 +54,6 @@ Input #0, mp3, from '/Users/deluan/Music/iTunes/iTunes Media/Music/Compilations/ It("detects embedded cover art in ffmpeg 4.4 output", func() { const output = ` - Input #0, flac, from '/run/media/naomi/Archivio/Musica/Katy Perry/Chained to the Rhythm/01 Katy Perry featuring Skip Marley - Chained to the Rhythm.flac': Metadata: ARTIST : Katy Perry featuring Skip Marley @@ -82,6 +81,22 @@ Input #0, ogg, from '/Users/deluan/Music/iTunes/iTunes Media/Music/_Testes/Jamai Expect(md).To(HaveKey("has_picture")) }) + It("detects embedded cover art in m4a containers", func() { + const output = ` +Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Putumayo Presents_ Euro Groove/01 Destins et Désirs.m4a': + Metadata: + album : Putumayo Presents: Euro Groove + Duration: 00:05:15.81, start: 0.047889, bitrate: 133 kb/s + Stream #0:0[0x1](und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 125 kb/s (default) + Metadata: + creation_time : 2008-03-11T21:03:23.000000Z + vendor_id : [0][0][0][0] + Stream #0:1[0x0]: Video: png, rgb24(pc), 350x350, 90k tbr, 90k tbn (attached pic) +` + md, _ := e.extractMetadata("tests/fixtures/test.mp3", output) + Expect(md).To(HaveKeyWithValue("has_picture", []string{"true"})) + }) + It("gets bitrate from the stream, if available", func() { const output = ` Input #0, mp3, from '/Users/deluan/Music/iTunes/iTunes Media/Music/Compilations/Putumayo Presents Blues Lounge/09 Pablo's Blues.mp3':