handle -P param

This commit is contained in:
2024-01-26 11:33:22 +01:00
parent c78b3ae174
commit 15766bd016
2 changed files with 14 additions and 6 deletions

View File

@@ -91,16 +91,22 @@ func (p *Process) Start() {
buildFilename(&p.Output)
params := append([]string{
params := []string{
strings.Split(p.Url, "?list")[0], //no playlist
"--newline",
"--no-colors",
"--no-playlist",
"--progress-template",
strings.NewReplacer("\n", "", "\t", "", " ", "").Replace(template),
"-o",
fmt.Sprintf("%s/%s", out.Path, out.Filename),
}, p.Params...)
}
// if user asked to manually override the output path...
if !slices.Includes(params, "-P") {
params = append(params, "-o")
params = append(params, fmt.Sprintf("%s/%s", out.Path, out.Filename))
}
params = append(params, p.Params...)
// ----------------- main block ----------------- //
cmd := exec.Command(config.Instance().DownloaderPath, params...)

View File

@@ -15,7 +15,6 @@ import (
"time"
"github.com/go-chi/chi/v5"
"github.com/go-chi/chi/v5/middleware"
"github.com/go-chi/cors"
"github.com/marcopeocchi/yt-dlp-web-ui/server/config"
"github.com/marcopeocchi/yt-dlp-web-ui/server/dbutils"
@@ -77,6 +76,8 @@ func RunBlocking(host string, port int, frontend fs.FS, dbPath string) {
go gracefulShutdown(srv, &mdb)
go autoPersist(time.Minute*5, &mdb, logger)
logger.Info("yt-dlp-webui started", slog.Int("port", port))
if err := srv.ListenAndServe(); err != nil {
logger.Warn("http server stopped", slog.String("err", err.Error()))
}
@@ -103,7 +104,8 @@ func newServer(c serverConfig) *http.Server {
})
r.Use(corsMiddleware.Handler)
r.Use(middleware.Logger)
// use in dev
// r.Use(middleware.Logger)
r.Mount("/", http.FileServer(http.FS(c.frontend)))