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

@@ -63,6 +63,7 @@ func main() {
c.QueueSize(queueSize) c.QueueSize(queueSize)
c.DownloadPath(downloadPath) c.DownloadPath(downloadPath)
c.DownloaderPath(downloaderPath) c.DownloaderPath(downloaderPath)
c.SessionFilePath(sessionFilePath)
c.RequireAuth(requireAuth) c.RequireAuth(requireAuth)
c.Username(username) c.Username(username)

View File

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