mirror of
https://github.com/Superredstone/spotiflac-cli.git
synced 2026-03-07 20:18:07 +01:00
feat: add --stop-on-fail flag
This commit is contained in:
@@ -6,6 +6,7 @@ type App struct {
|
|||||||
SpotifyClient *SpotifyClient
|
SpotifyClient *SpotifyClient
|
||||||
ApiInterval int // How many ms to wait between one call to apis and the other
|
ApiInterval int // How many ms to wait between one call to apis and the other
|
||||||
NoFallback bool
|
NoFallback bool
|
||||||
|
StopOnFail bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewApp() App {
|
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)
|
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 err := app.DownloadTrack(url, outputFile+"/", service, quality, true, metadata); err != nil {
|
||||||
|
if app.StopOnFail {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
app.log("Failed download")
|
||||||
|
}
|
||||||
|
|
||||||
// Avoid getting rate limited
|
// Avoid getting rate limited
|
||||||
time.Sleep(time.Duration(app.ApiInterval) * time.Millisecond)
|
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),
|
DefaultText: strconv.FormatBool(app.NoFallback),
|
||||||
Destination: &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 {
|
Action: func(ctx context.Context, cmd *cli.Command) error {
|
||||||
song_url := cmd.Args().First()
|
song_url := cmd.Args().First()
|
||||||
|
|||||||
Reference in New Issue
Block a user