mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-12 08:16:05 -07:00
Fixed a load of bugs need to figure out what is wrong with tv requests #865
This commit is contained in:
parent
2bc916998c
commit
386f856ea7
7 changed files with 66 additions and 32 deletions
|
@ -81,6 +81,7 @@ namespace Ombi.Core.Engine
|
||||||
RequestedDate = DateTime.UtcNow,
|
RequestedDate = DateTime.UtcNow,
|
||||||
Approved = false,
|
Approved = false,
|
||||||
RequestedUserId = user.Id,
|
RequestedUserId = user.Id,
|
||||||
|
SeasonRequests = new List<SeasonRequests>()
|
||||||
};
|
};
|
||||||
|
|
||||||
if (tv.LatestSeason)
|
if (tv.LatestSeason)
|
||||||
|
@ -112,13 +113,16 @@ namespace Ombi.Core.Engine
|
||||||
var episodesRequests = new List<EpisodeRequests>();
|
var episodesRequests = new List<EpisodeRequests>();
|
||||||
foreach (var ep in episodes)
|
foreach (var ep in episodes)
|
||||||
{
|
{
|
||||||
episodesRequests.Add(new EpisodeRequests
|
if (ep.season == first.season)
|
||||||
{
|
{
|
||||||
EpisodeNumber = ep.number,
|
episodesRequests.Add(new EpisodeRequests
|
||||||
AirDate = DateTime.Parse(ep.airdate),
|
{
|
||||||
Title = ep.name,
|
EpisodeNumber = ep.number,
|
||||||
Url = ep.url
|
AirDate = DateTime.Parse(ep.airdate),
|
||||||
});
|
Title = ep.name,
|
||||||
|
Url = ep.url
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
childRequest.SeasonRequests.Add(new SeasonRequests
|
childRequest.SeasonRequests.Add(new SeasonRequests
|
||||||
{
|
{
|
||||||
|
|
|
@ -77,15 +77,16 @@ namespace Ombi.Core.Engine
|
||||||
});
|
});
|
||||||
mapped.SeasonRequests.Add(newSeason);
|
mapped.SeasonRequests.Add(newSeason);
|
||||||
}
|
}
|
||||||
else
|
//else
|
||||||
{
|
//{
|
||||||
// Find the episode
|
// // Find the episode
|
||||||
var ep = season.Episodes.FirstOrDefault(x => x.EpisodeNumber == e.number);
|
// var ep = episodes.FirstOrDefault(x => x.number == e.number);
|
||||||
ep.Url = e.url;
|
|
||||||
ep.Title = e.name;
|
// ep.Url = e.url;
|
||||||
ep.AirDate = DateTime.Parse(e.airstamp);
|
// ep.Title = e.name;
|
||||||
ep.EpisodeNumber = e.number;
|
// ep.AirDate = DateTime.Parse(e.airstamp);
|
||||||
}
|
// ep.EpisodeNumber = e.number;
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
var existingRequests = await GetTvRequests();
|
var existingRequests = await GetTvRequests();
|
||||||
|
@ -180,6 +181,10 @@ namespace Ombi.Core.Engine
|
||||||
{
|
{
|
||||||
// Find the episode from what we are searching
|
// Find the episode from what we are searching
|
||||||
var episodeSearching = season.Episodes.FirstOrDefault(x => x.EpisodeNumber == ep.EpisodeNumber);
|
var episodeSearching = season.Episodes.FirstOrDefault(x => x.EpisodeNumber == ep.EpisodeNumber);
|
||||||
|
if(episodeSearching == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
episodeSearching.Requested = true;
|
episodeSearching.Requested = true;
|
||||||
episodeSearching.Available = ep.Available;
|
episodeSearching.Available = ep.Available;
|
||||||
episodeSearching.Approved = ep.Season.ChildRequest.Approved;
|
episodeSearching.Approved = ep.Season.ChildRequest.Approved;
|
||||||
|
|
|
@ -7,24 +7,26 @@ using Ombi.Core.Models.Requests.Tv;
|
||||||
using Ombi.Core.Models.Search;
|
using Ombi.Core.Models.Search;
|
||||||
using Ombi.Core.Requests.Models;
|
using Ombi.Core.Requests.Models;
|
||||||
using Ombi.Core.Rule.Interfaces;
|
using Ombi.Core.Rule.Interfaces;
|
||||||
|
using Ombi.Store.Repository;
|
||||||
|
using Ombi.Store.Repository.Requests;
|
||||||
|
|
||||||
namespace Ombi.Core.Rule.Rules.Search
|
namespace Ombi.Core.Rule.Rules.Search
|
||||||
{
|
{
|
||||||
public class ExistingRequestRule : BaseSearchRule, IRequestRules<SearchViewModel>
|
public class ExistingRequestRule : BaseSearchRule, IRequestRules<SearchViewModel>
|
||||||
{
|
{
|
||||||
public ExistingRequestRule(IRequestService<MovieRequestModel> movie, IRequestService<TvRequestModel> tv)
|
public ExistingRequestRule(IMovieRequestRepository movie, ITvRequestRepository tv)
|
||||||
{
|
{
|
||||||
Movie = movie;
|
Movie = movie;
|
||||||
Tv = tv;
|
Tv = tv;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IRequestService<MovieRequestModel> Movie { get; }
|
private IMovieRequestRepository Movie { get; }
|
||||||
private IRequestService<TvRequestModel> Tv { get; }
|
private ITvRequestRepository Tv { get; }
|
||||||
|
|
||||||
public async Task<RuleResult> Execute(SearchViewModel obj)
|
public async Task<RuleResult> Execute(SearchViewModel obj)
|
||||||
{
|
{
|
||||||
var movieRequests = await Movie.GetAllAsync();
|
var movieRequests = Movie.Get();
|
||||||
var existing = movieRequests.FirstOrDefault(x => x.ProviderId == obj.Id);
|
var existing = await movieRequests.FirstOrDefaultAsync(x => x.TheMovieDbId == obj.Id);
|
||||||
if (existing != null) // Do we already have a request for this?
|
if (existing != null) // Do we already have a request for this?
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -35,14 +37,14 @@ namespace Ombi.Core.Rule.Rules.Search
|
||||||
return Success();
|
return Success();
|
||||||
}
|
}
|
||||||
|
|
||||||
var tvRequests = await Tv.GetAllAsync();
|
var tvRequests = Tv.Get();
|
||||||
var tv = tvRequests.FirstOrDefault(x => x.ProviderId == obj.Id);
|
var tv = await tvRequests.FirstOrDefaultAsync(x => x.TvDbId == obj.Id);
|
||||||
if (tv != null) // Do we already have a request for this?
|
if (tv != null) // Do we already have a request for this?
|
||||||
{
|
{
|
||||||
|
|
||||||
obj.Requested = true;
|
obj.Requested = true;
|
||||||
obj.Approved = tv.Approved;
|
obj.Approved = tv.ChildRequests.Any(x => x.Approved);
|
||||||
obj.Available = tv.Available;
|
obj.Available = tv.ChildRequests.Any(x => x.Available);
|
||||||
|
|
||||||
return Success();
|
return Success();
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,27 +18,30 @@ namespace Ombi.Store.Repository.Requests
|
||||||
public async Task<TvRequests> GetRequest(int tvDbId)
|
public async Task<TvRequests> GetRequest(int tvDbId)
|
||||||
{
|
{
|
||||||
return await Db.TvRequests.Where(x => x.TvDbId == tvDbId)
|
return await Db.TvRequests.Where(x => x.TvDbId == tvDbId)
|
||||||
.Include(x => x.ChildRequests)
|
|
||||||
.ThenInclude(x => x.Issues)
|
|
||||||
.Include(x => x.ChildRequests)
|
.Include(x => x.ChildRequests)
|
||||||
.ThenInclude(x => x.RequestedUser)
|
.ThenInclude(x => x.RequestedUser)
|
||||||
|
.Include(x => x.ChildRequests)
|
||||||
|
.ThenInclude(x => x.SeasonRequests)
|
||||||
|
.ThenInclude(x => x.Episodes)
|
||||||
.FirstOrDefaultAsync();
|
.FirstOrDefaultAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IQueryable<TvRequests> Get()
|
public IQueryable<TvRequests> Get()
|
||||||
{
|
{
|
||||||
return Db.TvRequests
|
return Db.TvRequests
|
||||||
.Include(x => x.ChildRequests)
|
|
||||||
.ThenInclude(x => x.Issues)
|
|
||||||
.Include(x => x.ChildRequests)
|
.Include(x => x.ChildRequests)
|
||||||
.ThenInclude(x => x.RequestedUser)
|
.ThenInclude(x => x.RequestedUser)
|
||||||
|
.Include(x => x.ChildRequests)
|
||||||
|
.ThenInclude(x => x.SeasonRequests)
|
||||||
|
.ThenInclude(x => x.Episodes)
|
||||||
.AsQueryable();
|
.AsQueryable();
|
||||||
}
|
}
|
||||||
public IQueryable<ChildRequests> GetChild()
|
public IQueryable<ChildRequests> GetChild()
|
||||||
{
|
{
|
||||||
return Db.ChildRequests
|
return Db.ChildRequests
|
||||||
.Include(x => x.Issues)
|
|
||||||
.Include(x => x.RequestedUser)
|
.Include(x => x.RequestedUser)
|
||||||
|
.Include(x => x.SeasonRequests)
|
||||||
|
.ThenInclude(x => x.Episodes)
|
||||||
.AsQueryable();
|
.AsQueryable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,16 @@ namespace Ombi.Auth
|
||||||
// If the request path doesn't match, skip
|
// If the request path doesn't match, skip
|
||||||
if (!context.Request.Path.Equals(_options.Path, StringComparison.Ordinal))
|
if (!context.Request.Path.Equals(_options.Path, StringComparison.Ordinal))
|
||||||
{
|
{
|
||||||
return _next(context);
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
return _next(context);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
|
||||||
|
throw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Request must be POST with Content-Type: application/json
|
// Request must be POST with Content-Type: application/json
|
||||||
|
|
|
@ -40,7 +40,8 @@ export class RequestService extends ServiceAuthHelpers {
|
||||||
}
|
}
|
||||||
|
|
||||||
getTvRequests(count: number, position: number): Observable<ITvRequests[]> {
|
getTvRequests(count: number, position: number): Observable<ITvRequests[]> {
|
||||||
return this.http.get(`${this.url}tv/${count}/${position}`).map(this.extractData);
|
return this.http.get(`${this.url}tv/${count}/${position}`).map(this.extractData)
|
||||||
|
.catch(this.handleError);
|
||||||
}
|
}
|
||||||
|
|
||||||
searchTvRequests(search: string): Observable<ITvRequests[]> {
|
searchTvRequests(search: string): Observable<ITvRequests[]> {
|
||||||
|
|
|
@ -7,6 +7,7 @@ using Ombi.Core.Models.Search;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Ombi.Store.Entities.Requests;
|
using Ombi.Store.Entities.Requests;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace Ombi.Controllers
|
namespace Ombi.Controllers
|
||||||
{
|
{
|
||||||
|
@ -95,7 +96,16 @@ namespace Ombi.Controllers
|
||||||
[HttpGet("tv/{count:int}/{position:int}")]
|
[HttpGet("tv/{count:int}/{position:int}")]
|
||||||
public async Task<IEnumerable<TvRequests>> GetTvRequests(int count, int position)
|
public async Task<IEnumerable<TvRequests>> GetTvRequests(int count, int position)
|
||||||
{
|
{
|
||||||
return await TvRequestEngine.GetRequests(count, position);
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
return await TvRequestEngine.GetRequests(count, position);
|
||||||
|
}
|
||||||
|
catch (System.Exception e)
|
||||||
|
{
|
||||||
|
Debug.WriteLine(e.Message);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue