feat: download playlists

This commit is contained in:
Mathis Maquenne
2024-10-14 16:22:44 +02:00
parent cfa53da6ae
commit f247a0f71e
12 changed files with 465 additions and 311 deletions
+16
View File
@@ -15,6 +15,7 @@ type Song struct {
Artist string `json:"ART_NAME"`
Title string `json:"SNG_TITLE"`
Version string `json:"VERSION"`
Cover string `json:"ALB_PICTURE"`
Contributors struct {
MainArtists []string `json:"main_artist"`
Composers []string `json:"composer"`
@@ -70,3 +71,18 @@ func (s *Song) GetMediaData(quality string) (*Media, error) {
return &media, nil
}
func (s *Song) GetCoverImage() ([]byte, error) {
url := fmt.Sprintf("https://e-cdn-images.dzcdn.net/images/cover/%s/500x500-000000-80-0-0.jpg", s.Cover)
resp, err := http.Get(url)
if err != nil {
return nil, err
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("unexpected status code: %d", resp.StatusCode)
}
return io.ReadAll(resp.Body)
}