Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix requests when 4k content is available and 4k feature is disabled #4612

Merged
merged 1 commit into from
Apr 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/Ombi.Schedule/Jobs/Emby/EmbyAvaliabilityChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
using Microsoft.Extensions.Logging;
using Ombi.Core;
using Ombi.Core.Notifications;
using Ombi.Core.Services;
using Ombi.Helpers;
using Ombi.Hubs;
using Ombi.Notifications.Models;
using Ombi.Schedule.Jobs.Ombi;
using Ombi.Settings.Settings.Models;
using Ombi.Store.Entities;
using Ombi.Store.Repository;
using Ombi.Store.Repository.Requests;
Expand All @@ -21,14 +23,15 @@ namespace Ombi.Schedule.Jobs.Emby
public class EmbyAvaliabilityChecker : IEmbyAvaliabilityChecker
{
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;
_tvRepo = t;
_movieRepo = m;
_notificationService = n;
_log = log;
_notification = notification;
_featureService = featureService;
}

private readonly ITvRequestRepository _tvRepo;
Expand All @@ -37,6 +40,7 @@ public EmbyAvaliabilityChecker(IEmbyContentRepository repo, ITvRequestRepository
private readonly INotificationHelper _notificationService;
private readonly ILogger<EmbyAvaliabilityChecker> _log;
private readonly IHubContext<NotificationHub> _notification;
private readonly IFeatureService _featureService;

public async Task Execute(IJobExecutionContext job)
{
Expand All @@ -53,6 +57,7 @@ await _notification.Clients.Clients(NotificationHub.AdminConnectionIds)

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));

foreach (var movie in movies)
Expand Down Expand Up @@ -85,8 +90,8 @@ private async Task ProcessMovies()
notify = true;
}

// If we have a non-4k versison then mark as available
if (embyContent.Quality != null && !movie.Available)
// If we have a non-4k version or we don't care about versions, then mark as available
if (!movie.Available && ( !feature4kEnabled || embyContent.Quality != null ))
{
movie.Available = true;
movie.MarkedAsAvailable = DateTime.Now;
Expand Down
11 changes: 8 additions & 3 deletions src/Ombi.Schedule/Jobs/Jellyfin/JellyfinAvaliabilityChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Ombi.Core;
using Ombi.Core.Services;
using Ombi.Helpers;
using Ombi.Hubs;
using Ombi.Notifications.Models;
using Ombi.Settings.Settings.Models;
using Ombi.Store.Entities;
using Ombi.Store.Repository;
using Ombi.Store.Repository.Requests;
Expand All @@ -46,14 +48,15 @@ namespace Ombi.Schedule.Jobs.Jellyfin
public class JellyfinAvaliabilityChecker : IJellyfinAvaliabilityChecker
{
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;
_tvRepo = t;
_movieRepo = m;
_notificationService = n;
_log = log;
_notification = notification;
_featureService = featureService;
}

private readonly ITvRequestRepository _tvRepo;
Expand All @@ -62,6 +65,7 @@ public JellyfinAvaliabilityChecker(IJellyfinContentRepository repo, ITvRequestRe
private readonly INotificationHelper _notificationService;
private readonly ILogger<JellyfinAvaliabilityChecker> _log;
private readonly IHubContext<NotificationHub> _notification;
private readonly IFeatureService _featureService;

public async Task Execute(IJobExecutionContext job)
{
Expand All @@ -78,6 +82,7 @@ await _notification.Clients.Clients(NotificationHub.AdminConnectionIds)

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));

foreach (var movie in movies)
Expand Down Expand Up @@ -110,8 +115,8 @@ private async Task ProcessMovies()
notify = true;
}

// If we have a non-4k versison then mark as available
if (jellyfinContent.Quality != null && !movie.Available)
// If we have a non-4k version or we don't care about versions, then mark as available
if (!movie.Available && ( !feature4kEnabled || jellyfinContent.Quality != null ))
{
movie.Available = true;
movie.MarkedAsAvailable = DateTime.Now;
Expand Down