Fixed: Don't clean Kodi library if video is playing and Always Update is disabled

Closes #5387
This commit is contained in:
Mark McDowall 2023-02-20 10:48:49 -08:00
parent d923d3f106
commit bbd9b1657d
1 changed files with 26 additions and 11 deletions

View File

@ -36,23 +36,25 @@ namespace NzbDrone.Core.Notifications.Xbmc
public void Update(XbmcSettings settings, Series series)
{
if (!settings.AlwaysUpdate)
{
_logger.Debug("Determining if there are any active players on XBMC host: {0}", settings.Address);
var activePlayers = _proxy.GetActivePlayers(settings);
if (activePlayers.Any(a => a.Type.Equals("video")))
if (CheckIfVideoPlayerOpen(settings))
{
_logger.Debug("Video is currently playing, skipping library update");
return;
}
}
UpdateLibrary(settings, series);
}
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