|
|
|
@ -2,7 +2,6 @@ using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using NLog;
|
|
|
|
|
using NzbDrone.Common.Extensions;
|
|
|
|
|
using NzbDrone.Common.Instrumentation.Extensions;
|
|
|
|
@ -53,7 +52,7 @@ namespace NzbDrone.Core.Movies
|
|
|
|
|
_logger = logger;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void RefreshMovieInfo(Movie movie, Task<Tuple<Movie, List<Credit>>> dataTask)
|
|
|
|
|
private void RefreshMovieInfo(Movie movie)
|
|
|
|
|
{
|
|
|
|
|
_logger.ProgressInfo("Updating Info for {0}", movie.Title);
|
|
|
|
|
|
|
|
|
@ -62,7 +61,7 @@ namespace NzbDrone.Core.Movies
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var tuple = dataTask.GetAwaiter().GetResult();
|
|
|
|
|
var tuple = _movieInfo.GetMovieInfo(movie.TmdbId);
|
|
|
|
|
movieInfo = tuple.Item1;
|
|
|
|
|
credits = tuple.Item2;
|
|
|
|
|
}
|
|
|
|
@ -173,11 +172,10 @@ namespace NzbDrone.Core.Movies
|
|
|
|
|
if (message.MovieId.HasValue)
|
|
|
|
|
{
|
|
|
|
|
var movie = _movieService.GetMovie(message.MovieId.Value);
|
|
|
|
|
var movieData = _movieInfo.GetMovieInfoAsync(movie.TmdbId);
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
RefreshMovieInfo(movie, movieData);
|
|
|
|
|
RefreshMovieInfo(movie);
|
|
|
|
|
RescanMovie(movie, isNew, trigger);
|
|
|
|
|
}
|
|
|
|
|
catch (MovieNotFoundException)
|
|
|
|
@ -202,32 +200,13 @@ namespace NzbDrone.Core.Movies
|
|
|
|
|
updatedTMDBMovies = _movieInfo.GetChangedMovies(message.LastStartTime.Value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var toRefresh = allMovie
|
|
|
|
|
.Where(movie => (updatedTMDBMovies.Count == 0 && _checkIfMovieShouldBeRefreshed.ShouldRefresh(movie)) ||
|
|
|
|
|
updatedTMDBMovies.Contains(movie.TmdbId) ||
|
|
|
|
|
message.Trigger == CommandTrigger.Manual)
|
|
|
|
|
.ToDictionary(x => _movieInfo.GetMovieInfoAsync(x.TmdbId), x => x);
|
|
|
|
|
|
|
|
|
|
var tasks = toRefresh.Keys.ToList();
|
|
|
|
|
|
|
|
|
|
var skipped = allMovie.Except(toRefresh.Values);
|
|
|
|
|
|
|
|
|
|
foreach (var movie in skipped)
|
|
|
|
|
foreach (var movie in allMovie)
|
|
|
|
|
{
|
|
|
|
|
_logger.Info("Skipping refresh of movie: {0}", movie.Title);
|
|
|
|
|
RescanMovie(movie, false, trigger);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
while (tasks.Count > 0)
|
|
|
|
|
if ((updatedTMDBMovies.Count == 0 && _checkIfMovieShouldBeRefreshed.ShouldRefresh(movie)) || updatedTMDBMovies.Contains(movie.TmdbId) || message.Trigger == CommandTrigger.Manual)
|
|
|
|
|
{
|
|
|
|
|
var finishedTask = Task.WhenAny(tasks).GetAwaiter().GetResult();
|
|
|
|
|
tasks.Remove(finishedTask);
|
|
|
|
|
|
|
|
|
|
var movie = toRefresh[finishedTask];
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
RefreshMovieInfo(movie, finishedTask);
|
|
|
|
|
RefreshMovieInfo(movie);
|
|
|
|
|
}
|
|
|
|
|
catch (MovieNotFoundException)
|
|
|
|
|
{
|
|
|
|
@ -241,6 +220,12 @@ namespace NzbDrone.Core.Movies
|
|
|
|
|
|
|
|
|
|
RescanMovie(movie, false, trigger);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_logger.Info("Skipping refresh of movie: {0}", movie.Title);
|
|
|
|
|
RescanMovie(movie, false, trigger);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|