mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-04 10:02:40 +01:00
Fixed: Clean Library being to agressive when lists are having failures.
Fixes #2455
This commit is contained in:
parent
74e0db2829
commit
95ca863697
@ -34,19 +34,21 @@ public HttpNetImportBase(IHttpClient httpClient, IConfigService configService, I
|
||||
_httpClient = httpClient;
|
||||
}
|
||||
|
||||
public override IList<Movie> Fetch()
|
||||
public override NetImportFetchResult Fetch()
|
||||
{
|
||||
var generator = GetRequestGenerator();
|
||||
return FetchMovies(generator.GetMovies());
|
||||
}
|
||||
|
||||
protected virtual IList<Movie> FetchMovies(NetImportPageableRequestChain pageableRequestChain, bool isRecent = false)
|
||||
protected virtual NetImportFetchResult FetchMovies(NetImportPageableRequestChain pageableRequestChain, bool isRecent = false)
|
||||
{
|
||||
var movies = new List<Movie>();
|
||||
var url = string.Empty;
|
||||
|
||||
var parser = GetParser();
|
||||
|
||||
var anyFailure = false;
|
||||
|
||||
try
|
||||
{
|
||||
for (int i = 0; i < pageableRequestChain.Tiers; i++)
|
||||
@ -73,6 +75,7 @@ protected virtual IList<Movie> FetchMovies(NetImportPageableRequestChain pageabl
|
||||
}
|
||||
catch (WebException webException)
|
||||
{
|
||||
anyFailure = true;
|
||||
if (webException.Message.Contains("502") || webException.Message.Contains("503") ||
|
||||
webException.Message.Contains("timed out"))
|
||||
{
|
||||
@ -85,6 +88,7 @@ protected virtual IList<Movie> FetchMovies(NetImportPageableRequestChain pageabl
|
||||
}
|
||||
catch (HttpException httpException)
|
||||
{
|
||||
anyFailure = true;
|
||||
if ((int)httpException.Response.StatusCode == 429)
|
||||
{
|
||||
_logger.Warn("API Request Limit reached for {0}", this);
|
||||
@ -96,11 +100,12 @@ protected virtual IList<Movie> FetchMovies(NetImportPageableRequestChain pageabl
|
||||
}
|
||||
catch (Exception feedEx)
|
||||
{
|
||||
anyFailure = true;
|
||||
feedEx.Data.Add("FeedUrl", url);
|
||||
_logger.Error(feedEx, "An error occurred while processing feed. " + url);
|
||||
}
|
||||
|
||||
return movies;
|
||||
return new NetImportFetchResult {Movies = movies, AnyFailure = anyFailure};
|
||||
}
|
||||
|
||||
protected virtual IList<Movie> FetchPage(NetImportRequest request, IParseNetImportResponse parser)
|
||||
|
@ -9,6 +9,6 @@ public interface INetImport : IProvider
|
||||
bool Enabled { get; }
|
||||
bool EnableAuto { get; }
|
||||
|
||||
IList<Movie> Fetch();
|
||||
NetImportFetchResult Fetch();
|
||||
}
|
||||
}
|
@ -9,6 +9,12 @@
|
||||
|
||||
namespace NzbDrone.Core.NetImport
|
||||
{
|
||||
public class NetImportFetchResult
|
||||
{
|
||||
public IList<Movie> Movies { get; set; }
|
||||
public bool AnyFailure { get; set; }
|
||||
}
|
||||
|
||||
public abstract class NetImportBase<TSettings> : INetImport
|
||||
where TSettings : IProviderConfig, new()
|
||||
{
|
||||
@ -20,7 +26,7 @@ public abstract class NetImportBase<TSettings> : INetImport
|
||||
public abstract bool Enabled { get; }
|
||||
public abstract bool EnableAuto { get; }
|
||||
|
||||
public abstract IList<Movie> Fetch();
|
||||
public abstract NetImportFetchResult Fetch();
|
||||
|
||||
public NetImportBase(IConfigService configService, IParsingService parsingService, Logger logger)
|
||||
{
|
||||
|
@ -54,21 +54,22 @@ public NetImportSearchService(INetImportFactory netImportFactory, IMovieService
|
||||
}
|
||||
|
||||
|
||||
public List<Movie> Fetch(int listId, bool onlyEnableAuto = false)
|
||||
public NetImportFetchResult Fetch(int listId, bool onlyEnableAuto = false)
|
||||
{
|
||||
return MovieListSearch(listId, onlyEnableAuto);
|
||||
}
|
||||
|
||||
public List<Movie> FetchAndFilter(int listId, bool onlyEnableAuto)
|
||||
{
|
||||
var movies = MovieListSearch(listId, onlyEnableAuto);
|
||||
var movies = MovieListSearch(listId, onlyEnableAuto).Movies;
|
||||
|
||||
return _movieService.FilterExistingMovies(movies);
|
||||
return _movieService.FilterExistingMovies(movies.ToList());
|
||||
}
|
||||
|
||||
public List<Movie> MovieListSearch(int listId, bool onlyEnableAuto = false)
|
||||
public NetImportFetchResult MovieListSearch(int listId, bool onlyEnableAuto = false)
|
||||
{
|
||||
var movies = new List<Movie>();
|
||||
var anyFailure = false;
|
||||
|
||||
var importLists = _netImportFactory.GetAvailableProviders();
|
||||
|
||||
@ -81,12 +82,17 @@ public List<Movie> MovieListSearch(int listId, bool onlyEnableAuto = false)
|
||||
|
||||
foreach (var list in lists)
|
||||
{
|
||||
movies.AddRange(list.Fetch());
|
||||
var result = list.Fetch();
|
||||
movies.AddRange(result.Movies);
|
||||
anyFailure |= result.AnyFailure;
|
||||
}
|
||||
|
||||
_logger.Debug("Found {0} movies from list(s) {1}", movies.Count, string.Join(", ", lists.Select(l => l.Definition.Name)));
|
||||
|
||||
return movies.DistinctBy(x => {
|
||||
return new NetImportFetchResult
|
||||
{
|
||||
Movies = movies.DistinctBy(x =>
|
||||
{
|
||||
if (x.TmdbId != 0)
|
||||
{
|
||||
return x.TmdbId.ToString();
|
||||
@ -98,7 +104,9 @@ public List<Movie> MovieListSearch(int listId, bool onlyEnableAuto = false)
|
||||
}
|
||||
|
||||
return x.Title;
|
||||
}).ToList();
|
||||
}).ToList(),
|
||||
AnyFailure = anyFailure
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -112,9 +120,13 @@ public void Execute(NetImportSyncCommand message)
|
||||
return;
|
||||
}
|
||||
|
||||
var listedMovies = Fetch(0, true);
|
||||
var result = Fetch(0, true);
|
||||
var listedMovies = result.Movies.ToList();
|
||||
|
||||
if (!result.AnyFailure)
|
||||
{
|
||||
CleanLibrary(listedMovies);
|
||||
}
|
||||
|
||||
listedMovies = listedMovies.Where(x => !_movieService.MovieExists(x)).ToList();
|
||||
if (listedMovies.Any())
|
||||
|
Loading…
Reference in New Issue
Block a user