@@ -2,7 +2,6 @@ package main
22
33import (
44 "explo/src/logging"
5- "fmt"
65 "log"
76 "log/slog"
87 "os"
@@ -29,7 +28,8 @@ func initHttpClient() *util.HttpClient {
2928// Inits debug, gets playlist name, if needed, handles deprecation
3029func setup (cfg * config.Config ) {
3130 cfg .HandleDeprecation ()
32- logging .Init (cfg .LogLevel )
31+ notifyClient := logging .InitNotify (cfg .NotifyCfg )
32+ logging .Init (cfg .LogLevel , notifyClient )
3333 cfg .GenPlaylistName ()
3434}
3535
@@ -44,25 +44,21 @@ func main() {
4444 slog .Info ("Starting Explo..." )
4545
4646 httpClient := initHttpClient ()
47- notifyClient := logging .InitNotify (cfg .NotifyCfg )
4847 client , err := client .NewClient (& cfg )
4948 if err != nil {
5049 slog .Error (err .Error ())
51- notifyClient .SendNotification (err .Error ())
5250 os .Exit (1 )
5351 }
5452 discovery := discovery .NewDiscoverer (cfg .DiscoveryCfg , httpClient )
5553 downloader , err := downloader .NewDownloader (& cfg .DownloadCfg , httpClient , cfg .Flags .ExcludeLocal )
5654 if err != nil {
5755 slog .Error (err .Error ())
58- notifyClient .SendNotification (err .Error ())
5956 os .Exit (1 )
6057 }
6158
6259 tracks , err := discovery .Discover ()
6360 if err != nil {
6461 slog .Error (err .Error ())
65- notifyClient .SendNotification (err .Error ())
6662 os .Exit (1 )
6763 }
6864 if ! cfg .Persist {
@@ -84,16 +80,13 @@ func main() {
8480 downloader .StartDownload (& tracks )
8581 if len (tracks ) == 0 {
8682 slog .Error ("couldn't download any tracks" )
87- notifyClient .SendNotification ("couldn't download any tracks" )
8883 os .Exit (1 )
8984 }
9085 }
9186
9287 if err := client .CreatePlaylist (tracks ); err != nil {
9388 slog .Warn (err .Error ())
94- notifyClient .SendNotification (err .Error ())
9589 } else {
9690 slog .Info ("playlist created successfully" , "system" , cfg .System , "name" , cfg .ClientCfg .PlaylistName )
97- notifyClient .SendNotification (fmt .Sprintf ("%s playlist created in %s" , cfg .ClientCfg .PlaylistName , cfg .System ))
9891 }
9992}
0 commit comments