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
This commit is contained in:
yabobay 2024-04-14 02:08:47 +03:00 committed by GitHub
parent 713ab0e946
commit dc579f508b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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"