mirror of
https://github.com/Superredstone/spotiflac-cli.git
synced 2026-03-07 20:18:07 +01:00
feat: add --interval flag
This commit is contained in:
@@ -5,12 +5,14 @@ type App struct {
|
|||||||
SelectedTidalApiUrl string
|
SelectedTidalApiUrl string
|
||||||
Verbose bool
|
Verbose bool
|
||||||
SpotifyClient *SpotifyClient
|
SpotifyClient *SpotifyClient
|
||||||
|
ApiInterval int // How many ms to wait between one call to apis and the other
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewApp() App {
|
func NewApp() App {
|
||||||
return App{
|
return App{
|
||||||
UserAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36",
|
UserAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36",
|
||||||
Verbose: false,
|
Verbose: false,
|
||||||
|
ApiInterval: 800,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ func (app *App) DownloadPlaylist(url string, outputFile string, service string,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Avoid getting rate limited
|
// Avoid getting rate limited
|
||||||
time.Sleep(800 * time.Millisecond)
|
time.Sleep(time.Duration(app.ApiInterval) * time.Millisecond)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
16
main.go
16
main.go
@@ -4,13 +4,14 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"github.com/Superredstone/spotiflac-cli/lib"
|
"github.com/Superredstone/spotiflac-cli/lib"
|
||||||
"github.com/urfave/cli/v3"
|
"github.com/urfave/cli/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
outputFolder := ""
|
outputFolder := ""
|
||||||
service := ""
|
service := ""
|
||||||
|
|
||||||
app := lib.NewApp()
|
app := lib.NewApp()
|
||||||
@@ -39,6 +40,13 @@ func main() {
|
|||||||
Usage: "set service to tidal/amazon/qobuz (FFmpeg is required for amazon and qobuz)",
|
Usage: "set service to tidal/amazon/qobuz (FFmpeg is required for amazon and qobuz)",
|
||||||
Destination: &service,
|
Destination: &service,
|
||||||
},
|
},
|
||||||
|
&cli.IntFlag{
|
||||||
|
Name: "interval",
|
||||||
|
Aliases: []string{"i"},
|
||||||
|
Usage: "interval between api requests in milliseconds",
|
||||||
|
DefaultText: strconv.Itoa(app.ApiInterval),
|
||||||
|
Destination: &app.ApiInterval,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
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()
|
||||||
@@ -59,9 +67,9 @@ func main() {
|
|||||||
},
|
},
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
Name: "verbose",
|
Name: "verbose",
|
||||||
Aliases: []string{"v"},
|
Aliases: []string{"v"},
|
||||||
Usage: "verbose output",
|
Usage: "verbose output",
|
||||||
Destination: &app.Verbose,
|
Destination: &app.Verbose,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user