fix session file path, code refactoring

This commit is contained in:
2023-09-27 13:08:42 +02:00
parent 75ec95041d
commit fa4ba8a211
2 changed files with 5 additions and 8 deletions

View File

@@ -27,10 +27,6 @@ const template = `download:
"speed":%(progress.speed)s
}`
var (
cfg = config.Instance()
)
const (
StatusPending = iota
StatusDownloading
@@ -75,7 +71,7 @@ func (p *Process) Start() {
})
out := DownloadOutput{
Path: cfg.GetConfig().DownloadPath,
Path: config.Instance().GetConfig().DownloadPath,
Filename: "%(title)s.%(ext)s",
}
@@ -97,7 +93,7 @@ func (p *Process) Start() {
}, p.Params...)
// ----------------- main block ----------------- //
cmd := exec.Command(cfg.GetConfig().DownloaderPath, params...)
cmd := exec.Command(config.Instance().GetConfig().DownloaderPath, params...)
cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
r, err := cmd.StdoutPipe()
@@ -192,7 +188,7 @@ func (p *Process) Kill() error {
// Returns the available format for this URL
func (p *Process) GetFormatsSync() (DownloadFormats, error) {
cmd := exec.Command(cfg.GetConfig().DownloaderPath, p.Url, "-J")
cmd := exec.Command(config.Instance().GetConfig().DownloaderPath, p.Url, "-J")
stdout, err := cmd.Output()
if err != nil {
@@ -245,7 +241,7 @@ func (p *Process) SetPending() {
}
func (p *Process) SetMetadata() error {
cmd := exec.Command(cfg.GetConfig().DownloaderPath, p.Url, "-J")
cmd := exec.Command(config.Instance().GetConfig().DownloaderPath, p.Url, "-J")
cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
stdout, err := cmd.StdoutPipe()