mirror of
https://github.com/Superredstone/spotiflac-cli.git
synced 2026-03-08 04:28:07 +01:00
feat: add --stop-on-fail flag
This commit is contained in:
@@ -6,6 +6,7 @@ type App struct {
|
||||
SpotifyClient *SpotifyClient
|
||||
ApiInterval int // How many ms to wait between one call to apis and the other
|
||||
NoFallback bool
|
||||
StopOnFail bool
|
||||
}
|
||||
|
||||
func NewApp() App {
|
||||
|
||||
@@ -100,9 +100,13 @@ func (app *App) DownloadPlaylist(url string, outputFile string, service string,
|
||||
fmt.Println("[" + strconv.Itoa(idx+1) + "/" + strconv.Itoa(trackListSize) + "] " + metadata.Data.TrackUnion.Name + " - " + artists)
|
||||
|
||||
if err := app.DownloadTrack(url, outputFile+"/", service, quality, true, metadata); err != nil {
|
||||
if app.StopOnFail {
|
||||
return err
|
||||
}
|
||||
|
||||
app.log("Failed download")
|
||||
}
|
||||
|
||||
// Avoid getting rate limited
|
||||
time.Sleep(time.Duration(app.ApiInterval) * time.Millisecond)
|
||||
}
|
||||
|
||||
6
main.go
6
main.go
@@ -57,6 +57,12 @@ func main() {
|
||||
DefaultText: strconv.FormatBool(app.NoFallback),
|
||||
Destination: &app.NoFallback,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "stop-on-fail",
|
||||
Usage: "continue on download failure",
|
||||
DefaultText: strconv.FormatBool(app.StopOnFail),
|
||||
Destination: &app.StopOnFail,
|
||||
},
|
||||
},
|
||||
Action: func(ctx context.Context, cmd *cli.Command) error {
|
||||
song_url := cmd.Args().First()
|
||||
|
||||
Reference in New Issue
Block a user