From c46538a55ff4de5d4141ca136e83e7bc9c06b1d3 Mon Sep 17 00:00:00 2001 From: Joren Date: Mon, 7 Oct 2024 12:46:26 +0200 Subject: [PATCH] Change the config paths according to new layout --- src/downloaders.go | 8 ++++---- src/handlers.go | 6 +++--- src/main.go | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/downloaders.go b/src/downloaders.go index c027fb7..21f7f84 100644 --- a/src/downloaders.go +++ b/src/downloaders.go @@ -23,7 +23,7 @@ func removeBOM(input []byte) []byte { func downloadFile(drmdFilename string, item Item, jobInfo *JobInfo) error { logger.LogInfo("Download File", fmt.Sprintf("Starting download for: %s", item.Filename)) - tempDir := filepath.Join(config.TempBaseDir, sanitizeFilename(item.Filename)) + tempDir := filepath.Join(config.General.TempBaseDir, sanitizeFilename(item.Filename)) err := os.MkdirAll(tempDir, 0755) if err != nil { logger.LogError("Download File", fmt.Sprintf("Error creating temporary directory: %v", err)) @@ -132,7 +132,7 @@ func downloadFile(drmdFilename string, item Item, jobInfo *JobInfo) error { for { if outputBuffer.Len() > 0 { message := outputBuffer.Bytes() - if config.EnableConsole { + if config.General.EnableConsole { broadcast(drmdFilename, message) } outputBuffer.Reset() @@ -183,9 +183,9 @@ func getDownloadCommand(item Item, mpdPath string, tempDir string) string { filename := fmt.Sprintf("\"%s\"", sanitizedFilename) command += fmt.Sprintf(" --save-name %s", filename) - command += fmt.Sprintf(" --mux-after-done format=%s", config.Format) + command += fmt.Sprintf(" --mux-after-done format=%s", config.General.Format) - saveDir := config.BaseDir + saveDir := config.General.BaseDir if metadata.Type == "serie" { saveDir = filepath.Join(saveDir, "Series", metadata.Title, metadata.Season) } else { diff --git a/src/handlers.go b/src/handlers.go index 309c4ae..de5889e 100644 --- a/src/handlers.go +++ b/src/handlers.go @@ -386,8 +386,8 @@ var clients = make(map[string]map[*websocket.Conn]bool) var mu sync.Mutex func handleWebSocket(w http.ResponseWriter, r *http.Request) { - fmt.Println(config.EnableConsole) - if !config.EnableConsole { + fmt.Println(config.General.EnableConsole) + if !config.General.EnableConsole { http.Error(w, "Console output is disabled", http.StatusForbidden) return } @@ -428,7 +428,7 @@ func handleWebSocket(w http.ResponseWriter, r *http.Request) { } func broadcast(filename string, message []byte) { - if !config.EnableConsole { + if !config.General.EnableConsole { return } diff --git a/src/main.go b/src/main.go index 6089f4d..c24ed9d 100644 --- a/src/main.go +++ b/src/main.go @@ -84,7 +84,7 @@ func startWebServer() { http.HandleFunc("/clear-completed", handleClearCompleted) http.HandleFunc("/ws", handleWebSocket) - fmt.Println("Starting web server on http://0.0.0.0:8080") + logger.LogInfo("Main", "Starting web server on http://0.0.0.0:8080") http.ListenAndServe(":8080", nil) }