diff --git a/Selector.CLI/DbWatcherService.cs b/Selector.CLI/DbWatcherService.cs index e34ffbc..f9ecba6 100644 --- a/Selector.CLI/DbWatcherService.cs +++ b/Selector.CLI/DbWatcherService.cs @@ -83,7 +83,9 @@ namespace Selector.CLI var indices = new HashSet(); - foreach (var dbWatcher in db.Watcher.Include(w => w.User)) + foreach (var dbWatcher in db.Watcher + .Include(w => w.User) + .Where(w => !string.IsNullOrWhiteSpace(w.User.SpotifyRefreshToken))) { Logger.LogInformation($"Creating new [{dbWatcher.Type}] watcher"); diff --git a/Selector.CLI/Program.cs b/Selector.CLI/Program.cs index f580305..01d4c8f 100644 --- a/Selector.CLI/Program.cs +++ b/Selector.CLI/Program.cs @@ -26,8 +26,7 @@ namespace Selector.CLI } }; - var host = CreateHostBuilder(args, ConfigureDefault, ConfigureDefaultNlog); - await host.RunConsoleAsync(); + CreateHostBuilder(args, ConfigureDefault, ConfigureDefaultNlog).Build().Run(); } public static RootOptions ConfigureOptions(HostBuilderContext context, IServiceCollection services) diff --git a/Selector/Watcher/PlayerWatcher.cs b/Selector/Watcher/PlayerWatcher.cs index b613e73..02d0ae9 100644 --- a/Selector/Watcher/PlayerWatcher.cs +++ b/Selector/Watcher/PlayerWatcher.cs @@ -130,6 +130,14 @@ namespace Selector OnItemChange(GetEvent()); } } + else if (Previous.Item is null) + { + Logger.LogWarning($"Previous item was null [{Previous.DisplayString()}]"); + } + else if (Live.Item is null) + { + Logger.LogWarning($"Live item was null [{Live.DisplayString()}]"); + } else { Logger.LogError($"Unknown combination of previous and current playing contexts, [{Previous.DisplayString()}] [{Live.DisplayString()}]"); throw new NotSupportedException("Unknown item combination");