diff --git a/Selector.CLI/DbWatcherService.cs b/Selector.CLI/DbWatcherService.cs
index f9ecba6..56c81aa 100644
--- a/Selector.CLI/DbWatcherService.cs
+++ b/Selector.CLI/DbWatcherService.cs
@@ -72,7 +72,7 @@ namespace Selector.CLI
var watcherIndices = await InitInstances();
- Logger.LogInformation($"Starting {watcherIndices.Count()} affected watcher collection(s)...");
+ Logger.LogInformation("Starting {count} affected watcher collection(s)...", watcherIndices.Count());
StartWatcherCollections(watcherIndices);
}
@@ -87,7 +87,7 @@ namespace Selector.CLI
.Include(w => w.User)
.Where(w => !string.IsNullOrWhiteSpace(w.User.SpotifyRefreshToken)))
{
- Logger.LogInformation($"Creating new [{dbWatcher.Type}] watcher");
+ Logger.LogInformation("Creating new [{type}] watcher", dbWatcher.Type);
var watcherCollectionIdx = dbWatcher.UserId;
indices.Add(watcherCollectionIdx);
@@ -118,7 +118,7 @@ namespace Selector.CLI
}
else
{
- Logger.LogDebug($"[{dbWatcher.User.UserName}] No Last.fm username, skipping play counter");
+ Logger.LogDebug("[{username}] No Last.fm username, skipping play counter", dbWatcher.User.UserName);
}
break;
@@ -140,12 +140,12 @@ namespace Selector.CLI
{
try
{
- Logger.LogInformation($"Starting watcher collection [{index}]");
+ Logger.LogInformation("Starting watcher collection [{index}]", index);
Watchers[index].Start();
}
catch (KeyNotFoundException)
{
- Logger.LogError($"Unable to retrieve watcher collection [{index}] when starting");
+ Logger.LogError("Unable to retrieve watcher collection [{index}] when starting", index);
}
}
}
@@ -156,7 +156,7 @@ namespace Selector.CLI
foreach((var key, var watcher) in Watchers)
{
- Logger.LogInformation($"Stopping watcher collection [{key}]");
+ Logger.LogInformation("Stopping watcher collection [{key}]", key);
watcher.Stop();
}
diff --git a/Selector.CLI/LocalWatcherService.cs b/Selector.CLI/LocalWatcherService.cs
index 02616f3..364a2b7 100644
--- a/Selector.CLI/LocalWatcherService.cs
+++ b/Selector.CLI/LocalWatcherService.cs
@@ -54,7 +54,7 @@ namespace Selector.CLI
var watcherIndices = await InitInstances();
- Logger.LogInformation($"Starting {watcherIndices.Count()} affected watcher collection(s)...");
+ Logger.LogInformation("Starting {count} affected watcher collection(s)...", watcherIndices.Count());
StartWatcherCollections(watcherIndices);
}
@@ -145,12 +145,12 @@ namespace Selector.CLI
{
try
{
- Logger.LogInformation($"Starting watcher collection [{index}]");
+ Logger.LogInformation("Starting watcher collection [{index}]", index);
Watchers[index].Start();
}
catch (KeyNotFoundException)
{
- Logger.LogError($"Unable to retrieve watcher collection [{index}] when starting");
+ Logger.LogError("Unable to retrieve watcher collection [{index}] when starting", index);
}
}
}
@@ -161,7 +161,7 @@ namespace Selector.CLI
foreach((var key, var watcher) in Watchers)
{
- Logger.LogInformation($"Stopping watcher collection [{key}]");
+ Logger.LogInformation("Stopping watcher collection [{key}]", key);
watcher.Stop();
}
diff --git a/Selector.CLI/Selector.CLI.csproj b/Selector.CLI/Selector.CLI.csproj
index 585dc79..236efdc 100644
--- a/Selector.CLI/Selector.CLI.csproj
+++ b/Selector.CLI/Selector.CLI.csproj
@@ -14,7 +14,7 @@
-
+
diff --git a/Selector.Model/Selector.Model.csproj b/Selector.Model/Selector.Model.csproj
index 953a1e9..883c95c 100644
--- a/Selector.Model/Selector.Model.csproj
+++ b/Selector.Model/Selector.Model.csproj
@@ -12,15 +12,18 @@
-
-
-
-
+
+
+
+
runtime; build; native; contentfiles; analyzers; buildtransitive
all
-
-
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
diff --git a/Selector.Web/Selector.Web.csproj b/Selector.Web/Selector.Web.csproj
index 360c456..65bbcb3 100644
--- a/Selector.Web/Selector.Web.csproj
+++ b/Selector.Web/Selector.Web.csproj
@@ -13,13 +13,13 @@
-
-
+
+
-
+
-
+
runtime; build; native; contentfiles; analyzers; buildtransitive
all
@@ -27,8 +27,8 @@
-
-
+
+
diff --git a/Selector/Consumers/AudioFeatureInjector.cs b/Selector/Consumers/AudioFeatureInjector.cs
index d850fe6..f51b9c6 100644
--- a/Selector/Consumers/AudioFeatureInjector.cs
+++ b/Selector/Consumers/AudioFeatureInjector.cs
@@ -74,6 +74,10 @@ namespace Selector
{
Logger.LogDebug($"Ignoring podcast episdoe [{episode.DisplayString()}]");
}
+ else if (e.Current.Item is null)
+ {
+ Logger.LogDebug($"Skipping audio feature pulling for null item [{e.Current.DisplayString()}]");
+ }
else
{
Logger.LogError($"Unknown item pulled from API [{e.Current.Item}]");
diff --git a/Selector/Consumers/PlayCounter.cs b/Selector/Consumers/PlayCounter.cs
index f1d5c37..90290eb 100644
--- a/Selector/Consumers/PlayCounter.cs
+++ b/Selector/Consumers/PlayCounter.cs
@@ -141,6 +141,10 @@ namespace Selector
{
Logger.LogDebug($"Ignoring podcast episdoe [{episode.DisplayString()}]");
}
+ else if (e.Current.Item is null)
+ {
+ Logger.LogDebug($"Skipping play count pulling for null item [{e.Current.DisplayString()}]");
+ }
else
{
Logger.LogError($"Unknown item pulled from API [{e.Current.Item}]");
diff --git a/Selector/Extensions/SpotifyExtensions.cs b/Selector/Extensions/SpotifyExtensions.cs
index b47b271..c3e0340 100644
--- a/Selector/Extensions/SpotifyExtensions.cs
+++ b/Selector/Extensions/SpotifyExtensions.cs
@@ -21,15 +21,15 @@ namespace Selector
if (currentPlaying.Item is FullTrack track)
{
- return $"{currentPlaying.IsPlaying}, {track.DisplayString()}, {currentPlaying.Device?.DisplayString()}";
+ return $"{currentPlaying.IsPlaying}, {track.DisplayString()}, {currentPlaying.Device?.DisplayString() ?? "no device"}, {currentPlaying?.Context?.DisplayString() ?? "no context"}";
}
else if (currentPlaying.Item is FullEpisode episode)
{
- return $"{currentPlaying.IsPlaying}, {episode.DisplayString()}, {currentPlaying.Device?.DisplayString()}";
+ return $"{currentPlaying.IsPlaying}, {episode.DisplayString()}, {currentPlaying.Device?.DisplayString() ?? "no device"}";
}
else if (currentPlaying.Item is null)
{
- return $"{currentPlaying.IsPlaying}, no item, {currentPlaying.Device?.DisplayString()}";
+ return $"{currentPlaying.IsPlaying}, no item, {currentPlaying.Device?.DisplayString() ?? "no device"}";
}
else
{
diff --git a/Selector/Selector.csproj b/Selector/Selector.csproj
index 7595f2c..23ebd82 100644
--- a/Selector/Selector.csproj
+++ b/Selector/Selector.csproj
@@ -1,7 +1,7 @@
- netstandard2.1
+ net6.0
true
latest
diff --git a/Selector/Watcher/BaseWatcher.cs b/Selector/Watcher/BaseWatcher.cs
index 44132a2..f1ed7d5 100644
--- a/Selector/Watcher/BaseWatcher.cs
+++ b/Selector/Watcher/BaseWatcher.cs
@@ -29,7 +29,16 @@ namespace Selector
Logger.LogDebug("Starting watcher");
while (true) {
cancelToken.ThrowIfCancellationRequested();
- await WatchOne(cancelToken);
+
+ try
+ {
+ await WatchOne(cancelToken);
+ }
+ catch (Exception ex)
+ {
+ Logger.LogError(ex, "Exception occured while conducting single poll operation");
+ }
+
Logger.LogTrace($"Finished watch one, delaying {PollPeriod}ms...");
await Task.Delay(PollPeriod, cancelToken);
}
diff --git a/Selector/Watcher/PlayerWatcher.cs b/Selector/Watcher/PlayerWatcher.cs
index 02d0ae9..c1eeaeb 100644
--- a/Selector/Watcher/PlayerWatcher.cs
+++ b/Selector/Watcher/PlayerWatcher.cs
@@ -58,7 +58,7 @@ namespace Selector
try{
Logger.LogTrace("Making Spotify call");
var polledCurrent = await spotifyClient.GetCurrentPlayback();
- Logger.LogTrace($"Received Spotify call [{polledCurrent?.DisplayString()}]");
+ Logger.LogTrace("Received Spotify call [{context}]", polledCurrent?.DisplayString());
if (polledCurrent != null) StoreCurrentPlaying(polledCurrent);
@@ -76,17 +76,38 @@ namespace Selector
else
{
// STARTED PLAYBACK
+ if(Previous?.Context is null && Live?.Context is not null)
+ {
+ Logger.LogDebug("Context started: {context}", Live?.Context.DisplayString());
+ OnContextChange(GetEvent());
+ }
+
+ if(Previous?.Item is null && Live?.Item is not null)
+ {
+ if (Live.Item is FullTrack track)
+ {
+ Logger.LogDebug("Item started: {track}", track.DisplayString());
+ }
+ else if (Live.Item is FullEpisode episode)
+ {
+ Logger.LogDebug("Item started: {episode}", episode.DisplayString());
+ }
+ else
+ {
+ Logger.LogDebug("Item started: {item}", Live.Item);
+ }
+ OnItemChange(GetEvent());
+ }
+
if(Previous is null && Live is not null)
{
- Logger.LogDebug($"Playback started: {Live.DisplayString()}");
+ Logger.LogDebug("Playback started: {context}", Live.DisplayString());
OnPlayingChange(GetEvent());
- OnItemChange(GetEvent());
- OnContextChange(GetEvent());
}
// STOPPED PLAYBACK
else if(Previous is not null && Live is null)
{
- Logger.LogDebug($"Playback stopped: {Previous.DisplayString()}");
+ Logger.LogDebug("Playback stopped: {context}", Previous.DisplayString());
OnPlayingChange(GetEvent());
OnItemChange(GetEvent());
OnContextChange(GetEvent());
@@ -99,7 +120,7 @@ namespace Selector
&& Live.Item is FullTrack currentTrack)
{
if(!eq.IsEqual(previousTrack, currentTrack)) {
- Logger.LogDebug($"Track changed: {previousTrack.DisplayString()} -> {currentTrack.DisplayString()}");
+ Logger.LogDebug("Track changed: {prevTrack} -> {currentTrack}", previousTrack.DisplayString(), currentTrack.DisplayString());
OnItemChange(GetEvent());
}
@@ -132,11 +153,11 @@ namespace Selector
}
else if (Previous.Item is null)
{
- Logger.LogWarning($"Previous item was null [{Previous.DisplayString()}]");
+ Logger.LogTrace($"Previous item was null [{Previous.DisplayString()}]");
}
else if (Live.Item is null)
{
- Logger.LogWarning($"Live item was null [{Live.DisplayString()}]");
+ Logger.LogTrace($"Live item was null [{Live.DisplayString()}]");
}
else {
Logger.LogError($"Unknown combination of previous and current playing contexts, [{Previous.DisplayString()}] [{Live.DisplayString()}]");