gspot/src/components/commands/downloadCover.go
2024-02-18 01:30:19 -08:00

24 lines
435 B
Go

package commands
import (
"os"
"path/filepath"
)
func (c *Commander) DownloadCover(path string) error {
destinationPath := filepath.Clean(path)
state, err := c.Client.PlayerState(c.Context)
if err != nil {
return err
}
f, err := os.OpenFile(destinationPath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0755)
if err != nil {
return err
}
err = state.Item.Album.Images[0].Download(f)
if err != nil {
return err
}
return nil
}