Merge pull request #4612 from sephrat/4k-emby

Fix requests when 4k content is available and 4k feature is disabled
pull/4614/head
Jamie 3 years ago committed by GitHub
commit 9652719c6b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -7,10 +7,12 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Ombi.Core; using Ombi.Core;
using Ombi.Core.Notifications; using Ombi.Core.Notifications;
using Ombi.Core.Services;
using Ombi.Helpers; using Ombi.Helpers;
using Ombi.Hubs; using Ombi.Hubs;
using Ombi.Notifications.Models; using Ombi.Notifications.Models;
using Ombi.Schedule.Jobs.Ombi; using Ombi.Schedule.Jobs.Ombi;
using Ombi.Settings.Settings.Models;
using Ombi.Store.Entities; using Ombi.Store.Entities;
using Ombi.Store.Repository; using Ombi.Store.Repository;
using Ombi.Store.Repository.Requests; using Ombi.Store.Repository.Requests;
@ -21,7 +23,7 @@ namespace Ombi.Schedule.Jobs.Emby
public class EmbyAvaliabilityChecker : IEmbyAvaliabilityChecker public class EmbyAvaliabilityChecker : IEmbyAvaliabilityChecker
{ {
public EmbyAvaliabilityChecker(IEmbyContentRepository repo, ITvRequestRepository t, IMovieRequestRepository m, public EmbyAvaliabilityChecker(IEmbyContentRepository repo, ITvRequestRepository t, IMovieRequestRepository m,
INotificationHelper n, ILogger<EmbyAvaliabilityChecker> log, IHubContext<NotificationHub> notification) INotificationHelper n, ILogger<EmbyAvaliabilityChecker> log, IHubContext<NotificationHub> notification, IFeatureService featureService)
{ {
_repo = repo; _repo = repo;
_tvRepo = t; _tvRepo = t;
@ -29,6 +31,7 @@ namespace Ombi.Schedule.Jobs.Emby
_notificationService = n; _notificationService = n;
_log = log; _log = log;
_notification = notification; _notification = notification;
_featureService = featureService;
} }
private readonly ITvRequestRepository _tvRepo; private readonly ITvRequestRepository _tvRepo;
@ -37,6 +40,7 @@ namespace Ombi.Schedule.Jobs.Emby
private readonly INotificationHelper _notificationService; private readonly INotificationHelper _notificationService;
private readonly ILogger<EmbyAvaliabilityChecker> _log; private readonly ILogger<EmbyAvaliabilityChecker> _log;
private readonly IHubContext<NotificationHub> _notification; private readonly IHubContext<NotificationHub> _notification;
private readonly IFeatureService _featureService;
public async Task Execute(IJobExecutionContext job) public async Task Execute(IJobExecutionContext job)
{ {
@ -53,6 +57,7 @@ namespace Ombi.Schedule.Jobs.Emby
private async Task ProcessMovies() private async Task ProcessMovies()
{ {
var feature4kEnabled = await _featureService.FeatureEnabled(FeatureNames.Movie4KRequests);
var movies = _movieRepo.GetAll().Include(x => x.RequestedUser).Where(x => !x.Available || (!x.Available4K && x.Has4KRequest)); var movies = _movieRepo.GetAll().Include(x => x.RequestedUser).Where(x => !x.Available || (!x.Available4K && x.Has4KRequest));
foreach (var movie in movies) foreach (var movie in movies)
@ -85,8 +90,8 @@ namespace Ombi.Schedule.Jobs.Emby
notify = true; notify = true;
} }
// If we have a non-4k versison then mark as available // If we have a non-4k version or we don't care about versions, then mark as available
if (embyContent.Quality != null && !movie.Available) if (!movie.Available && ( !feature4kEnabled || embyContent.Quality != null ))
{ {
movie.Available = true; movie.Available = true;
movie.MarkedAsAvailable = DateTime.Now; movie.MarkedAsAvailable = DateTime.Now;

@ -33,9 +33,11 @@ using Microsoft.AspNetCore.SignalR;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Ombi.Core; using Ombi.Core;
using Ombi.Core.Services;
using Ombi.Helpers; using Ombi.Helpers;
using Ombi.Hubs; using Ombi.Hubs;
using Ombi.Notifications.Models; using Ombi.Notifications.Models;
using Ombi.Settings.Settings.Models;
using Ombi.Store.Entities; using Ombi.Store.Entities;
using Ombi.Store.Repository; using Ombi.Store.Repository;
using Ombi.Store.Repository.Requests; using Ombi.Store.Repository.Requests;
@ -46,7 +48,7 @@ namespace Ombi.Schedule.Jobs.Jellyfin
public class JellyfinAvaliabilityChecker : IJellyfinAvaliabilityChecker public class JellyfinAvaliabilityChecker : IJellyfinAvaliabilityChecker
{ {
public JellyfinAvaliabilityChecker(IJellyfinContentRepository repo, ITvRequestRepository t, IMovieRequestRepository m, public JellyfinAvaliabilityChecker(IJellyfinContentRepository repo, ITvRequestRepository t, IMovieRequestRepository m,
INotificationHelper n, ILogger<JellyfinAvaliabilityChecker> log, IHubContext<NotificationHub> notification) INotificationHelper n, ILogger<JellyfinAvaliabilityChecker> log, IHubContext<NotificationHub> notification, IFeatureService featureService)
{ {
_repo = repo; _repo = repo;
_tvRepo = t; _tvRepo = t;
@ -54,6 +56,7 @@ namespace Ombi.Schedule.Jobs.Jellyfin
_notificationService = n; _notificationService = n;
_log = log; _log = log;
_notification = notification; _notification = notification;
_featureService = featureService;
} }
private readonly ITvRequestRepository _tvRepo; private readonly ITvRequestRepository _tvRepo;
@ -62,6 +65,7 @@ namespace Ombi.Schedule.Jobs.Jellyfin
private readonly INotificationHelper _notificationService; private readonly INotificationHelper _notificationService;
private readonly ILogger<JellyfinAvaliabilityChecker> _log; private readonly ILogger<JellyfinAvaliabilityChecker> _log;
private readonly IHubContext<NotificationHub> _notification; private readonly IHubContext<NotificationHub> _notification;
private readonly IFeatureService _featureService;
public async Task Execute(IJobExecutionContext job) public async Task Execute(IJobExecutionContext job)
{ {
@ -78,6 +82,7 @@ namespace Ombi.Schedule.Jobs.Jellyfin
private async Task ProcessMovies() private async Task ProcessMovies()
{ {
var feature4kEnabled = await _featureService.FeatureEnabled(FeatureNames.Movie4KRequests);
var movies = _movieRepo.GetAll().Include(x => x.RequestedUser).Where(x => !x.Available || (!x.Available4K && x.Has4KRequest)); var movies = _movieRepo.GetAll().Include(x => x.RequestedUser).Where(x => !x.Available || (!x.Available4K && x.Has4KRequest));
foreach (var movie in movies) foreach (var movie in movies)
@ -110,8 +115,8 @@ namespace Ombi.Schedule.Jobs.Jellyfin
notify = true; notify = true;
} }
// If we have a non-4k versison then mark as available // If we have a non-4k version or we don't care about versions, then mark as available
if (jellyfinContent.Quality != null && !movie.Available) if (!movie.Available && ( !feature4kEnabled || jellyfinContent.Quality != null ))
{ {
movie.Available = true; movie.Available = true;
movie.MarkedAsAvailable = DateTime.Now; movie.MarkedAsAvailable = DateTime.Now;

Loading…
Cancel
Save