From 8fd259abcba7c5773fbda0d409f0831c7b91bb71 Mon Sep 17 00:00:00 2001 From: JorgeLNJunior Date: Fri, 2 Feb 2024 21:33:21 -0300 Subject: [PATCH 1/5] try to parse the year when 'year' tag could be a date --- id3v2metadata.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/id3v2metadata.go b/id3v2metadata.go index 6185963..16e8ac1 100644 --- a/id3v2metadata.go +++ b/id3v2metadata.go @@ -7,6 +7,7 @@ package tag import ( "strconv" "strings" + "time" ) type frameNames map[string][2]string @@ -89,8 +90,19 @@ 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())) + + year, _ := strconv.Atoi(stringYear) + if year != 0 { + return year + } + + date, err := time.Parse(time.DateOnly, stringYear) + if err != nil { + return 0 + } + + return date.Year() } func parseXofN(s string) (x, n int) { From cb29df219d880d78d5c542038a48ec70524da64c Mon Sep 17 00:00:00 2001 From: Jorge Junior Date: Sat, 13 Apr 2024 11:08:17 -0300 Subject: [PATCH 2/5] apply suggestion Co-authored-by: David Howden --- id3v2metadata.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/id3v2metadata.go b/id3v2metadata.go index 16e8ac1..4279f64 100644 --- a/id3v2metadata.go +++ b/id3v2metadata.go @@ -92,8 +92,7 @@ func (m metadataID3v2) Genre() string { func (m metadataID3v2) Year() int { stringYear := m.getString(frames.Name("year", m.Format())) - year, _ := strconv.Atoi(stringYear) - if year != 0 { + if year, err := strconv.Atoi(stringYear); err == nil { return year } From d8b6ebde1167046837d7b39867f2115ea9d42580 Mon Sep 17 00:00:00 2001 From: JorgeLNJunior Date: Sun, 14 Apr 2024 11:45:29 -0300 Subject: [PATCH 3/5] bump the go version --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index d57cf38..e1aa28a 100644 --- a/go.mod +++ b/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 From 218f199a2593205e04b2a57af295c44c9ba5c881 Mon Sep 17 00:00:00 2001 From: JorgeLNJunior Date: Mon, 15 Apr 2024 10:10:01 -0300 Subject: [PATCH 4/5] bump the version in the workflow file --- .github/workflows/go.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index f89f878..e985de9 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -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 From 89fc76d5e102b82c4861ec9a0aff0e3b08a39116 Mon Sep 17 00:00:00 2001 From: JorgeLNJunior Date: Mon, 15 Apr 2024 21:52:11 -0300 Subject: [PATCH 5/5] treat version as a string --- .github/workflows/go.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index e985de9..3788420 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -16,7 +16,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v3 with: - go-version: 1.20 + go-version: "1.20" cache: true - name: Build