mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-14 02:26:55 -07:00
fix(mediaserver): fixed some more issues in the media server sync and availability checks
This commit is contained in:
parent
3b0ba18f1b
commit
f3ea979b8b
6 changed files with 46 additions and 4 deletions
|
@ -8,6 +8,7 @@ using Ombi.Core.Rule.Rules.Search;
|
|||
using Ombi.Core.Services;
|
||||
using Ombi.Core.Settings;
|
||||
using Ombi.Core.Settings.Models.External;
|
||||
using Ombi.Settings.Settings.Models;
|
||||
using Ombi.Store.Entities;
|
||||
using Ombi.Store.Repository;
|
||||
using Ombi.Store.Repository.Requests;
|
||||
|
@ -51,6 +52,7 @@ namespace Ombi.Core.Tests.Rule.Search
|
|||
[Test]
|
||||
public async Task Movie_ShouldBe_Available_WhenFoundInEmby_4K()
|
||||
{
|
||||
FeatureMock.Setup(x => x.FeatureEnabled(FeatureNames.Movie4KRequests)).ReturnsAsync(true);
|
||||
ContextMock.Setup(x => x.GetByTheMovieDbId(It.IsAny<string>())).ReturnsAsync(new EmbyContent
|
||||
{
|
||||
TheMovieDbId = "123",
|
||||
|
@ -70,6 +72,7 @@ namespace Ombi.Core.Tests.Rule.Search
|
|||
[Test]
|
||||
public async Task Movie_ShouldBe_Available_WhenFoundInEmby_Both()
|
||||
{
|
||||
FeatureMock.Setup(x => x.FeatureEnabled(FeatureNames.Movie4KRequests)).ReturnsAsync(true);
|
||||
ContextMock.Setup(x => x.GetByTheMovieDbId(It.IsAny<string>())).ReturnsAsync(new EmbyContent
|
||||
{
|
||||
TheMovieDbId = "123",
|
||||
|
|
|
@ -8,6 +8,7 @@ using Ombi.Core.Rule.Rules.Search;
|
|||
using Ombi.Core.Services;
|
||||
using Ombi.Core.Settings;
|
||||
using Ombi.Core.Settings.Models.External;
|
||||
using Ombi.Settings.Settings.Models;
|
||||
using Ombi.Store.Entities;
|
||||
using Ombi.Store.Repository;
|
||||
using Ombi.Store.Repository.Requests;
|
||||
|
@ -51,6 +52,7 @@ namespace Ombi.Core.Tests.Rule.Search
|
|||
[Test]
|
||||
public async Task Movie_ShouldBe_Available_WhenFoundInJellyfin_4K()
|
||||
{
|
||||
FeatureMock.Setup(x => x.FeatureEnabled(FeatureNames.Movie4KRequests)).ReturnsAsync(true);
|
||||
ContextMock.Setup(x => x.GetByTheMovieDbId(It.IsAny<string>())).ReturnsAsync(new JellyfinContent
|
||||
{
|
||||
TheMovieDbId = "123",
|
||||
|
@ -70,6 +72,7 @@ namespace Ombi.Core.Tests.Rule.Search
|
|||
[Test]
|
||||
public async Task Movie_ShouldBe_Available_WhenFoundInJellyfin_Both()
|
||||
{
|
||||
FeatureMock.Setup(x => x.FeatureEnabled(FeatureNames.Movie4KRequests)).ReturnsAsync(true);
|
||||
ContextMock.Setup(x => x.GetByTheMovieDbId(It.IsAny<string>())).ReturnsAsync(new JellyfinContent
|
||||
{
|
||||
TheMovieDbId = "123",
|
||||
|
|
|
@ -82,6 +82,13 @@ namespace Ombi.Core.Rule.Rules.Search
|
|||
obj.EmbyUrl = item.Url;
|
||||
obj.Quality = item.Quality;
|
||||
}
|
||||
|
||||
if (item.Quality.HasValue())
|
||||
{
|
||||
obj.Available = true;
|
||||
obj.EmbyUrl = item.Url;
|
||||
obj.Quality = item.Quality;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -88,13 +88,20 @@ namespace Ombi.Core.Rule.Rules.Search
|
|||
{
|
||||
movie.Available4K = true;
|
||||
obj.JellyfinUrl = item.Url;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
obj.Available = true;
|
||||
obj.EmbyUrl = item.Url;
|
||||
obj.Quality = item.Quality;
|
||||
}
|
||||
|
||||
if (item.Quality.HasValue())
|
||||
{
|
||||
obj.Available = true;
|
||||
obj.EmbyUrl = item.Url;
|
||||
obj.Quality = item.Quality;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -3,9 +3,11 @@ using System.Threading.Tasks;
|
|||
using Microsoft.Extensions.Logging;
|
||||
using Ombi.Core.Models.Search;
|
||||
using Ombi.Core.Rule.Interfaces;
|
||||
using Ombi.Core.Services;
|
||||
using Ombi.Core.Settings;
|
||||
using Ombi.Core.Settings.Models.External;
|
||||
using Ombi.Helpers;
|
||||
using Ombi.Settings.Settings.Models;
|
||||
using Ombi.Store.Entities;
|
||||
using Ombi.Store.Repository;
|
||||
|
||||
|
@ -14,12 +16,15 @@ namespace Ombi.Core.Rule.Rules.Search
|
|||
public class PlexAvailabilityRule : BaseSearchRule, IRules<SearchViewModel>
|
||||
{
|
||||
private readonly ISettingsService<PlexSettings> _plexSettings;
|
||||
private readonly IFeatureService _featureService;
|
||||
|
||||
public PlexAvailabilityRule(IPlexContentRepository repo, ILogger<PlexAvailabilityRule> log, ISettingsService<PlexSettings> plexSettings)
|
||||
public PlexAvailabilityRule(IPlexContentRepository repo, ILogger<PlexAvailabilityRule> log, ISettingsService<PlexSettings> plexSettings,
|
||||
IFeatureService featureService)
|
||||
{
|
||||
PlexContentRepository = repo;
|
||||
Log = log;
|
||||
_plexSettings = plexSettings;
|
||||
_featureService = featureService;
|
||||
}
|
||||
|
||||
private IPlexContentRepository PlexContentRepository { get; }
|
||||
|
@ -92,10 +97,17 @@ namespace Ombi.Core.Rule.Rules.Search
|
|||
|
||||
if (obj is SearchMovieViewModel movie)
|
||||
{
|
||||
if (item.Has4K)
|
||||
var is4kEnabled = await _featureService.FeatureEnabled(FeatureNames.Movie4KRequests);
|
||||
|
||||
if (item.Has4K && is4kEnabled)
|
||||
{
|
||||
movie.Available4K = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
obj.Available = true;
|
||||
obj.Quality = item.Quality;
|
||||
}
|
||||
|
||||
if (item.Quality.HasValue())
|
||||
{
|
||||
|
|
|
@ -307,9 +307,13 @@ namespace Ombi.Schedule.Jobs.Plex
|
|||
// We need to see if this is a different quality,
|
||||
// We want to know if this is a 4k content for example
|
||||
var foundQualities = movie.Media?.Select(x => x.videoResolution);
|
||||
|
||||
var qualitySaved = false;
|
||||
foreach (var quality in foundQualities)
|
||||
{
|
||||
if (qualitySaved)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (quality.Equals(existing.Quality))
|
||||
{
|
||||
// We got it
|
||||
|
@ -322,6 +326,12 @@ namespace Ombi.Schedule.Jobs.Plex
|
|||
Logger.LogDebug($"We already have movie {movie.title}, But found a 4K version!");
|
||||
existing.Has4K = true;
|
||||
await Repo.Update(existing);
|
||||
}
|
||||
else
|
||||
{
|
||||
qualitySaved = true;
|
||||
existing.Quality = quality;
|
||||
await Repo.Update(existing);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue