refactor: simplify codebase (-209 lines)

This commit is contained in:
Mathis Maquenne
2026-03-01 21:55:42 +01:00
parent cd45c3f40a
commit 08b608ec80
31 changed files with 389 additions and 598 deletions
+7 -19
View File
@@ -4,9 +4,8 @@ import (
"encoding/json"
"fmt"
"path"
"strconv"
"time"
"github.com/flytam/filenamify"
)
type Track struct {
@@ -20,11 +19,9 @@ func (t *Track) String() string {
return "Track: No data available"
}
duration := "Unknown"
if t.Results.Data.Duration != "" {
if d, err := time.ParseDuration(t.Results.Data.Duration + "s"); err == nil {
duration = d.String()
}
duration, err := strconv.Atoi(t.Results.Data.Duration)
if err != nil {
duration = 0
}
return fmt.Sprintf(
@@ -35,7 +32,7 @@ Duration: %s
==================================================`,
t.Results.Data.GetTitle(),
t.Results.Data.Artist,
duration,
time.Duration(duration)*time.Second,
)
}
@@ -52,7 +49,7 @@ func (t *Track) GetTitle() string {
func (t *Track) GetSongs() []*Song {
if t.Results.Data == nil {
return []*Song{}
return nil
}
return []*Song{t.Results.Data}
}
@@ -60,16 +57,7 @@ func (t *Track) GetSongs() []*Song {
func (t *Track) SetSongs(songs []*Song) {}
func (t *Track) GetOutputDir(outputDir string) string {
if t.Results.Data == nil {
return outputDir
}
// For single tracks, create a simple "Singles" folder
base := "Singles"
base, _ = filenamify.Filenamify(base, filenamify.Options{})
outputDir = path.Join(outputDir, base)
return outputDir
return path.Join(outputDir, "Singles")
}
func (t *Track) Unmarshal(data []byte) error {