refactor: use a better API to download playlists with more than 40 tracks
This commit is contained in:
+16
-14
@@ -8,18 +8,20 @@ import (
|
||||
)
|
||||
|
||||
type Playlist struct {
|
||||
Data struct {
|
||||
Title string `json:"TITLE"`
|
||||
Status int `json:"STATUS"`
|
||||
CollabKey string `json:"COLLAB_KEY"`
|
||||
} `json:"DATA"`
|
||||
Songs struct {
|
||||
Data []*Song `json:"data"`
|
||||
} `json:"SONGS"`
|
||||
Results struct {
|
||||
Data struct {
|
||||
Title string `json:"TITLE"`
|
||||
Status int `json:"STATUS"`
|
||||
CollabKey string `json:"COLLAB_KEY"`
|
||||
} `json:"DATA"`
|
||||
Songs struct {
|
||||
Data []*Song `json:"data"`
|
||||
} `json:"SONGS"`
|
||||
} `json:"results"`
|
||||
}
|
||||
|
||||
func (p *Playlist) GetURL(id string) string {
|
||||
return "https://www.deezer.com/en/playlist/" + id
|
||||
func (p *Playlist) GetType() string {
|
||||
return "Playlist"
|
||||
}
|
||||
|
||||
func (p *Playlist) UnmarshalData(data []byte) error {
|
||||
@@ -27,17 +29,17 @@ func (p *Playlist) UnmarshalData(data []byte) error {
|
||||
}
|
||||
|
||||
func (p *Playlist) GetSongs() []*Song {
|
||||
return p.Songs.Data
|
||||
return p.Results.Songs.Data
|
||||
}
|
||||
|
||||
func (p *Playlist) GetOutputPath(outputDir string) string {
|
||||
p.Data.Title, _ = filenamify.Filenamify(p.Data.Title, filenamify.Options{})
|
||||
outputPath := path.Join(outputDir, p.Data.Title)
|
||||
p.Results.Data.Title, _ = filenamify.Filenamify(p.Results.Data.Title, filenamify.Options{})
|
||||
outputPath := path.Join(outputDir, p.Results.Data.Title)
|
||||
outputPath, _ = filenamify.Filenamify(outputPath, filenamify.Options{})
|
||||
|
||||
return outputPath
|
||||
}
|
||||
|
||||
func (p *Playlist) GetTitle() string {
|
||||
return p.Data.Title
|
||||
return p.Results.Data.Title
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user