mirror of
https://github.com/Superredstone/spotiflac-cli.git
synced 2026-03-07 20:18:07 +01:00
feat: add output folder flag
This commit is contained in:
11
main.go
11
main.go
@@ -11,7 +11,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
var song_url string
|
var song_url, output_folder string
|
||||||
|
|
||||||
application := app.NewApp()
|
application := app.NewApp()
|
||||||
|
|
||||||
cmd := &cli.Command{
|
cmd := &cli.Command{
|
||||||
@@ -23,9 +24,15 @@ func main() {
|
|||||||
Usage: "Download a song/playlist",
|
Usage: "Download a song/playlist",
|
||||||
Destination: &song_url,
|
Destination: &song_url,
|
||||||
},
|
},
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "output",
|
||||||
|
Aliases: []string{"o"},
|
||||||
|
Usage: "Set output folder",
|
||||||
|
Destination: &output_folder,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Action: func(ctx context.Context, cmd *cli.Command) error {
|
Action: func(ctx context.Context, cmd *cli.Command) error {
|
||||||
err := pkg.Download(application, song_url)
|
err := pkg.Download(application, song_url, output_folder)
|
||||||
return err
|
return err
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,11 @@ type MetadataPlaylist struct {
|
|||||||
TrackList []MetadataTrack `json:"track_list"`
|
TrackList []MetadataTrack `json:"track_list"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func Download(application *app.App, url string) error {
|
func Download(application *app.App, url string, output_folder string) error {
|
||||||
|
if output_folder == "" {
|
||||||
|
output_folder = DEFAULT_DOWNLOAD_OUTPUT_FOLDER
|
||||||
|
}
|
||||||
|
|
||||||
if strings.Contains(url, "https://open.spotify.com/track") {
|
if strings.Contains(url, "https://open.spotify.com/track") {
|
||||||
metadata, err := GetMetadata[MetadataSong](application, url)
|
metadata, err := GetMetadata[MetadataSong](application, url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -59,7 +63,7 @@ func Download(application *app.App, url string) error {
|
|||||||
AlbumArtist: track.AlbumArtist,
|
AlbumArtist: track.AlbumArtist,
|
||||||
ReleaseDate: track.ReleaseDate,
|
ReleaseDate: track.ReleaseDate,
|
||||||
CoverURL: track.Images,
|
CoverURL: track.Images,
|
||||||
OutputDir: DEFAULT_DOWNLOAD_OUTPUT_FOLDER,
|
OutputDir: output_folder,
|
||||||
SpotifyID: track.SpotifyID,
|
SpotifyID: track.SpotifyID,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,7 +88,7 @@ func Download(application *app.App, url string) error {
|
|||||||
AlbumArtist: track.AlbumArtist,
|
AlbumArtist: track.AlbumArtist,
|
||||||
ReleaseDate: track.ReleaseDate,
|
ReleaseDate: track.ReleaseDate,
|
||||||
CoverURL: track.Images,
|
CoverURL: track.Images,
|
||||||
OutputDir: DEFAULT_DOWNLOAD_OUTPUT_FOLDER,
|
OutputDir: output_folder,
|
||||||
SpotifyID: track.SpotifyID,
|
SpotifyID: track.SpotifyID,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user