New: Only Refresh on TMDB Refersh

This commit is contained in:
Qstick 2019-12-14 22:30:44 -05:00
parent d2065bfa1b
commit edcc0ba7ce
3 changed files with 27 additions and 3 deletions

View File

@ -9,5 +9,6 @@ namespace NzbDrone.Core.MetadataSource
{
Movie GetMovieInfo(string ImdbId);
Movie GetMovieInfo(int TmdbId, Profile profile, bool hasPreDBEntry);
HashSet<int> GetChangedMovies(DateTime startTime);
}
}
}

View File

@ -50,6 +50,22 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
_logger = logger;
}
public HashSet<int> GetChangedMovies (DateTime startTime)
{
var request = _movieBuilder.Create()
.SetSegment("route", "movie")
.SetSegment("id", "")
.SetSegment("secondaryRoute", "changes")
.Build();
request.AllowAutoRedirect = true;
request.SuppressHttpError = true;
var response = _httpClient.Get<MovieSearchRoot>(request);
return new HashSet<int>(response.Resource.results.Select(c => c.id));
}
public Movie GetMovieInfo(int TmdbId, Profile profile = null, bool hasPreDBEntry = false)
{
var langCode = profile != null ? IsoLanguages.Get(profile.Language)?.TwoLetterCode ?? "en" : "en";

View File

@ -12,7 +12,6 @@ using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.Messaging.Commands;
using NzbDrone.Core.Messaging.Events;
using NzbDrone.Core.MetadataSource;
using NzbDrone.Core.MediaFiles.Commands;
using NzbDrone.Core.MetadataSource.RadarrAPI;
using NzbDrone.Core.Movies.AlternativeTitles;
using NzbDrone.Core.Movies.Commands;
@ -219,9 +218,17 @@ namespace NzbDrone.Core.Movies
{
var allMovie = _movieService.GetAllMovies().OrderBy(c => c.SortTitle).ToList();
var updatedTMDBMovies = new HashSet<int>();
if (message.LastExecutionTime.HasValue && message.LastExecutionTime.Value.AddDays(14) > DateTime.UtcNow)
{
// TODO: Should we add some overlap to ensure we get everything?
updatedTMDBMovies = _movieInfo.GetChangedMovies(message.LastExecutionTime.Value);
}
foreach (var movie in allMovie)
{
if (message.Trigger == CommandTrigger.Manual || _checkIfMovieShouldBeRefreshed.ShouldRefresh(movie))
if ((updatedTMDBMovies.Count == 0 && _checkIfMovieShouldBeRefreshed.ShouldRefresh(movie)) || updatedTMDBMovies.Contains(movie.TmdbId) || message.Trigger == CommandTrigger.Manual)
{
try
{