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
+21 -3
View File
@@ -2,7 +2,9 @@ package deezer
import (
"encoding/json"
"fmt"
"path"
"time"
"github.com/flytam/filenamify"
)
@@ -10,9 +12,10 @@ import (
type Playlist struct {
Results struct {
Data struct {
Title string `json:"TITLE"`
Status int `json:"STATUS"`
CollabKey string `json:"COLLAB_KEY"`
Title string `json:"TITLE"`
Status int `json:"STATUS"`
Creator string `json:"PARENT_USERNAME"`
Duration int `json:"DURATION"`
} `json:"DATA"`
Songs struct {
Data []*Song `json:"data"`
@@ -20,6 +23,21 @@ type Playlist struct {
} `json:"results"`
}
func (p *Playlist) String() string {
return fmt.Sprintf(
`=============== [ Playlist Info ] ===============
Title: %s
Creator: %s
Tracks: %d
Duration: %s
=================================================`,
p.Results.Data.Title,
p.Results.Data.Creator,
len(p.Results.Songs.Data),
time.Duration(p.Results.Data.Duration)*time.Second,
)
}
func (p *Playlist) GetType() string {
return "Playlist"
}