mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-19 04:49:33 -07:00
feat: plex availability checker
This commit is contained in:
parent
dec4f317b2
commit
4b031c9a1b
1 changed files with 19 additions and 13 deletions
|
@ -180,16 +180,12 @@ namespace Ombi.Schedule.Jobs.Plex
|
||||||
private async Task ProcessMovies()
|
private async Task ProcessMovies()
|
||||||
{
|
{
|
||||||
// Get all non available
|
// Get all non available
|
||||||
var movies = _movieRepo.GetAll().Include(x => x.RequestedUser).Where(x => !x.Available);
|
var movies = _movieRepo.GetAll().Include(x => x.RequestedUser).Where(x => !x.Available || (!x.Available4K && x.Has4KRequest));
|
||||||
var itemsForAvailbility = new List<AvailabilityModel>();
|
var itemsForAvailbility = new List<AvailabilityModel>();
|
||||||
|
|
||||||
foreach (var movie in movies)
|
foreach (var movie in movies)
|
||||||
{
|
{
|
||||||
if (movie.Available)
|
var has4kRequest = movie.Has4KRequest;
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
PlexServerContent item = null;
|
PlexServerContent item = null;
|
||||||
if (movie.ImdbId.HasValue())
|
if (movie.ImdbId.HasValue())
|
||||||
{
|
{
|
||||||
|
@ -208,9 +204,21 @@ namespace Ombi.Schedule.Jobs.Plex
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
_log.LogInformation("[PAC] - Movie request {0} is now available, sending notification", $"{movie.Title} - {movie.Id}");
|
_log.LogInformation($"[PAC] - Movie request {movie.Title} - {movie.Id} is now available, sending notification");
|
||||||
movie.Available = true;
|
|
||||||
movie.MarkedAsAvailable = DateTime.UtcNow;
|
if (has4kRequest && item.Has4K)
|
||||||
|
{
|
||||||
|
movie.Available4K = true;
|
||||||
|
movie.MarkedAsAvailable4K = DateTime.Now;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we have a non-4k versison then mark as available
|
||||||
|
if (item.Quality.HasValue())
|
||||||
|
{
|
||||||
|
movie.Available = true;
|
||||||
|
movie.MarkedAsAvailable = DateTime.Now;
|
||||||
|
}
|
||||||
|
|
||||||
itemsForAvailbility.Add(new AvailabilityModel
|
itemsForAvailbility.Add(new AvailabilityModel
|
||||||
{
|
{
|
||||||
Id = movie.Id,
|
Id = movie.Id,
|
||||||
|
@ -222,9 +230,9 @@ namespace Ombi.Schedule.Jobs.Plex
|
||||||
{
|
{
|
||||||
await _movieRepo.SaveChangesAsync();
|
await _movieRepo.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
foreach (var i in itemsForAvailbility)
|
|
||||||
{
|
|
||||||
|
|
||||||
|
foreach (var i in itemsForAvailbility.DistinctBy(x => x.Id))
|
||||||
|
{
|
||||||
await _notificationService.Notify(new NotificationOptions
|
await _notificationService.Notify(new NotificationOptions
|
||||||
{
|
{
|
||||||
DateTime = DateTime.Now,
|
DateTime = DateTime.Now,
|
||||||
|
@ -234,8 +242,6 @@ namespace Ombi.Schedule.Jobs.Plex
|
||||||
Recipient = i.RequestedUser
|
Recipient = i.RequestedUser
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//await _repo.SaveChangesAsync();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool _disposed;
|
private bool _disposed;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue