From b73b99df8d93891b08ba8888dd9a6e30d7517377 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Mon, 22 Oct 2018 14:20:22 -0700 Subject: [PATCH] Fixed: Don't clean Kodi library if Always Update is disabled and video is playing Fixes #2773 --- .../Notifications/Xbmc/HttpApiProvider.cs | 14 +++++++++++++- .../Notifications/Xbmc/JsonApiProvider.cs | 16 ++++++++++++++-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/NzbDrone.Core/Notifications/Xbmc/HttpApiProvider.cs b/src/NzbDrone.Core/Notifications/Xbmc/HttpApiProvider.cs index 76f2bc91f..1065ecaff 100644 --- a/src/NzbDrone.Core/Notifications/Xbmc/HttpApiProvider.cs +++ b/src/NzbDrone.Core/Notifications/Xbmc/HttpApiProvider.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -53,6 +53,18 @@ namespace NzbDrone.Core.Notifications.Xbmc public void Clean(XbmcSettings settings) { + if (!settings.AlwaysUpdate) + { + _logger.Debug("Determining if there are any active players on XBMC host: {0}", settings.Address); + var activePlayers = GetActivePlayers(settings); + + if (activePlayers.Any(a => a.Type.Equals("video"))) + { + _logger.Debug("Video is currently playing, skipping library cleaning"); + return; + } + } + const string cleanVideoLibrary = "CleanLibrary(video)"; var command = BuildExecBuiltInCommand(cleanVideoLibrary); diff --git a/src/NzbDrone.Core/Notifications/Xbmc/JsonApiProvider.cs b/src/NzbDrone.Core/Notifications/Xbmc/JsonApiProvider.cs index 1a0674908..fbaa71544 100644 --- a/src/NzbDrone.Core/Notifications/Xbmc/JsonApiProvider.cs +++ b/src/NzbDrone.Core/Notifications/Xbmc/JsonApiProvider.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using NLog; @@ -33,7 +33,7 @@ namespace NzbDrone.Core.Notifications.Xbmc if (!settings.AlwaysUpdate) { _logger.Debug("Determining if there are any active players on XBMC host: {0}", settings.Address); - var activePlayers = _proxy.GetActivePlayers(settings); + var activePlayers = GetActivePlayers(settings); if (activePlayers.Any(a => a.Type.Equals("video"))) { @@ -47,6 +47,18 @@ namespace NzbDrone.Core.Notifications.Xbmc public void Clean(XbmcSettings settings) { + if (!settings.AlwaysUpdate) + { + _logger.Debug("Determining if there are any active players on XBMC host: {0}", settings.Address); + var activePlayers = GetActivePlayers(settings); + + if (activePlayers.Any(a => a.Type.Equals("video"))) + { + _logger.Debug("Video is currently playing, skipping library cleaning"); + return; + } + } + _proxy.CleanLibrary(settings); }