diff --git a/src/NzbDrone.Core/Notifications/Xbmc/XbmcService.cs b/src/NzbDrone.Core/Notifications/Xbmc/XbmcService.cs index 7bffa3b86..fa1f72493 100644 --- a/src/NzbDrone.Core/Notifications/Xbmc/XbmcService.cs +++ b/src/NzbDrone.Core/Notifications/Xbmc/XbmcService.cs @@ -36,16 +36,11 @@ namespace NzbDrone.Core.Notifications.Xbmc public void Update(XbmcSettings settings, Series series) { - if (!settings.AlwaysUpdate) + if (CheckIfVideoPlayerOpen(settings)) { - _logger.Debug("Determining if there are any active players on XBMC host: {0}", settings.Address); - var activePlayers = _proxy.GetActivePlayers(settings); + _logger.Debug("Video is currently playing, skipping library update"); - if (activePlayers.Any(a => a.Type.Equals("video"))) - { - _logger.Debug("Video is currently playing, skipping library update"); - return; - } + return; } UpdateLibrary(settings, series); @@ -53,6 +48,13 @@ namespace NzbDrone.Core.Notifications.Xbmc public void Clean(XbmcSettings settings) { + if (CheckIfVideoPlayerOpen(settings)) + { + _logger.Debug("Video is currently playing, skipping library clean"); + + return; + } + _proxy.CleanLibrary(settings); } @@ -62,7 +64,7 @@ namespace NzbDrone.Core.Notifications.Xbmc if (!allSeries.Any()) { - _logger.Debug("No TV shows returned from XBMC"); + _logger.Debug("No TV shows returned from Kodi"); return null; } @@ -90,11 +92,11 @@ namespace NzbDrone.Core.Notifications.Xbmc if (seriesPath != null) { - _logger.Debug("Updating series {0} (Path: {1}) on XBMC host: {2}", series, seriesPath, settings.Address); + _logger.Debug("Updating series {0} (Path: {1}) on Kodi host: {2}", series, seriesPath, settings.Address); } else { - _logger.Debug("Series {0} doesn't exist on XBMC host: {1}, Updating Entire Library", series, settings.Address); + _logger.Debug("Series {0} doesn't exist on Kodi host: {1}, Updating Entire Library", series, settings.Address); } var response = _proxy.UpdateLibrary(settings, seriesPath); @@ -110,6 +112,19 @@ namespace NzbDrone.Core.Notifications.Xbmc } } + private bool CheckIfVideoPlayerOpen(XbmcSettings settings) + { + if (settings.AlwaysUpdate) + { + return false; + } + + _logger.Debug("Determining if there are any active players on Kodi host: {0}", settings.Address); + var activePlayers = _proxy.GetActivePlayers(settings); + + return activePlayers.Any(a => a.Type.Equals("video")); + } + public ValidationFailure Test(XbmcSettings settings, string message) { try