mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-12 08:16:05 -07:00
Merge branch 'develop' of https://github.com/tidusjar/ombi into develop
This commit is contained in:
commit
b56b68191f
2 changed files with 60 additions and 3 deletions
|
@ -98,7 +98,7 @@ namespace Ombi.Api.Emby
|
|||
|
||||
request.AddQueryString("Fields", "ProviderIds,Overview");
|
||||
|
||||
request.AddQueryString("VirtualItem", "False");
|
||||
request.AddQueryString("IsVirtualItem", "False");
|
||||
|
||||
return await Api.Request<EmbyItemContainer<EmbyMovie>>(request);
|
||||
}
|
||||
|
@ -149,7 +149,7 @@ namespace Ombi.Api.Emby
|
|||
request.AddQueryString("IncludeItemTypes", type);
|
||||
request.AddQueryString("Fields", includeOverview ? "ProviderIds,Overview" : "ProviderIds");
|
||||
|
||||
request.AddQueryString("VirtualItem", "False");
|
||||
request.AddQueryString("IsVirtualItem", "False");
|
||||
|
||||
AddHeaders(request, apiKey);
|
||||
|
||||
|
@ -167,7 +167,7 @@ namespace Ombi.Api.Emby
|
|||
request.AddQueryString("startIndex", startIndex.ToString());
|
||||
request.AddQueryString("limit", count.ToString());
|
||||
|
||||
request.AddQueryString("VirtualItem", "False");
|
||||
request.AddQueryString("IsVirtualItem", "False");
|
||||
|
||||
AddHeaders(request, apiKey);
|
||||
|
||||
|
|
57
src/Ombi.Core/Rule/Rules/Request/ExistingTVRequestRule.cs
Normal file
57
src/Ombi.Core/Rule/Rules/Request/ExistingTVRequestRule.cs
Normal file
|
@ -0,0 +1,57 @@
|
|||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Ombi.Core.Rule.Interfaces;
|
||||
using Ombi.Store.Entities;
|
||||
using Ombi.Store.Entities.Requests;
|
||||
using Ombi.Store.Repository.Requests;
|
||||
|
||||
namespace Ombi.Core.Rule.Rules.Request
|
||||
{
|
||||
public class ExistingTvRequestRule : BaseRequestRule, IRules<BaseRequest>
|
||||
{
|
||||
public ExistingTvRequestRule(ITvRequestRepository rv)
|
||||
{
|
||||
Tv = rv;
|
||||
}
|
||||
|
||||
private ITvRequestRepository Tv { get; }
|
||||
|
||||
/// <summary>
|
||||
/// We check if the request exists, if it does then we don't want to re-request it.
|
||||
/// </summary>
|
||||
/// <param name="obj">The object.</param>
|
||||
/// <returns></returns>
|
||||
public async Task<RuleResult> Execute(BaseRequest obj)
|
||||
{
|
||||
if (obj.RequestType == RequestType.TvShow)
|
||||
{
|
||||
var tv = (ChildRequests) obj;
|
||||
var tvRequests = Tv.GetChild();
|
||||
var currentRequest = await tvRequests.FirstOrDefaultAsync(x => x.ParentRequest.TvDbId == tv.Id); // the Id on the child is the tvdbid at this point
|
||||
if (currentRequest == null)
|
||||
{
|
||||
return Success();
|
||||
}
|
||||
foreach (var season in tv.SeasonRequests)
|
||||
{
|
||||
var currentSeasonRequest =
|
||||
currentRequest.SeasonRequests.FirstOrDefault(x => x.SeasonNumber == season.SeasonNumber);
|
||||
if (currentSeasonRequest == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
foreach (var e in season.Episodes)
|
||||
{
|
||||
var hasEpisode = currentSeasonRequest.Episodes.Any(x => x.EpisodeNumber == e.EpisodeNumber);
|
||||
if (hasEpisode)
|
||||
{
|
||||
return Fail($"We already have episodes requested from series {tv.Title}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return Success();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue