feat(media): download and decrypt media

This commit is contained in:
Mathis Maquenne
2024-10-14 16:21:21 +02:00
parent 142dcfa30a
commit b700b6483c
6 changed files with 137 additions and 4 deletions
+15 -2
View File
@@ -27,11 +27,24 @@ var downloadCmd = &cobra.Command{
for _, song := range album.Songs.Data {
media, err := song.GetMediaData()
if err != nil {
fmt.Fprintf(os.Stderr, "could not fetch media data: %v\n", err)
fmt.Fprintf(os.Stderr, "could not get media data: %v\n", err)
if err.Error() == "invalid license token" {
os.Exit(1)
}
continue
}
fmt.Println(media)
songTitle := song.Title
if song.Version != "" {
songTitle = fmt.Sprintf("%s %s", song.Title, song.Version)
}
filename := fmt.Sprintf("%s - %s.flac", song.ArtistName, songTitle)
err = media.Download(filename, song.ID)
if err != nil {
fmt.Fprintf(os.Stderr, "could not download song: %v\n", err)
continue
}
}
}
},