config package refactor

This commit is contained in:
2023-10-24 16:07:38 +02:00
parent 0c7415df28
commit b512e996ad
11 changed files with 33 additions and 73 deletions

View File

@@ -98,7 +98,7 @@ func (m *MemoryDB) Persist() {
running := m.All()
sessionFile := filepath.Join(
config.Instance().GetConfig().SessionFilePath,
config.Instance().SessionFilePath,
"session.dat",
)

View File

@@ -16,7 +16,7 @@ type MessageQueue struct {
// CPU cores.
// The queue size can be set via the qs flag.
func NewMessageQueue() *MessageQueue {
size := config.Instance().GetConfig().QueueSize
size := config.Instance().QueueSize
if size <= 0 {
log.Fatalln("invalid queue size")

View File

@@ -19,7 +19,7 @@ type metadata struct {
func PlaylistDetect(req DownloadRequest, mq *MessageQueue, db *MemoryDB) error {
var (
downloader = config.Instance().GetConfig().DownloaderPath
downloader = config.Instance().DownloaderPath
cmd = exec.Command(downloader, req.URL, "-J")
)

View File

@@ -74,7 +74,7 @@ func (p *Process) Start() {
})
out := DownloadOutput{
Path: config.Instance().GetConfig().DownloadPath,
Path: config.Instance().DownloadPath,
Filename: "%(title)s.%(ext)s",
}
@@ -97,7 +97,7 @@ func (p *Process) Start() {
}, p.Params...)
// ----------------- main block ----------------- //
cmd := exec.Command(config.Instance().GetConfig().DownloaderPath, params...)
cmd := exec.Command(config.Instance().DownloaderPath, params...)
cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
r, err := cmd.StdoutPipe()
@@ -192,7 +192,7 @@ func (p *Process) Kill() error {
// Returns the available format for this URL
func (p *Process) GetFormatsSync() (DownloadFormats, error) {
cmd := exec.Command(config.Instance().GetConfig().DownloaderPath, p.Url, "-J")
cmd := exec.Command(config.Instance().DownloaderPath, p.Url, "-J")
stdout, err := cmd.Output()
if err != nil {
@@ -245,7 +245,7 @@ func (p *Process) SetPending() {
}
func (p *Process) SetMetadata() error {
cmd := exec.Command(config.Instance().GetConfig().DownloaderPath, p.Url, "-J")
cmd := exec.Command(config.Instance().DownloaderPath, p.Url, "-J")
cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
stdout, err := cmd.StdoutPipe()