From dc579f508b6b179acc9ce2abf63ff50ac55fa69f Mon Sep 17 00:00:00 2001 From: yabobay <122279668+yabobay@users.noreply.github.com> Date: Sun, 14 Apr 2024 02:08:47 +0300 Subject: [PATCH] Fallback to year field for ogg files when date not present (#105) * Recognise year field for ogg files when present * prioritize 'date' over 'year' tag on ogg files --- vorbis.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/vorbis.go b/vorbis.go index 84332af..f1c6a19 100644 --- a/vorbis.go +++ b/vorbis.go @@ -216,6 +216,13 @@ func (m *metadataVorbis) Year() int { // and obviously the VorbisComment standard https://wiki.xiph.org/VorbisComment#Date_and_time switch len(m.c["date"]) { case 0: + // Fallback on year tag as some files use that. + if len(m.c["year"]) != 0 { + year, err := strconv.Atoi(m.c["year"]) + if err == nil { + return year + } + } return 0 case 4: dateFormat = "2006"