mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-30 11:38:32 -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 Ombi.Core.Models.Search;
|
||||
using Ombi.Core.Rule.Interfaces;
|
||||
using Ombi.Helpers;
|
||||
using Ombi.Store.Entities;
|
||||
using Ombi.Store.Repository;
|
||||
|
||||
|
@ -20,35 +21,48 @@ namespace Ombi.Core.Rule.Rules.Search
|
|||
public async Task<RuleResult> Execute(SearchViewModel obj)
|
||||
{
|
||||
EmbyContent item = null;
|
||||
if (obj.Type == RequestType.Movie)
|
||||
if (obj.ImdbId.HasValue())
|
||||
{
|
||||
item = await EmbyContentRepository.Get(obj.ImdbId);
|
||||
if (item == null)
|
||||
}
|
||||
if (item == null)
|
||||
{
|
||||
if (obj.TheMovieDbId.HasValue())
|
||||
{
|
||||
item = await EmbyContentRepository.Get(obj.TheMovieDbId);
|
||||
}
|
||||
|
||||
if (item == null)
|
||||
{
|
||||
if (obj.TheTvDbId.HasValue())
|
||||
{
|
||||
item = await EmbyContentRepository.Get(obj.TheTvDbId);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
item = await EmbyContentRepository.Get(obj.TheTvDbId);
|
||||
}
|
||||
|
||||
if (item != null)
|
||||
{
|
||||
obj.Available = true;
|
||||
|
||||
if (obj.Type == RequestType.TvShow)
|
||||
{
|
||||
var searchResult = (SearchTvShowViewModel)obj;
|
||||
var search = (SearchTvShowViewModel)obj;
|
||||
// Let's go through the episodes now
|
||||
if (searchResult.SeasonRequests.Any())
|
||||
if (search.SeasonRequests.Any())
|
||||
{
|
||||
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)
|
||||
{
|
||||
var epExists = await allEpisodes.FirstOrDefaultAsync(x =>
|
||||
x.EpisodeNumber == episode.EpisodeNumber && x.SeasonNumber == season.SeasonNumber && item.ProviderId.ToString() == searchResult.Id.ToString());
|
||||
EmbyEpisode epExists = null;
|
||||
|
||||
epExists = await allEpisodes.FirstOrDefaultAsync(x =>
|
||||
x.EpisodeNumber == episode.EpisodeNumber && x.SeasonNumber == season.SeasonNumber &&
|
||||
x.Series.ProviderId == item.ProviderId.ToString());
|
||||
|
||||
|
||||
if (epExists != null)
|
||||
{
|
||||
episode.Available = true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue