id3v2: try to parse the year when 'year' tag could be a date (#104)
Co-authored-by: David Howden <dhowden@gmail.com>
This commit is contained in:
parent
dc579f508b
commit
3d75831295
2
.github/workflows/go.yml
vendored
2
.github/workflows/go.yml
vendored
@ -16,7 +16,7 @@ jobs:
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: 1.18
|
||||
go-version: "1.20"
|
||||
cache: true
|
||||
|
||||
- name: Build
|
||||
|
2
go.mod
2
go.mod
@ -1,6 +1,6 @@
|
||||
module github.com/dhowden/tag
|
||||
|
||||
go 1.18
|
||||
go 1.20
|
||||
|
||||
require github.com/dhowden/itl v0.0.0-20170329215456-9fbe21093131
|
||||
|
||||
|
@ -7,6 +7,7 @@ package tag
|
||||
import (
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
type frameNames map[string][2]string
|
||||
@ -89,8 +90,18 @@ func (m metadataID3v2) Genre() string {
|
||||
}
|
||||
|
||||
func (m metadataID3v2) Year() int {
|
||||
year, _ := strconv.Atoi(m.getString(frames.Name("year", m.Format())))
|
||||
return year
|
||||
stringYear := m.getString(frames.Name("year", m.Format()))
|
||||
|
||||
if year, err := strconv.Atoi(stringYear); err == nil {
|
||||
return year
|
||||
}
|
||||
|
||||
date, err := time.Parse(time.DateOnly, stringYear)
|
||||
if err != nil {
|
||||
return 0
|
||||
}
|
||||
|
||||
return date.Year()
|
||||
}
|
||||
|
||||
func parseXofN(s string) (x, n int) {
|
||||
|
Loading…
Reference in New Issue
Block a user