feat: update download cmd to use new functions
This commit is contained in:
+32
-4
@@ -1,12 +1,40 @@
|
||||
package cmd
|
||||
|
||||
import "github.com/spf13/cobra"
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/mathismqn/godeez/internal/album"
|
||||
"github.com/mathismqn/godeez/internal/song"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var downloadCmd = &cobra.Command{
|
||||
Use: "download [ID]",
|
||||
Short: "Download a track from Deezer",
|
||||
Use: "download [album_id...]",
|
||||
Short: "Download songs from one or more albums",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
// Your code here
|
||||
if len(args) == 0 {
|
||||
cmd.Help()
|
||||
return
|
||||
}
|
||||
|
||||
for _, id := range args {
|
||||
albumData, err := album.GetDataByID(id)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "could not fetch album data: %v\n", err)
|
||||
continue
|
||||
}
|
||||
|
||||
for _, s := range albumData.Songs.Data {
|
||||
media, err := song.GetMedia(s)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "could not fetch media data: %v\n", err)
|
||||
continue
|
||||
}
|
||||
|
||||
fmt.Println(media)
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user