mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-20 13:23:20 -07:00
fix(emby/jellyfin): 🐛 Fixed another issue where we were not correctly displaying the correct status' for movies
This commit is contained in:
parent
2927504f0e
commit
5c0556e6f4
8 changed files with 37 additions and 46 deletions
|
@ -221,7 +221,7 @@ namespace Ombi.Api.Emby
|
||||||
|
|
||||||
request.AddQueryString("Recursive", true.ToString());
|
request.AddQueryString("Recursive", true.ToString());
|
||||||
request.AddQueryString("IncludeItemTypes", type);
|
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("startIndex", startIndex.ToString());
|
||||||
request.AddQueryString("limit", count.ToString());
|
request.AddQueryString("limit", count.ToString());
|
||||||
if (!string.IsNullOrEmpty(parentIdFilder))
|
if (!string.IsNullOrEmpty(parentIdFilder))
|
||||||
|
|
|
@ -5,6 +5,7 @@ using Moq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using Ombi.Core.Models.Search;
|
using Ombi.Core.Models.Search;
|
||||||
using Ombi.Core.Rule.Rules.Search;
|
using Ombi.Core.Rule.Rules.Search;
|
||||||
|
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.Store.Entities;
|
using Ombi.Store.Entities;
|
||||||
|
@ -20,19 +21,18 @@ namespace Ombi.Core.Tests.Rule.Search
|
||||||
{
|
{
|
||||||
ContextMock = new Mock<IEmbyContentRepository>();
|
ContextMock = new Mock<IEmbyContentRepository>();
|
||||||
LoggerMock = new Mock<ILogger<EmbyAvailabilityRule>>();
|
LoggerMock = new Mock<ILogger<EmbyAvailabilityRule>>();
|
||||||
SettingsMock = new Mock<ISettingsService<EmbySettings>>();
|
FeatureMock = new Mock<IFeatureService>();
|
||||||
Rule = new EmbyAvailabilityRule(ContextMock.Object, LoggerMock.Object, SettingsMock.Object);
|
Rule = new EmbyAvailabilityRule(ContextMock.Object, LoggerMock.Object, FeatureMock.Object);
|
||||||
}
|
}
|
||||||
|
|
||||||
private EmbyAvailabilityRule Rule { get; set; }
|
private EmbyAvailabilityRule Rule { get; set; }
|
||||||
private Mock<IEmbyContentRepository> ContextMock { get; set; }
|
private Mock<IEmbyContentRepository> ContextMock { get; set; }
|
||||||
private Mock<ILogger<EmbyAvailabilityRule>> LoggerMock { get; set; }
|
private Mock<ILogger<EmbyAvailabilityRule>> LoggerMock { get; set; }
|
||||||
private Mock<ISettingsService<EmbySettings>> SettingsMock { get; set; }
|
private Mock<IFeatureService> FeatureMock { get; set; }
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public async Task Movie_ShouldBe_Available_WhenFoundInEmby()
|
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
|
ContextMock.Setup(x => x.GetByTheMovieDbId(It.IsAny<string>())).ReturnsAsync(new EmbyContent
|
||||||
{
|
{
|
||||||
TheMovieDbId = "123",
|
TheMovieDbId = "123",
|
||||||
|
@ -51,7 +51,6 @@ namespace Ombi.Core.Tests.Rule.Search
|
||||||
[Test]
|
[Test]
|
||||||
public async Task Movie_ShouldBe_Available_WhenFoundInEmby_4K()
|
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
|
ContextMock.Setup(x => x.GetByTheMovieDbId(It.IsAny<string>())).ReturnsAsync(new EmbyContent
|
||||||
{
|
{
|
||||||
TheMovieDbId = "123",
|
TheMovieDbId = "123",
|
||||||
|
@ -71,7 +70,6 @@ namespace Ombi.Core.Tests.Rule.Search
|
||||||
[Test]
|
[Test]
|
||||||
public async Task Movie_ShouldBe_Available_WhenFoundInEmby_Both()
|
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
|
ContextMock.Setup(x => x.GetByTheMovieDbId(It.IsAny<string>())).ReturnsAsync(new EmbyContent
|
||||||
{
|
{
|
||||||
TheMovieDbId = "123",
|
TheMovieDbId = "123",
|
||||||
|
|
|
@ -5,6 +5,7 @@ using Moq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using Ombi.Core.Models.Search;
|
using Ombi.Core.Models.Search;
|
||||||
using Ombi.Core.Rule.Rules.Search;
|
using Ombi.Core.Rule.Rules.Search;
|
||||||
|
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.Store.Entities;
|
using Ombi.Store.Entities;
|
||||||
|
@ -20,19 +21,18 @@ namespace Ombi.Core.Tests.Rule.Search
|
||||||
{
|
{
|
||||||
ContextMock = new Mock<IJellyfinContentRepository>();
|
ContextMock = new Mock<IJellyfinContentRepository>();
|
||||||
LoggerMock = new Mock<ILogger<JellyfinAvailabilityRule>>();
|
LoggerMock = new Mock<ILogger<JellyfinAvailabilityRule>>();
|
||||||
SettingsMock = new Mock<ISettingsService<JellyfinSettings>>();
|
FeatureMock = new Mock<IFeatureService>();
|
||||||
Rule = new JellyfinAvailabilityRule(ContextMock.Object, LoggerMock.Object, SettingsMock.Object);
|
Rule = new JellyfinAvailabilityRule(ContextMock.Object, LoggerMock.Object, FeatureMock.Object);
|
||||||
}
|
}
|
||||||
|
|
||||||
private JellyfinAvailabilityRule Rule { get; set; }
|
private JellyfinAvailabilityRule Rule { get; set; }
|
||||||
private Mock<IJellyfinContentRepository> ContextMock { get; set; }
|
private Mock<IJellyfinContentRepository> ContextMock { get; set; }
|
||||||
private Mock<ILogger<JellyfinAvailabilityRule>> LoggerMock { get; set; }
|
private Mock<ILogger<JellyfinAvailabilityRule>> LoggerMock { get; set; }
|
||||||
private Mock<ISettingsService<JellyfinSettings>> SettingsMock { get; set; }
|
private Mock<IFeatureService> FeatureMock { get; set; }
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public async Task Movie_ShouldBe_Available_WhenFoundInJellyfin()
|
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
|
ContextMock.Setup(x => x.GetByTheMovieDbId(It.IsAny<string>())).ReturnsAsync(new JellyfinContent
|
||||||
{
|
{
|
||||||
TheMovieDbId = "123",
|
TheMovieDbId = "123",
|
||||||
|
@ -51,7 +51,6 @@ namespace Ombi.Core.Tests.Rule.Search
|
||||||
[Test]
|
[Test]
|
||||||
public async Task Movie_ShouldBe_Available_WhenFoundInJellyfin_4K()
|
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
|
ContextMock.Setup(x => x.GetByTheMovieDbId(It.IsAny<string>())).ReturnsAsync(new JellyfinContent
|
||||||
{
|
{
|
||||||
TheMovieDbId = "123",
|
TheMovieDbId = "123",
|
||||||
|
@ -71,7 +70,6 @@ namespace Ombi.Core.Tests.Rule.Search
|
||||||
[Test]
|
[Test]
|
||||||
public async Task Movie_ShouldBe_Available_WhenFoundInJellyfin_Both()
|
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
|
ContextMock.Setup(x => x.GetByTheMovieDbId(It.IsAny<string>())).ReturnsAsync(new JellyfinContent
|
||||||
{
|
{
|
||||||
TheMovieDbId = "123",
|
TheMovieDbId = "123",
|
||||||
|
@ -92,20 +90,6 @@ namespace Ombi.Core.Tests.Rule.Search
|
||||||
[Test]
|
[Test]
|
||||||
public async Task Movie_Uses_Default_Url_When()
|
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
|
ContextMock.Setup(x => x.GetByTheMovieDbId(It.IsAny<string>())).ReturnsAsync(new JellyfinContent
|
||||||
{
|
{
|
||||||
TheMovieDbId = "123",
|
TheMovieDbId = "123",
|
||||||
|
|
|
@ -4,9 +4,9 @@ using Microsoft.EntityFrameworkCore;
|
||||||
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.Settings;
|
using Ombi.Core.Services;
|
||||||
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,16 +14,17 @@ namespace Ombi.Core.Rule.Rules.Search
|
||||||
{
|
{
|
||||||
public class EmbyAvailabilityRule : BaseSearchRule, IRules<SearchViewModel>
|
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;
|
EmbyContentRepository = repo;
|
||||||
Log = log;
|
Log = log;
|
||||||
EmbySettings = s;
|
_featureService = featureService;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEmbyContentRepository EmbyContentRepository { get; }
|
private IEmbyContentRepository EmbyContentRepository { get; }
|
||||||
private ILogger Log { get; }
|
private ILogger Log { get; }
|
||||||
private ISettingsService<EmbySettings> EmbySettings { get; }
|
|
||||||
|
|
||||||
public async Task<RuleResult> Execute(SearchViewModel obj)
|
public async Task<RuleResult> Execute(SearchViewModel obj)
|
||||||
{
|
{
|
||||||
|
@ -68,13 +69,14 @@ 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;
|
||||||
obj.EmbyUrl = item.Url;
|
obj.EmbyUrl = item.Url;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if (item.Quality.HasValue())
|
|
||||||
{
|
{
|
||||||
obj.Available = true;
|
obj.Available = true;
|
||||||
obj.EmbyUrl = item.Url;
|
obj.EmbyUrl = item.Url;
|
||||||
|
|
|
@ -4,9 +4,9 @@ using Microsoft.EntityFrameworkCore;
|
||||||
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.Settings;
|
using Ombi.Core.Services;
|
||||||
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,16 +14,17 @@ namespace Ombi.Core.Rule.Rules.Search
|
||||||
{
|
{
|
||||||
public class JellyfinAvailabilityRule : BaseSearchRule, IRules<SearchViewModel>
|
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;
|
JellyfinContentRepository = repo;
|
||||||
Log = log;
|
Log = log;
|
||||||
JellyfinSettings = s;
|
_featureService = featureService;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IJellyfinContentRepository JellyfinContentRepository { get; }
|
private IJellyfinContentRepository JellyfinContentRepository { get; }
|
||||||
private ILogger Log { get; }
|
private ILogger Log { get; }
|
||||||
private ISettingsService<JellyfinSettings> JellyfinSettings { get; }
|
|
||||||
|
|
||||||
public async Task<RuleResult> Execute(SearchViewModel obj)
|
public async Task<RuleResult> Execute(SearchViewModel obj)
|
||||||
{
|
{
|
||||||
|
@ -82,13 +83,13 @@ 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;
|
||||||
obj.JellyfinUrl = item.Url;
|
obj.JellyfinUrl = item.Url;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if (item.Quality.HasValue())
|
|
||||||
{
|
{
|
||||||
obj.Available = true;
|
obj.Available = true;
|
||||||
obj.EmbyUrl = item.Url;
|
obj.EmbyUrl = item.Url;
|
||||||
|
|
|
@ -281,12 +281,15 @@ namespace Ombi.Schedule.Jobs.Emby
|
||||||
}
|
}
|
||||||
else
|
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}'");
|
_logger.LogDebug($"We have found another quality for Movie '{movieInfo.Name}', Quality: '{quality}'");
|
||||||
existingMovie.Quality = has4K ? null : quality;
|
existingMovie.Quality = has4K ? null : quality;
|
||||||
existingMovie.Has4K = has4K;
|
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);
|
toUpdate.Add(existingMovie);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -245,12 +245,15 @@ namespace Ombi.Schedule.Jobs.Jellyfin
|
||||||
}
|
}
|
||||||
else
|
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}'");
|
_logger.LogDebug($"We have found another quality for Movie '{movieInfo.Name}', Quality: '{quality}'");
|
||||||
existingMovie.Quality = has4K ? null : quality;
|
existingMovie.Quality = has4K ? null : quality;
|
||||||
existingMovie.Has4K = has4K;
|
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);
|
toUpdate.Add(existingMovie);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -105,7 +105,7 @@
|
||||||
</ItemGroup>
|
</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">
|
<Exec Command="node --version" ContinueOnError="true">
|
||||||
<Output TaskParameter="ExitCode" PropertyName="ErrorCode" />
|
<Output TaskParameter="ExitCode" PropertyName="ErrorCode" />
|
||||||
</Exec>
|
</Exec>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue