|
|
@ -73,23 +73,37 @@ namespace Ombi.Schedule.Jobs.Radarr
|
|
|
|
private async Task ProcessMovies()
|
|
|
|
private async Task ProcessMovies()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var availableRadarrMovies = _radarrRepo.GetAll().Where(x => x.HasFile).ToImmutableHashSet();
|
|
|
|
var availableRadarrMovies = _radarrRepo.GetAll().Where(x => x.HasFile).ToImmutableHashSet();
|
|
|
|
var unavailableMovieRequests = _movies.GetAll().Where(x => !x.Available).ToImmutableHashSet();
|
|
|
|
var unavailableMovieRequests = _movies.GetAll().Where(x => !x.Available || (!x.Available4K && x.Has4KRequest)).ToImmutableHashSet();
|
|
|
|
|
|
|
|
|
|
|
|
var itemsForAvailability = new List<AvailabilityModel>();
|
|
|
|
var itemsForAvailability = new List<AvailabilityModel>();
|
|
|
|
foreach (var movieRequest in unavailableMovieRequests)
|
|
|
|
foreach (var movieRequest in unavailableMovieRequests)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Do we have an item in the radarr list
|
|
|
|
// Do we have an item in the radarr list
|
|
|
|
var available = availableRadarrMovies.Any(x => x.TheMovieDbId == movieRequest.TheMovieDbId);
|
|
|
|
var available = availableRadarrMovies.FirstOrDefault(x => x.TheMovieDbId == movieRequest.TheMovieDbId);
|
|
|
|
if (available)
|
|
|
|
if (available != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_logger.LogInformation($"Found move '{movieRequest.Title}' available in Radarr");
|
|
|
|
_logger.LogInformation($"Found move '{movieRequest.Title}' available in Radarr");
|
|
|
|
movieRequest.Available = true;
|
|
|
|
if (available.Has4K && !movieRequest.Available4K)
|
|
|
|
movieRequest.MarkedAsAvailable = DateTime.UtcNow;
|
|
|
|
{
|
|
|
|
|
|
|
|
itemsForAvailability.Add(new AvailabilityModel
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Id = movieRequest.Id,
|
|
|
|
|
|
|
|
RequestedUser = movieRequest.RequestedUser != null ? movieRequest.RequestedUser.Email : string.Empty
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
movieRequest.Available4K = true;
|
|
|
|
|
|
|
|
movieRequest.MarkedAsAvailable4K = DateTime.UtcNow;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (available.HasRegular)
|
|
|
|
|
|
|
|
{
|
|
|
|
itemsForAvailability.Add(new AvailabilityModel
|
|
|
|
itemsForAvailability.Add(new AvailabilityModel
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Id = movieRequest.Id,
|
|
|
|
Id = movieRequest.Id,
|
|
|
|
RequestedUser = movieRequest.RequestedUser != null ? movieRequest.RequestedUser.Email : string.Empty
|
|
|
|
RequestedUser = movieRequest.RequestedUser != null ? movieRequest.RequestedUser.Email : string.Empty
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
movieRequest.Available = true;
|
|
|
|
|
|
|
|
movieRequest.MarkedAsAvailable = DateTime.UtcNow;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
await _movies.SaveChangesAsync();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -97,7 +111,6 @@ namespace Ombi.Schedule.Jobs.Radarr
|
|
|
|
{
|
|
|
|
{
|
|
|
|
await _hub.Clients.Clients(NotificationHub.AdminConnectionIds)
|
|
|
|
await _hub.Clients.Clients(NotificationHub.AdminConnectionIds)
|
|
|
|
.SendAsync(NotificationHub.NotificationEvent, "Radarr Availability Checker found some new available movies!");
|
|
|
|
.SendAsync(NotificationHub.NotificationEvent, "Radarr Availability Checker found some new available movies!");
|
|
|
|
await _movies.SaveChangesAsync();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
foreach (var item in itemsForAvailability)
|
|
|
|
foreach (var item in itemsForAvailability)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -110,7 +123,6 @@ namespace Ombi.Schedule.Jobs.Radarr
|
|
|
|
Recipient = item.RequestedUser
|
|
|
|
Recipient = item.RequestedUser
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async Task ProcessTvShows()
|
|
|
|
public async Task ProcessTvShows()
|
|
|
|