mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-19 12:59:39 -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.Services;
|
||||||
using Ombi.Core.Settings;
|
using Ombi.Core.Settings;
|
||||||
using Ombi.Core.Settings.Models.External;
|
using Ombi.Core.Settings.Models.External;
|
||||||
|
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;
|
||||||
|
@ -51,6 +52,7 @@ namespace Ombi.Core.Tests.Rule.Search
|
||||||
[Test]
|
[Test]
|
||||||
public async Task Movie_ShouldBe_Available_WhenFoundInEmby_4K()
|
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
|
ContextMock.Setup(x => x.GetByTheMovieDbId(It.IsAny<string>())).ReturnsAsync(new EmbyContent
|
||||||
{
|
{
|
||||||
TheMovieDbId = "123",
|
TheMovieDbId = "123",
|
||||||
|
@ -70,6 +72,7 @@ namespace Ombi.Core.Tests.Rule.Search
|
||||||
[Test]
|
[Test]
|
||||||
public async Task Movie_ShouldBe_Available_WhenFoundInEmby_Both()
|
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
|
ContextMock.Setup(x => x.GetByTheMovieDbId(It.IsAny<string>())).ReturnsAsync(new EmbyContent
|
||||||
{
|
{
|
||||||
TheMovieDbId = "123",
|
TheMovieDbId = "123",
|
||||||
|
|
|
@ -8,6 +8,7 @@ using Ombi.Core.Rule.Rules.Search;
|
||||||
using Ombi.Core.Services;
|
using Ombi.Core.Services;
|
||||||
using Ombi.Core.Settings;
|
using Ombi.Core.Settings;
|
||||||
using Ombi.Core.Settings.Models.External;
|
using Ombi.Core.Settings.Models.External;
|
||||||
|
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;
|
||||||
|
@ -51,6 +52,7 @@ namespace Ombi.Core.Tests.Rule.Search
|
||||||
[Test]
|
[Test]
|
||||||
public async Task Movie_ShouldBe_Available_WhenFoundInJellyfin_4K()
|
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
|
ContextMock.Setup(x => x.GetByTheMovieDbId(It.IsAny<string>())).ReturnsAsync(new JellyfinContent
|
||||||
{
|
{
|
||||||
TheMovieDbId = "123",
|
TheMovieDbId = "123",
|
||||||
|
@ -70,6 +72,7 @@ namespace Ombi.Core.Tests.Rule.Search
|
||||||
[Test]
|
[Test]
|
||||||
public async Task Movie_ShouldBe_Available_WhenFoundInJellyfin_Both()
|
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
|
ContextMock.Setup(x => x.GetByTheMovieDbId(It.IsAny<string>())).ReturnsAsync(new JellyfinContent
|
||||||
{
|
{
|
||||||
TheMovieDbId = "123",
|
TheMovieDbId = "123",
|
||||||
|
|
|
@ -82,6 +82,13 @@ namespace Ombi.Core.Rule.Rules.Search
|
||||||
obj.EmbyUrl = item.Url;
|
obj.EmbyUrl = item.Url;
|
||||||
obj.Quality = item.Quality;
|
obj.Quality = item.Quality;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (item.Quality.HasValue())
|
||||||
|
{
|
||||||
|
obj.Available = true;
|
||||||
|
obj.EmbyUrl = item.Url;
|
||||||
|
obj.Quality = item.Quality;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -95,6 +95,13 @@ namespace Ombi.Core.Rule.Rules.Search
|
||||||
obj.EmbyUrl = item.Url;
|
obj.EmbyUrl = item.Url;
|
||||||
obj.Quality = item.Quality;
|
obj.Quality = item.Quality;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (item.Quality.HasValue())
|
||||||
|
{
|
||||||
|
obj.Available = true;
|
||||||
|
obj.EmbyUrl = item.Url;
|
||||||
|
obj.Quality = item.Quality;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,9 +3,11 @@ using System.Threading.Tasks;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Ombi.Core.Models.Search;
|
using Ombi.Core.Models.Search;
|
||||||
using Ombi.Core.Rule.Interfaces;
|
using Ombi.Core.Rule.Interfaces;
|
||||||
|
using Ombi.Core.Services;
|
||||||
using Ombi.Core.Settings;
|
using Ombi.Core.Settings;
|
||||||
using Ombi.Core.Settings.Models.External;
|
using Ombi.Core.Settings.Models.External;
|
||||||
using Ombi.Helpers;
|
using Ombi.Helpers;
|
||||||
|
using Ombi.Settings.Settings.Models;
|
||||||
using Ombi.Store.Entities;
|
using Ombi.Store.Entities;
|
||||||
using Ombi.Store.Repository;
|
using Ombi.Store.Repository;
|
||||||
|
|
||||||
|
@ -14,12 +16,15 @@ namespace Ombi.Core.Rule.Rules.Search
|
||||||
public class PlexAvailabilityRule : BaseSearchRule, IRules<SearchViewModel>
|
public class PlexAvailabilityRule : BaseSearchRule, IRules<SearchViewModel>
|
||||||
{
|
{
|
||||||
private readonly ISettingsService<PlexSettings> _plexSettings;
|
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;
|
PlexContentRepository = repo;
|
||||||
Log = log;
|
Log = log;
|
||||||
_plexSettings = plexSettings;
|
_plexSettings = plexSettings;
|
||||||
|
_featureService = featureService;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IPlexContentRepository PlexContentRepository { get; }
|
private IPlexContentRepository PlexContentRepository { get; }
|
||||||
|
@ -92,10 +97,17 @@ namespace Ombi.Core.Rule.Rules.Search
|
||||||
|
|
||||||
if (obj is SearchMovieViewModel movie)
|
if (obj is SearchMovieViewModel movie)
|
||||||
{
|
{
|
||||||
if (item.Has4K)
|
var is4kEnabled = await _featureService.FeatureEnabled(FeatureNames.Movie4KRequests);
|
||||||
|
|
||||||
|
if (item.Has4K && is4kEnabled)
|
||||||
{
|
{
|
||||||
movie.Available4K = true;
|
movie.Available4K = true;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
obj.Available = true;
|
||||||
|
obj.Quality = item.Quality;
|
||||||
|
}
|
||||||
|
|
||||||
if (item.Quality.HasValue())
|
if (item.Quality.HasValue())
|
||||||
{
|
{
|
||||||
|
|
|
@ -307,9 +307,13 @@ namespace Ombi.Schedule.Jobs.Plex
|
||||||
// We need to see if this is a different quality,
|
// We need to see if this is a different quality,
|
||||||
// We want to know if this is a 4k content for example
|
// We want to know if this is a 4k content for example
|
||||||
var foundQualities = movie.Media?.Select(x => x.videoResolution);
|
var foundQualities = movie.Media?.Select(x => x.videoResolution);
|
||||||
|
var qualitySaved = false;
|
||||||
foreach (var quality in foundQualities)
|
foreach (var quality in foundQualities)
|
||||||
{
|
{
|
||||||
|
if (qualitySaved)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (quality.Equals(existing.Quality))
|
if (quality.Equals(existing.Quality))
|
||||||
{
|
{
|
||||||
// We got it
|
// We got it
|
||||||
|
@ -323,6 +327,12 @@ namespace Ombi.Schedule.Jobs.Plex
|
||||||
existing.Has4K = true;
|
existing.Has4K = true;
|
||||||
await Repo.Update(existing);
|
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