97 custom arguments broken (#99)

* golang debug

* handle template in playlist download

* code refactoring, dropped goccy go json
This commit is contained in:
Marco
2023-10-22 15:54:08 +02:00
committed by GitHub
parent 8eb2831bc6
commit ba23485b33
13 changed files with 60 additions and 48 deletions

View File

@@ -7,7 +7,7 @@ type DownloadProgress struct {
Status int `json:"process_status"`
Percentage string `json:"percentage"`
Speed float32 `json:"speed"`
ETA int `json:"eta"`
ETA float32 `json:"eta"`
}
// Used to deser the yt-dlp -J output
@@ -50,6 +50,8 @@ type ProcessResponse struct {
Id string `json:"id"`
Progress DownloadProgress `json:"progress"`
Info DownloadInfo `json:"info"`
Output DownloadOutput `json:"output"`
Params []string `json:"params"`
}
// struct representing the current status of the memoryDB

View File

@@ -85,6 +85,8 @@ func (m *MemoryDB) All() *[]ProcessResponse {
Id: key.(string),
Info: value.(*Process).Info,
Progress: value.(*Process).Progress,
Output: value.(*Process).Output,
Params: value.(*Process).Params,
})
return true
})
@@ -137,6 +139,8 @@ func (m *MemoryDB) Restore() {
Url: proc.Info.URL,
Info: proc.Info,
Progress: proc.Progress,
Output: proc.Output,
Params: proc.Params,
}
m.table.Store(proc.Id, restored)

View File

@@ -1,12 +1,12 @@
package internal
import (
"encoding/json"
"errors"
"log"
"os/exec"
"time"
"github.com/goccy/go-json"
"github.com/marcopeocchi/yt-dlp-web-ui/server/cli"
"github.com/marcopeocchi/yt-dlp-web-ui/server/config"
)
@@ -60,9 +60,11 @@ func PlaylistDetect(req DownloadRequest, mq *MessageQueue, db *MemoryDB) error {
proc := &Process{
Url: meta.OriginalURL,
Progress: DownloadProgress{},
Output: DownloadOutput{},
Info: meta,
Params: req.Params,
Output: DownloadOutput{
Filename: req.Rename,
},
Info: meta,
Params: req.Params,
}
proc.Info.URL = meta.OriginalURL

View File

@@ -2,13 +2,12 @@ package internal
import (
"bufio"
"encoding/json"
"fmt"
"regexp"
"sync"
"syscall"
"github.com/goccy/go-json"
"log"
"os"
"os/exec"
@@ -38,7 +37,7 @@ type ProgressTemplate struct {
Percentage string `json:"percentage"`
Speed float32 `json:"speed"`
Size string `json:"size"`
Eta int `json:"eta"`
Eta float32 `json:"eta"`
}
// Process descriptor
@@ -70,6 +69,10 @@ func (p *Process) Start() {
return !match
})
p.Params = slices.Filter(p.Params, func(e string) bool {
return e != ""
})
out := DownloadOutput{
Path: config.Instance().GetConfig().DownloadPath,
Filename: "%(title)s.%(ext)s",
@@ -87,7 +90,8 @@ func (p *Process) Start() {
"--newline",
"--no-colors",
"--no-playlist",
"--progress-template", strings.ReplaceAll(template, "\n", ""),
"--progress-template",
strings.NewReplacer("\n", "", "\t", "", " ", "").Replace(template),
"-o",
fmt.Sprintf("%s/%s", out.Path, out.Filename),
}, p.Params...)