refactor(cli): improve output display

This commit is contained in:
Mathis Maquenne
2025-05-19 13:35:06 +02:00
parent 5d18ab2088
commit 0a9e6c9a4d
6 changed files with 182 additions and 42 deletions
+23
View File
@@ -4,6 +4,8 @@ import (
"encoding/json"
"fmt"
"path"
"strconv"
"time"
"github.com/flytam/filenamify"
)
@@ -17,6 +19,7 @@ type Album struct {
PhysicalReleaseDate string `json:"PHYSICAL_RELEASE_DATE"`
Label string `json:"LABEL_NAME"`
ProducerLine string `json:"PRODUCER_LINE"`
Duration string `json:"DURATION"`
} `json:"DATA"`
Songs struct {
Data []*Song `json:"data"`
@@ -24,6 +27,26 @@ type Album struct {
} `json:"results"`
}
func (a *Album) String() string {
duration, err := strconv.Atoi(a.Results.Data.Duration)
if err != nil {
duration = 0
}
return fmt.Sprintf(
`================= [ Album Info ] =================
Title: %s
Artist: %s
Tracks: %d
Duration: %s
==================================================`,
a.Results.Data.Title,
a.Results.Data.Artist,
len(a.Results.Songs.Data),
time.Duration(duration)*time.Second,
)
}
func (a *Album) GetType() string {
return "Album"
}