2017-01-02 17:05:55 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using NLog;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Tv
|
|
|
|
|
{
|
|
|
|
|
public interface ICheckIfMovieShouldBeRefreshed
|
|
|
|
|
{
|
|
|
|
|
bool ShouldRefresh(Movie movie);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class ShouldRefreshMovie : ICheckIfMovieShouldBeRefreshed
|
|
|
|
|
{
|
|
|
|
|
private readonly IEpisodeService _episodeService;
|
|
|
|
|
private readonly Logger _logger;
|
|
|
|
|
|
|
|
|
|
public ShouldRefreshMovie(IEpisodeService episodeService, Logger logger)
|
|
|
|
|
{
|
|
|
|
|
_episodeService = episodeService;
|
|
|
|
|
_logger = logger;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool ShouldRefresh(Movie movie)
|
|
|
|
|
{
|
2017-08-09 20:14:01 +00:00
|
|
|
|
//return false;
|
2017-01-02 17:05:55 +00:00
|
|
|
|
if (movie.LastInfoSync < DateTime.UtcNow.AddDays(-30))
|
|
|
|
|
{
|
|
|
|
|
_logger.Trace("Movie {0} last updated more than 30 days ago, should refresh.", movie.Title);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (movie.LastInfoSync >= DateTime.UtcNow.AddHours(-6))
|
|
|
|
|
{
|
|
|
|
|
_logger.Trace("Movie {0} last updated less than 6 hours ago, should not be refreshed.", movie.Title);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-28 14:59:06 +00:00
|
|
|
|
if (movie.Status == MovieStatusType.Announced || movie.Status == MovieStatusType.InCinemas)
|
2017-01-02 17:05:55 +00:00
|
|
|
|
{
|
2017-07-28 14:59:06 +00:00
|
|
|
|
_logger.Trace("Movie {0} is announced or in cinemas, should refresh.", movie.Title); //We probably have to change this.
|
2017-01-02 17:05:55 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-28 14:59:06 +00:00
|
|
|
|
if (movie.Status == MovieStatusType.Released && movie.PhysicalReleaseDate() >= DateTime.UtcNow.AddDays(-30))
|
|
|
|
|
{
|
|
|
|
|
_logger.Trace("Movie {0} is released since less than 30 days, should refresh", movie.Title);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_logger.Trace("Movie {0} came out long ago, should not be refreshed.", movie.Title);
|
2017-01-02 17:05:55 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|