fix session file path, code refactoring
This commit is contained in:
1
main.go
1
main.go
@@ -63,6 +63,7 @@ func main() {
|
||||
c.QueueSize(queueSize)
|
||||
c.DownloadPath(downloadPath)
|
||||
c.DownloaderPath(downloaderPath)
|
||||
c.SessionFilePath(sessionFilePath)
|
||||
|
||||
c.RequireAuth(requireAuth)
|
||||
c.Username(username)
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user