diff --git a/internal/music/api_spotify.go b/internal/music/api_spotify.go index cd74a98..0e301f5 100644 --- a/internal/music/api_spotify.go +++ b/internal/music/api_spotify.go @@ -102,8 +102,8 @@ func SearchAlbumByTitle(title string, album *Album) error { album.Artist = track["artists"].([]interface{})[0].(map[string]interface{})["name"].(string) album.ID = albumData["id"].(string) album.Album = albumData["name"].(string) - album.Date = albumData["release_date"].(string) - album.Year, _ = strconv.Atoi(strings.Split(album.Date, "-")[0]) + album.ReleaseDate = albumData["release_date"].(string) + album.Year, _ = strconv.Atoi(strings.Split(album.ReleaseDate, "-")[0]) album.Subtitle = strconv.Itoa(album.Year) album.Tracks = int(albumData["total_tracks"].(float64)) // Spotify envía números como float64 album.Link = albumData["href"].(string) diff --git a/internal/music/controller.go b/internal/music/controller.go index b2237c5..e107a1c 100644 --- a/internal/music/controller.go +++ b/internal/music/controller.go @@ -90,16 +90,17 @@ func generateAlbumMarkdown(album Album) error { outputPath := filepath.Join(outputDir, fmt.Sprintf("%s.md", album.Slug)) data := map[string]interface{}{ - "Title": album.Title, - "Artist": album.Artist, - "Link": album.Link, - "Subtitle": album.Year, - "Year": album.Year, - "Rate": album.Rate, - "Tracks": album.Tracks, - "Image": album.Image, - "Date": album.Date, - "Tags": "listening", + "Title": album.Title, + "Artist": album.Artist, + "Link": album.Link, + "Subtitle": album.Year, + "Year": album.Year, + "Rate": album.Rate, + "Tracks": album.Tracks, + "Image": album.Image, + "Date": album.Date, + "ReleaseDate": album.ReleaseDate, + "Tags": "listening", } return utils.GenerateMarkdown(templatePath, outputPath, data) diff --git a/internal/music/model.go b/internal/music/model.go index 84876a5..3cda8bc 100644 --- a/internal/music/model.go +++ b/internal/music/model.go @@ -1,20 +1,21 @@ package music type Album struct { - Title string `yaml:"title"` - Artist string `yaml:"artist"` - Album string `yaml:"album"` - Slug string `yaml:"slug"` - ID string `yaml:"spotify_id"` - Subtitle string `yaml:"subtitle"` - Link string `yaml:"link"` - Year int `yaml:"year"` - Rate float64 `yaml:"rate"` - Tracks int `yaml:"tracks"` - Image string `yaml:"image"` - Date string `yaml:"date"` - New bool `yaml:"new"` - Tags []string + Title string `yaml:"title"` + Artist string `yaml:"artist"` + Album string `yaml:"album"` + Slug string `yaml:"slug"` + ID string `yaml:"spotify_id"` + Subtitle string `yaml:"subtitle"` + Link string `yaml:"link"` + Year int `yaml:"year"` + Rate float64 `yaml:"rate"` + Tracks int `yaml:"tracks"` + Image string `yaml:"image"` + ReleaseDate string `yaml:"release_date"` + Date string `yaml:"date"` + New bool `yaml:"new"` + Tags []string } type Albums []Album diff --git a/templates/music.md.tpl b/templates/music.md.tpl index 3b3fc8c..9008992 100644 --- a/templates/music.md.tpl +++ b/templates/music.md.tpl @@ -11,6 +11,7 @@ image640: {{ imageSize .Image "640" }} image1024: {{ imageSize .Image "1024" }} tracks: {{ .Tracks }} date: {{ .Date }} +release_date: {{ .ReleaseDate }} draft: false tags: {{ .Tags }} ---