feat: add --stop-on-fail flag

This commit is contained in:
2026-02-28 16:34:53 +01:00
parent fcae48753b
commit 420429112a
3 changed files with 12 additions and 1 deletions

View File

@@ -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 {

View File

@@ -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)
} }

View File

@@ -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()