Allow Plex Watchlist to be empty

This commit is contained in:
nopoz 2024-05-14 09:49:39 -07:00
parent 627b2a4289
commit a342152ce7
1 changed files with 26 additions and 0 deletions

View File

@ -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.
}
}
}