mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-19 12:59:39 -07:00
Quick change to the Emby Availability rule to make it in line slightly with the Plex one. #1950
This commit is contained in:
parent
6227e11543
commit
c3c85b0ae0
1 changed files with 25 additions and 11 deletions
|
|
@ -3,6 +3,7 @@ using System.Threading.Tasks;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Ombi.Core.Models.Search;
|
using Ombi.Core.Models.Search;
|
||||||
using Ombi.Core.Rule.Interfaces;
|
using Ombi.Core.Rule.Interfaces;
|
||||||
|
using Ombi.Helpers;
|
||||||
using Ombi.Store.Entities;
|
using Ombi.Store.Entities;
|
||||||
using Ombi.Store.Repository;
|
using Ombi.Store.Repository;
|
||||||
|
|
||||||
|
|
@ -20,35 +21,48 @@ namespace Ombi.Core.Rule.Rules.Search
|
||||||
public async Task<RuleResult> Execute(SearchViewModel obj)
|
public async Task<RuleResult> Execute(SearchViewModel obj)
|
||||||
{
|
{
|
||||||
EmbyContent item = null;
|
EmbyContent item = null;
|
||||||
if (obj.Type == RequestType.Movie)
|
if (obj.ImdbId.HasValue())
|
||||||
{
|
{
|
||||||
item = await EmbyContentRepository.Get(obj.ImdbId);
|
item = await EmbyContentRepository.Get(obj.ImdbId);
|
||||||
|
}
|
||||||
if (item == null)
|
if (item == null)
|
||||||
|
{
|
||||||
|
if (obj.TheMovieDbId.HasValue())
|
||||||
{
|
{
|
||||||
item = await EmbyContentRepository.Get(obj.TheMovieDbId);
|
item = await EmbyContentRepository.Get(obj.TheMovieDbId);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
if (item == null)
|
||||||
|
{
|
||||||
|
if (obj.TheTvDbId.HasValue())
|
||||||
{
|
{
|
||||||
item = await EmbyContentRepository.Get(obj.TheTvDbId);
|
item = await EmbyContentRepository.Get(obj.TheTvDbId);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (item != null)
|
if (item != null)
|
||||||
{
|
{
|
||||||
obj.Available = true;
|
obj.Available = true;
|
||||||
|
|
||||||
if (obj.Type == RequestType.TvShow)
|
if (obj.Type == RequestType.TvShow)
|
||||||
{
|
{
|
||||||
var searchResult = (SearchTvShowViewModel)obj;
|
var search = (SearchTvShowViewModel)obj;
|
||||||
// Let's go through the episodes now
|
// Let's go through the episodes now
|
||||||
if (searchResult.SeasonRequests.Any())
|
if (search.SeasonRequests.Any())
|
||||||
{
|
{
|
||||||
var allEpisodes = EmbyContentRepository.GetAllEpisodes().Include(x => x.Series);
|
var allEpisodes = EmbyContentRepository.GetAllEpisodes().Include(x => x.Series);
|
||||||
foreach (var season in searchResult.SeasonRequests)
|
foreach (var season in search.SeasonRequests)
|
||||||
{
|
{
|
||||||
foreach (var episode in season.Episodes)
|
foreach (var episode in season.Episodes)
|
||||||
{
|
{
|
||||||
var epExists = await allEpisodes.FirstOrDefaultAsync(x =>
|
EmbyEpisode epExists = null;
|
||||||
x.EpisodeNumber == episode.EpisodeNumber && x.SeasonNumber == season.SeasonNumber && item.ProviderId.ToString() == searchResult.Id.ToString());
|
|
||||||
|
epExists = await allEpisodes.FirstOrDefaultAsync(x =>
|
||||||
|
x.EpisodeNumber == episode.EpisodeNumber && x.SeasonNumber == season.SeasonNumber &&
|
||||||
|
x.Series.ProviderId == item.ProviderId.ToString());
|
||||||
|
|
||||||
|
|
||||||
if (epExists != null)
|
if (epExists != null)
|
||||||
{
|
{
|
||||||
episode.Available = true;
|
episode.Available = true;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue