Skip to content

Commit

Permalink
changed error msgs
Browse files Browse the repository at this point in the history
  • Loading branch information
LumePart committed Jan 12, 2025
1 parent 629a49c commit c5fb463
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/jellyfin.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,20 @@ func jfAllPaths(cfg Config) (Paths, error) {

body, err := makeRequest("GET", cfg.URL+params, nil, cfg.Creds.Headers)
if err != nil {
return nil, fmt.Errorf("jfAllPaths: %s", err.Error())
return nil, fmt.Errorf("jfAllPaths(): %s", err.Error())
}

var paths Paths
if err = parseResp(body, &paths); err != nil {
return nil, fmt.Errorf("jfAllPaths: %s", err.Error())
return nil, fmt.Errorf("jfAllPaths(): %s", err.Error())
}
return paths, nil
}

func (cfg *Config) getJfPath() { // Gets Librarys ID
paths, err := jfAllPaths(*cfg)
if err != nil {
log.Fatalf("failed to get Jellyfin paths: %s", err.Error())
log.Fatalf("getJfPath(): %s", err.Error())
}

for _, path := range paths {
Expand All @@ -99,15 +99,15 @@ func jfAddPath(cfg Config) { // adds Jellyfin library, if not set
body, err := makeRequest("POST", cfg.URL+params, bytes.NewReader(payload), cfg.Creds.Headers)
if err != nil {
debug.Debug(fmt.Sprintf("response: %s", body))
log.Fatalf("failed to add path to Jellyfin: %s", err.Error())
log.Fatalf("failed to add library to Jellyfin using the download path, please define a library name using LIBRARY_NAME in .env: %s", err.Error())
}
}

func refreshJfLibrary(cfg Config) error {
params := fmt.Sprintf("/Items/%s/Refresh", cfg.Jellyfin.LibraryID)

if _, err := makeRequest("POST", cfg.URL+params, nil, cfg.Creds.Headers); err != nil {
return fmt.Errorf("failed to refresh library: %s", err.Error())
return fmt.Errorf("refreshJfLibrary(): %s", err.Error())
}
return nil
}
Expand All @@ -117,7 +117,7 @@ func getJfSong(cfg Config, track Track) (string, error) { // Gets all files in E

body, err := makeRequest("GET", cfg.URL+params, nil, cfg.Creds.Headers)
if err != nil {
return "", fmt.Errorf("failed to find song: %s", err.Error())
return "", fmt.Errorf("getJfSong(): %s", err.Error())
}

var results Audios
Expand All @@ -138,7 +138,7 @@ func findJfPlaylist(cfg Config) (string, error) {

body, err := makeRequest("GET", cfg.URL+params, nil, cfg.Creds.Headers)
if err != nil {
return "", fmt.Errorf("failed to find playlist: %s", err.Error())
return "", fmt.Errorf("findJfPlaylist(): %s", err.Error())
}

var results Search
Expand Down Expand Up @@ -218,7 +218,7 @@ func deleteJfPlaylist(cfg Config, ID string) error {
params := fmt.Sprintf("/Items/%s", ID)

if _, err := makeRequest("DELETE", cfg.URL+params, nil, cfg.Creds.Headers); err != nil {
return fmt.Errorf("failed to delete playlist: %s", err.Error())
return fmt.Errorf("deleyeJfPlaylist(): %s", err.Error())
}
return nil
}

0 comments on commit c5fb463

Please sign in to comment.