diff --git a/Handlers/MPDHandler.cs b/Handlers/MPDHandler.cs index 9f87700..90eedea 100644 --- a/Handlers/MPDHandler.cs +++ b/Handlers/MPDHandler.cs @@ -497,21 +497,23 @@ namespace unison public async void QueryStats() { - Dictionary response = await SafelySendCommandAsync(new StatsCommand()); + Dictionary Response = await SafelySendCommandAsync(new StatsCommand()); + if (Response == null) + return; - _stats.Songs = int.Parse(response["songs"]); - _stats.Albums = int.Parse(response["albums"]); - _stats.Artists = int.Parse(response["artists"]); + _stats.Songs = int.Parse(Response["songs"]); + _stats.Albums = int.Parse(Response["albums"]); + _stats.Artists = int.Parse(Response["artists"]); TimeSpan time; - time = TimeSpan.FromSeconds(int.Parse(response["uptime"])); + time = TimeSpan.FromSeconds(int.Parse(Response["uptime"])); _stats.Uptime = time.ToString(@"dd\:hh\:mm\:ss"); - time = TimeSpan.FromSeconds(int.Parse(response["db_playtime"])); + time = TimeSpan.FromSeconds(int.Parse(Response["db_playtime"])); _stats.TotalPlaytime = time.ToString(@"dd\:hh\:mm\:ss"); - time = TimeSpan.FromSeconds(int.Parse(response["playtime"])); + time = TimeSpan.FromSeconds(int.Parse(Response["playtime"])); _stats.TotalTimePlayed = time.ToString(@"dd\:hh\:mm\:ss"); - DateTime date = new DateTime(1970, 1, 1).AddSeconds(int.Parse(response["db_update"])).ToLocalTime(); + DateTime date = new DateTime(1970, 1, 1).AddSeconds(int.Parse(Response["db_update"])).ToLocalTime(); _stats.DatabaseUpdate = date.ToString("dd/MM/yyyy @ HH:mm"); } }