diff --git a/src/Ombi.Api.Emby/EmbyApi.cs b/src/Ombi.Api.Emby/EmbyApi.cs index c12cdb716..a1791494d 100644 --- a/src/Ombi.Api.Emby/EmbyApi.cs +++ b/src/Ombi.Api.Emby/EmbyApi.cs @@ -221,7 +221,7 @@ namespace Ombi.Api.Emby request.AddQueryString("Recursive", true.ToString()); request.AddQueryString("IncludeItemTypes", type); - request.AddQueryString("Fields", includeOverview ? "ProviderIds,Overview" : "ProviderIds"); + request.AddQueryString("Fields", includeOverview ? "ProviderIds,Overview,MediaStreams" : "ProviderIds,MediaStreams"); request.AddQueryString("startIndex", startIndex.ToString()); request.AddQueryString("limit", count.ToString()); if (!string.IsNullOrEmpty(parentIdFilder)) diff --git a/src/Ombi.Core.Tests/Rule/Search/EmbyAvailabilityRuleTests.cs b/src/Ombi.Core.Tests/Rule/Search/EmbyAvailabilityRuleTests.cs index 95be538cd..e3ec6cffe 100644 --- a/src/Ombi.Core.Tests/Rule/Search/EmbyAvailabilityRuleTests.cs +++ b/src/Ombi.Core.Tests/Rule/Search/EmbyAvailabilityRuleTests.cs @@ -5,6 +5,7 @@ using Moq; using NUnit.Framework; using Ombi.Core.Models.Search; using Ombi.Core.Rule.Rules.Search; +using Ombi.Core.Services; using Ombi.Core.Settings; using Ombi.Core.Settings.Models.External; using Ombi.Store.Entities; @@ -20,19 +21,18 @@ namespace Ombi.Core.Tests.Rule.Search { ContextMock = new Mock(); LoggerMock = new Mock>(); - SettingsMock = new Mock>(); - Rule = new EmbyAvailabilityRule(ContextMock.Object, LoggerMock.Object, SettingsMock.Object); + FeatureMock = new Mock(); + Rule = new EmbyAvailabilityRule(ContextMock.Object, LoggerMock.Object, FeatureMock.Object); } private EmbyAvailabilityRule Rule { get; set; } private Mock ContextMock { get; set; } private Mock> LoggerMock { get; set; } - private Mock> SettingsMock { get; set; } + private Mock FeatureMock { get; set; } [Test] public async Task Movie_ShouldBe_Available_WhenFoundInEmby() { - SettingsMock.Setup(x => x.GetSettingsAsync()).ReturnsAsync(new EmbySettings()); ContextMock.Setup(x => x.GetByTheMovieDbId(It.IsAny())).ReturnsAsync(new EmbyContent { TheMovieDbId = "123", @@ -51,7 +51,6 @@ namespace Ombi.Core.Tests.Rule.Search [Test] public async Task Movie_ShouldBe_Available_WhenFoundInEmby_4K() { - SettingsMock.Setup(x => x.GetSettingsAsync()).ReturnsAsync(new EmbySettings()); ContextMock.Setup(x => x.GetByTheMovieDbId(It.IsAny())).ReturnsAsync(new EmbyContent { TheMovieDbId = "123", @@ -71,7 +70,6 @@ namespace Ombi.Core.Tests.Rule.Search [Test] public async Task Movie_ShouldBe_Available_WhenFoundInEmby_Both() { - SettingsMock.Setup(x => x.GetSettingsAsync()).ReturnsAsync(new EmbySettings()); ContextMock.Setup(x => x.GetByTheMovieDbId(It.IsAny())).ReturnsAsync(new EmbyContent { TheMovieDbId = "123", diff --git a/src/Ombi.Core.Tests/Rule/Search/JellyfinAvailabilityRuleTests.cs b/src/Ombi.Core.Tests/Rule/Search/JellyfinAvailabilityRuleTests.cs index c0034afb7..6da5787b6 100644 --- a/src/Ombi.Core.Tests/Rule/Search/JellyfinAvailabilityRuleTests.cs +++ b/src/Ombi.Core.Tests/Rule/Search/JellyfinAvailabilityRuleTests.cs @@ -5,6 +5,7 @@ using Moq; using NUnit.Framework; using Ombi.Core.Models.Search; using Ombi.Core.Rule.Rules.Search; +using Ombi.Core.Services; using Ombi.Core.Settings; using Ombi.Core.Settings.Models.External; using Ombi.Store.Entities; @@ -20,19 +21,18 @@ namespace Ombi.Core.Tests.Rule.Search { ContextMock = new Mock(); LoggerMock = new Mock>(); - SettingsMock = new Mock>(); - Rule = new JellyfinAvailabilityRule(ContextMock.Object, LoggerMock.Object, SettingsMock.Object); + FeatureMock = new Mock(); + Rule = new JellyfinAvailabilityRule(ContextMock.Object, LoggerMock.Object, FeatureMock.Object); } private JellyfinAvailabilityRule Rule { get; set; } private Mock ContextMock { get; set; } private Mock> LoggerMock { get; set; } - private Mock> SettingsMock { get; set; } + private Mock FeatureMock { get; set; } [Test] public async Task Movie_ShouldBe_Available_WhenFoundInJellyfin() { - SettingsMock.Setup(x => x.GetSettingsAsync()).ReturnsAsync(new JellyfinSettings()); ContextMock.Setup(x => x.GetByTheMovieDbId(It.IsAny())).ReturnsAsync(new JellyfinContent { TheMovieDbId = "123", @@ -51,7 +51,6 @@ namespace Ombi.Core.Tests.Rule.Search [Test] public async Task Movie_ShouldBe_Available_WhenFoundInJellyfin_4K() { - SettingsMock.Setup(x => x.GetSettingsAsync()).ReturnsAsync(new JellyfinSettings()); ContextMock.Setup(x => x.GetByTheMovieDbId(It.IsAny())).ReturnsAsync(new JellyfinContent { TheMovieDbId = "123", @@ -71,7 +70,6 @@ namespace Ombi.Core.Tests.Rule.Search [Test] public async Task Movie_ShouldBe_Available_WhenFoundInJellyfin_Both() { - SettingsMock.Setup(x => x.GetSettingsAsync()).ReturnsAsync(new JellyfinSettings()); ContextMock.Setup(x => x.GetByTheMovieDbId(It.IsAny())).ReturnsAsync(new JellyfinContent { TheMovieDbId = "123", @@ -92,20 +90,6 @@ namespace Ombi.Core.Tests.Rule.Search [Test] public async Task Movie_Uses_Default_Url_When() { - SettingsMock.Setup(x => x.GetSettingsAsync()).ReturnsAsync(new JellyfinSettings - { - Enable = true, - Servers = new List - { - new JellyfinServers - { - Ip = "8080", - Port = 9090, - ServerHostname = string.Empty, - ServerId = "8" - } - } - }); ContextMock.Setup(x => x.GetByTheMovieDbId(It.IsAny())).ReturnsAsync(new JellyfinContent { TheMovieDbId = "123", diff --git a/src/Ombi.Core/Rule/Rules/Search/EmbyAvailabilityRule.cs b/src/Ombi.Core/Rule/Rules/Search/EmbyAvailabilityRule.cs index 4bc42ad04..79158ee43 100644 --- a/src/Ombi.Core/Rule/Rules/Search/EmbyAvailabilityRule.cs +++ b/src/Ombi.Core/Rule/Rules/Search/EmbyAvailabilityRule.cs @@ -4,9 +4,9 @@ using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; using Ombi.Core.Models.Search; using Ombi.Core.Rule.Interfaces; -using Ombi.Core.Settings; -using Ombi.Core.Settings.Models.External; +using Ombi.Core.Services; using Ombi.Helpers; +using Ombi.Settings.Settings.Models; using Ombi.Store.Entities; using Ombi.Store.Repository; @@ -14,16 +14,17 @@ namespace Ombi.Core.Rule.Rules.Search { public class EmbyAvailabilityRule : BaseSearchRule, IRules { - public EmbyAvailabilityRule(IEmbyContentRepository repo, ILogger log, ISettingsService s) + private readonly IFeatureService _featureService; + + public EmbyAvailabilityRule(IEmbyContentRepository repo, ILogger log, IFeatureService featureService) { EmbyContentRepository = repo; Log = log; - EmbySettings = s; + _featureService = featureService; } private IEmbyContentRepository EmbyContentRepository { get; } private ILogger Log { get; } - private ISettingsService EmbySettings { get; } public async Task Execute(SearchViewModel obj) { @@ -68,13 +69,14 @@ 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; obj.EmbyUrl = item.Url; } - - if (item.Quality.HasValue()) + else { obj.Available = true; obj.EmbyUrl = item.Url; diff --git a/src/Ombi.Core/Rule/Rules/Search/JellyfinAvailabilityRule.cs b/src/Ombi.Core/Rule/Rules/Search/JellyfinAvailabilityRule.cs index f8c69c0f0..7cab89991 100644 --- a/src/Ombi.Core/Rule/Rules/Search/JellyfinAvailabilityRule.cs +++ b/src/Ombi.Core/Rule/Rules/Search/JellyfinAvailabilityRule.cs @@ -4,9 +4,9 @@ using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; using Ombi.Core.Models.Search; using Ombi.Core.Rule.Interfaces; -using Ombi.Core.Settings; -using Ombi.Core.Settings.Models.External; +using Ombi.Core.Services; using Ombi.Helpers; +using Ombi.Settings.Settings.Models; using Ombi.Store.Entities; using Ombi.Store.Repository; @@ -14,16 +14,17 @@ namespace Ombi.Core.Rule.Rules.Search { public class JellyfinAvailabilityRule : BaseSearchRule, IRules { - public JellyfinAvailabilityRule(IJellyfinContentRepository repo, ILogger log, ISettingsService s) + private readonly IFeatureService _featureService; + + public JellyfinAvailabilityRule(IJellyfinContentRepository repo, ILogger log, IFeatureService featureService) { JellyfinContentRepository = repo; Log = log; - JellyfinSettings = s; + _featureService = featureService; } private IJellyfinContentRepository JellyfinContentRepository { get; } private ILogger Log { get; } - private ISettingsService JellyfinSettings { get; } public async Task Execute(SearchViewModel obj) { @@ -82,13 +83,13 @@ 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; obj.JellyfinUrl = item.Url; } - - if (item.Quality.HasValue()) + else { obj.Available = true; obj.EmbyUrl = item.Url; diff --git a/src/Ombi.Schedule/Jobs/Emby/EmbyContentSync.cs b/src/Ombi.Schedule/Jobs/Emby/EmbyContentSync.cs index 89baa7e9d..b4d61f93d 100644 --- a/src/Ombi.Schedule/Jobs/Emby/EmbyContentSync.cs +++ b/src/Ombi.Schedule/Jobs/Emby/EmbyContentSync.cs @@ -281,12 +281,15 @@ namespace Ombi.Schedule.Jobs.Emby } else { - if (!existingMovie.Quality.Equals(quality, StringComparison.InvariantCultureIgnoreCase)) + if (!quality.Equals(existingMovie?.Quality, StringComparison.InvariantCultureIgnoreCase)) { _logger.LogDebug($"We have found another quality for Movie '{movieInfo.Name}', Quality: '{quality}'"); existingMovie.Quality = has4K ? null : quality; existingMovie.Has4K = has4K; + // Probably could refactor here + // If a 4k movie comes in (we don't store the quality on 4k) + // it will always get updated even know it's not changed toUpdate.Add(existingMovie); } else diff --git a/src/Ombi.Schedule/Jobs/Jellyfin/JellyfinContentSync.cs b/src/Ombi.Schedule/Jobs/Jellyfin/JellyfinContentSync.cs index 10a6ae98c..060c974e7 100644 --- a/src/Ombi.Schedule/Jobs/Jellyfin/JellyfinContentSync.cs +++ b/src/Ombi.Schedule/Jobs/Jellyfin/JellyfinContentSync.cs @@ -245,12 +245,15 @@ namespace Ombi.Schedule.Jobs.Jellyfin } else { - if (!existingMovie.Quality.Equals(quality, StringComparison.InvariantCultureIgnoreCase)) + if (!quality.Equals(existingMovie?.Quality, StringComparison.InvariantCultureIgnoreCase)) { _logger.LogDebug($"We have found another quality for Movie '{movieInfo.Name}', Quality: '{quality}'"); existingMovie.Quality = has4K ? null : quality; existingMovie.Has4K = has4K; + // Probably could refactor here + // If a 4k movie comes in (we don't store the quality on 4k) + // it will always get updated even know it's not changed toUpdate.Add(existingMovie); } else diff --git a/src/Ombi/Ombi.csproj b/src/Ombi/Ombi.csproj index 5f836c27f..3dbc377cf 100644 --- a/src/Ombi/Ombi.csproj +++ b/src/Ombi/Ombi.csproj @@ -105,7 +105,7 @@ - +