Skip to content

Commit

Permalink
chore: simplify logging
Browse files Browse the repository at this point in the history
  • Loading branch information
martinohansen committed Feb 26, 2021
1 parent f6df2f6 commit eead913
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions moverr.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func main() {
os.Exit(1)
}
case "version":
fmt.Println("moverr version 0.3.0")
fmt.Println("moverr version 0.3.1")
os.Exit(0)
default:
flag.Usage()
Expand All @@ -109,13 +109,14 @@ func main() {
movies := radarr.Show(*radarrTag, *radarrConn)

for _, movie := range movies {
log.SetPrefix(movie.Directory)
if *radarrPrefixPath != "" {
movie.Directory = path.Join(*radarrPrefixPath, movie.Directory)
}

movable, err := movie.Movable()
if err != nil {
log.Fatalf("%s failed to check if movable: %s", movie.Directory, err)
log.Fatalf("failed to check if movable: %s", err)
}

switch movable {
Expand All @@ -125,15 +126,15 @@ func main() {
} else {
*radarrSymlinkPath = path.Clean(*radarrSymlinkPath)
}
log.Printf("%s is not moved, moving to: %s and creating symlink to: %s", movie.Directory, *radarrDestination, *radarrSymlinkPath)
log.Printf("is not moved, moving to: %s and creating symlink to: %s", *radarrDestination, *radarrSymlinkPath)
err := show.Move(movie, *radarrDestination, *radarrSymlinkPath)
if err != nil {
log.Fatalf("%s failed to move: %s", movie.Directory, err)
log.Fatalf("failed to move: %s", err)
}
log.Printf("%s finished moving and created symlink", movie.Directory)
log.Printf("finished moving and created symlink")
case false:
if *radarrVerbose {
log.Printf("%s is already moved, skipping...", movie.Directory)
log.Printf("is already moved, skipping...")
}
}
}
Expand All @@ -151,13 +152,14 @@ func main() {
log.Fatalf("failed to any series: %s", err)
}
for _, s := range series {
log.SetPrefix(s.Directory)
if *sonarrPrefixPath != "" {
s.Directory = path.Join(*sonarrPrefixPath, s.Directory)
}

movable, err := s.Movable()
if err != nil {
log.Fatalf("%s, failed to check if movable: %s", s.Directory, err)
log.Fatalf("failed to check if movable: %s", err)
}

switch movable {
Expand All @@ -167,15 +169,15 @@ func main() {
} else {
*sonarrSymlinkPath = path.Clean(*sonarrSymlinkPath)
}
log.Printf("%s is not moved, moving to: %s and creating symlink to: %s", s.Directory, *sonarrDestination, *sonarrSymlinkPath)
log.Printf("is not moved, moving to: %s and creating symlink to: %s", *sonarrDestination, *sonarrSymlinkPath)
err := show.Move(s, *sonarrDestination, *sonarrSymlinkPath)
if err != nil {
log.Fatalf("%s failed to move: %s", s.Directory, err)
log.Fatalf("failed to move: %s", err)
}
log.Printf("%s finished moving and created symlink", s.Directory)
log.Printf("finished moving and created symlink")
case false:
if *sonarrVerbose {
log.Printf("%s is already moved, skipping...", s.Directory)
log.Printf("is already moved, skipping...")
}
}
}
Expand Down

0 comments on commit eead913

Please sign in to comment.