From a342152ce7584b55a97a90ebee4c4c4f0650e9eb Mon Sep 17 00:00:00 2001 From: nopoz Date: Tue, 14 May 2024 09:49:39 -0700 Subject: [PATCH] Allow Plex Watchlist to be empty --- .../ImportLists/Plex/PlexImport.cs | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/NzbDrone.Core/ImportLists/Plex/PlexImport.cs b/src/NzbDrone.Core/ImportLists/Plex/PlexImport.cs index ee50b3540..e31910294 100644 --- a/src/NzbDrone.Core/ImportLists/Plex/PlexImport.cs +++ b/src/NzbDrone.Core/ImportLists/Plex/PlexImport.cs @@ -1,5 +1,7 @@ using System; using System.Collections.Generic; +using System.Linq; +using FluentValidation.Results; using NLog; using NzbDrone.Common.Extensions; using NzbDrone.Common.Http; @@ -104,5 +106,29 @@ namespace NzbDrone.Core.ImportLists.Plex return new { }; } + + protected override ValidationFailure TestConnection() + { + try + { + var parser = GetParser(); + var generator = GetRequestGenerator(); + var pageableRequests = generator.GetListItems(); + var request = pageableRequests.GetAllTiers().First().First(); + var releases = FetchPage(request, parser); + + if (releases.Empty()) + { + _logger.Info("No results were returned from Plex Watchlist."); + } + } + catch (Exception ex) + { + _logger.Warn(ex, "Unable to connect to Plex Watchlist"); + return new ValidationFailure(string.Empty, $"Unable to connect to Plex Watchlist: {ex.Message}. Check the log for details."); + } + + return null; // Indicate no fatal errors even if the list is empty. + } } }