mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-19 17:32:38 +01:00
Fixed: Calculate movie availability comparing UTC dates
This commit is contained in:
parent
04c5e6c2a6
commit
44c7c71226
@ -7,12 +7,12 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync
|
||||
{
|
||||
public class AvailabilitySpecification : IDecisionEngineSpecification
|
||||
{
|
||||
private readonly IConfigService _settingsService;
|
||||
private readonly IConfigService _configService;
|
||||
private readonly Logger _logger;
|
||||
|
||||
public AvailabilitySpecification(IConfigService settingsService, Logger logger)
|
||||
public AvailabilitySpecification(IConfigService configService, Logger logger)
|
||||
{
|
||||
_settingsService = settingsService;
|
||||
_configService = configService;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
@ -21,18 +21,17 @@ public AvailabilitySpecification(IConfigService settingsService, Logger logger)
|
||||
|
||||
public Decision IsSatisfiedBy(RemoteMovie subject, SearchCriteriaBase searchCriteria)
|
||||
{
|
||||
if (searchCriteria != null)
|
||||
if (searchCriteria is { UserInvokedSearch: true })
|
||||
{
|
||||
if (searchCriteria.UserInvokedSearch)
|
||||
{
|
||||
_logger.Debug("Skipping availability check during search");
|
||||
return Decision.Accept();
|
||||
}
|
||||
_logger.Debug("Skipping availability check during search");
|
||||
return Decision.Accept();
|
||||
}
|
||||
|
||||
if (!subject.Movie.IsAvailable(_settingsService.AvailabilityDelay))
|
||||
var availabilityDelay = _configService.AvailabilityDelay;
|
||||
|
||||
if (!subject.Movie.IsAvailable(availabilityDelay))
|
||||
{
|
||||
return Decision.Reject("Movie {0} will only be considered available {1} days after {2}", subject.Movie, _settingsService.AvailabilityDelay, subject.Movie.MinimumAvailability.ToString());
|
||||
return Decision.Reject("Movie {0} will only be considered available {1} days after {2}", subject.Movie, availabilityDelay, subject.Movie.MinimumAvailability.ToString());
|
||||
}
|
||||
|
||||
return Decision.Accept();
|
||||
|
@ -81,7 +81,7 @@ public bool IsAvailable(int delay = 0)
|
||||
// This more complex sequence handles the delay
|
||||
DateTime minimumAvailabilityDate;
|
||||
|
||||
if ((MinimumAvailability == MovieStatusType.TBA) || (MinimumAvailability == MovieStatusType.Announced))
|
||||
if (MinimumAvailability is MovieStatusType.TBA or MovieStatusType.Announced)
|
||||
{
|
||||
minimumAvailabilityDate = DateTime.MinValue;
|
||||
}
|
||||
@ -105,16 +105,16 @@ public bool IsAvailable(int delay = 0)
|
||||
}
|
||||
else
|
||||
{
|
||||
minimumAvailabilityDate = MovieMetadata.Value.InCinemas.HasValue ? MovieMetadata.Value.InCinemas.Value.AddDays(90) : DateTime.MaxValue;
|
||||
minimumAvailabilityDate = MovieMetadata.Value.InCinemas?.AddDays(90) ?? DateTime.MaxValue;
|
||||
}
|
||||
}
|
||||
|
||||
if (minimumAvailabilityDate == DateTime.MinValue || minimumAvailabilityDate == DateTime.MaxValue)
|
||||
{
|
||||
return DateTime.Now >= minimumAvailabilityDate;
|
||||
return DateTime.UtcNow >= minimumAvailabilityDate;
|
||||
}
|
||||
|
||||
return DateTime.Now >= minimumAvailabilityDate.AddDays((double)delay);
|
||||
return DateTime.UtcNow >= minimumAvailabilityDate.AddDays(delay);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
|
Loading…
Reference in New Issue
Block a user