fix(emby/jellyfin): 🐛 Fixed another issue where we were not correctly displaying the correct status' for movies

pull/4516/head
tidusjar 3 years ago
parent 2927504f0e
commit 5c0556e6f4

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

@ -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<IEmbyContentRepository>();
LoggerMock = new Mock<ILogger<EmbyAvailabilityRule>>();
SettingsMock = new Mock<ISettingsService<EmbySettings>>();
Rule = new EmbyAvailabilityRule(ContextMock.Object, LoggerMock.Object, SettingsMock.Object);
FeatureMock = new Mock<IFeatureService>();
Rule = new EmbyAvailabilityRule(ContextMock.Object, LoggerMock.Object, FeatureMock.Object);
}
private EmbyAvailabilityRule Rule { get; set; }
private Mock<IEmbyContentRepository> ContextMock { get; set; }
private Mock<ILogger<EmbyAvailabilityRule>> LoggerMock { get; set; }
private Mock<ISettingsService<EmbySettings>> SettingsMock { get; set; }
private Mock<IFeatureService> 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<string>())).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<string>())).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<string>())).ReturnsAsync(new EmbyContent
{
TheMovieDbId = "123",

@ -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<IJellyfinContentRepository>();
LoggerMock = new Mock<ILogger<JellyfinAvailabilityRule>>();
SettingsMock = new Mock<ISettingsService<JellyfinSettings>>();
Rule = new JellyfinAvailabilityRule(ContextMock.Object, LoggerMock.Object, SettingsMock.Object);
FeatureMock = new Mock<IFeatureService>();
Rule = new JellyfinAvailabilityRule(ContextMock.Object, LoggerMock.Object, FeatureMock.Object);
}
private JellyfinAvailabilityRule Rule { get; set; }
private Mock<IJellyfinContentRepository> ContextMock { get; set; }
private Mock<ILogger<JellyfinAvailabilityRule>> LoggerMock { get; set; }
private Mock<ISettingsService<JellyfinSettings>> SettingsMock { get; set; }
private Mock<IFeatureService> 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<string>())).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<string>())).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<string>())).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<JellyfinServers>
{
new JellyfinServers
{
Ip = "8080",
Port = 9090,
ServerHostname = string.Empty,
ServerId = "8"
}
}
});
ContextMock.Setup(x => x.GetByTheMovieDbId(It.IsAny<string>())).ReturnsAsync(new JellyfinContent
{
TheMovieDbId = "123",

@ -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<SearchViewModel>
{
public EmbyAvailabilityRule(IEmbyContentRepository repo, ILogger<EmbyAvailabilityRule> log, ISettingsService<EmbySettings> s)
private readonly IFeatureService _featureService;
public EmbyAvailabilityRule(IEmbyContentRepository repo, ILogger<EmbyAvailabilityRule> log, IFeatureService featureService)
{
EmbyContentRepository = repo;
Log = log;
EmbySettings = s;
_featureService = featureService;
}
private IEmbyContentRepository EmbyContentRepository { get; }
private ILogger Log { get; }
private ISettingsService<EmbySettings> EmbySettings { get; }
public async Task<RuleResult> 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;

@ -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<SearchViewModel>
{
public JellyfinAvailabilityRule(IJellyfinContentRepository repo, ILogger<JellyfinAvailabilityRule> log, ISettingsService<JellyfinSettings> s)
private readonly IFeatureService _featureService;
public JellyfinAvailabilityRule(IJellyfinContentRepository repo, ILogger<JellyfinAvailabilityRule> log, IFeatureService featureService)
{
JellyfinContentRepository = repo;
Log = log;
JellyfinSettings = s;
_featureService = featureService;
}
private IJellyfinContentRepository JellyfinContentRepository { get; }
private ILogger Log { get; }
private ISettingsService<JellyfinSettings> JellyfinSettings { get; }
public async Task<RuleResult> 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;

@ -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

@ -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

@ -105,7 +105,7 @@
</ItemGroup>
<Target Name="DebugEnsureNodeEnv" BeforeTargets="Build" Condition=" '$(Configuration)' == 'Debug' And !Exists('$(SpaRoot)node_modules') ">
<Target Name="DebugEnsureNodeEnv" BeforeTargets="Build" Condition=" '$(Configuration)' == 'Debug' And !Exists('$(SpaRoot)node_modules') And '$(NCrunch)' != '1' ">
<Exec Command="node --version" ContinueOnError="true">
<Output TaskParameter="ExitCode" PropertyName="ErrorCode" />
</Exec>

Loading…
Cancel
Save