diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c75a0206..5eb51423c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,71 @@ # Changelog -## (unreleased) +## v3.0.3421 (2018-06-23) + +### **New Features** + +- Added TVRequestsLite. [Jamie] + +- Added a smaller and simplier way of getting TV Request info. [Jamie Rees] + +### **Fixes** + +- Show the popular movies and tv shows by default. [Jamie] + +- Fixed #2348. [Jamie] + + +## v3.0.3407 (2018-06-18) + +### **New Features** + +- Update appveyor.yml. [Jamie] + +- Update build.cake. [Jamie] + +### **Fixes** + +- Fixed the issue where when we find an episode for the recently added sync, we don't check if we should run the availbility checker. [Jamie] + +- Fixed the API not working due to a bug in .Net Core 2.1. [Jamie] + +- Fixed #2321. [Jamie] + +- Maybe this will fix #2298. [Jamie] + +- Fixed #2312. [Jamie] + +- Fixed the SickRage/Medusa Issue where it was always being set as Skipped/Ignore #2084. [Jamie] + +- Fixed the sorting and filtering on the Movie Requests page, it all functions correctly now. [Jamie] + +- Fixed #2288. [Jamie] + +- Upgrade packages. [Jamie] + +- Inital Migration. [Jamie] + +- Fixed #2317. [Jamie] + + +## v3.0.3383 (2018-06-07) + +### **New Features** + +- Update CHANGELOG.md. [Jamie] + +### **Fixes** + +- Minor improvements. [Jamie] + +- Run the availability checker on finish of the recentlty added sync. [Jamie] + +- Fixed the issue with the Recently Added Sync sometimes not working as expected. [Jamie] + +- The UI looks at the local time to see if the JWT token has expired. Use local time to generate the token. [Jamie Rees] + + +## v3.0.3368 (2018-06-03) ### **New Features** @@ -8,6 +73,8 @@ - Added the subscribe button to the search page if we have an existing request. [Jamie Rees] +- Update CHANGELOG.md. [Jamie] + ### **Fixes** - Use selected episodes in submitRequest. [Calvin] diff --git a/src/Ombi.Api.Emby/EmbyApi.cs b/src/Ombi.Api.Emby/EmbyApi.cs index 3af6d0dd5..3ac70c844 100644 --- a/src/Ombi.Api.Emby/EmbyApi.cs +++ b/src/Ombi.Api.Emby/EmbyApi.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Net.Http; using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore.Internal; using Newtonsoft.Json; using Ombi.Api.Emby.Models; using Ombi.Api.Emby.Models.Media.Tv; @@ -100,7 +101,7 @@ namespace Ombi.Api.Emby public async Task> GetAllMovies(string apiKey, string userId, string baseUri) { - return await GetAll("Movie", apiKey, userId, baseUri); + return await GetAll("Movie", apiKey, userId, baseUri, true); } public async Task> GetAllEpisodes(string apiKey, string userId, string baseUri) @@ -129,20 +130,22 @@ namespace Ombi.Api.Emby private async Task GetInformation(string mediaId, string apiKey, string userId, string baseUrl) { var request = new Request($"emby/users/{userId}/items/{mediaId}", baseUrl, HttpMethod.Get); + AddHeaders(request, apiKey); var response = await Api.RequestContent(request); return JsonConvert.DeserializeObject(response); } - - - private async Task> GetAll(string type, string apiKey, string userId, string baseUri) + private async Task> GetAll(string type, string apiKey, string userId, string baseUri, bool includeOverview = false) { var request = new Request($"emby/users/{userId}/items", baseUri, HttpMethod.Get); request.AddQueryString("Recursive", true.ToString()); request.AddQueryString("IncludeItemTypes", type); + request.AddQueryString("Fields", includeOverview ? "ProviderIds,Overview" : "ProviderIds"); + + request.AddQueryString("VirtualItem","False"); AddHeaders(request, apiKey); diff --git a/src/Ombi.Api.Emby/Models/Media/Movie/EmbyMovie.cs b/src/Ombi.Api.Emby/Models/Media/Movie/EmbyMovie.cs index 34038edd8..a10ddaae6 100644 --- a/src/Ombi.Api.Emby/Models/Media/Movie/EmbyMovie.cs +++ b/src/Ombi.Api.Emby/Models/Media/Movie/EmbyMovie.cs @@ -28,5 +28,7 @@ namespace Ombi.Api.Emby.Models.Movie public string MediaType { get; set; } public bool HasSubtitles { get; set; } public int CriticRating { get; set; } + public string Overview { get; set; } + public EmbyProviderids ProviderIds { get; set; } } } \ No newline at end of file diff --git a/src/Ombi.Api.Emby/Models/Media/Tv/EmbyEpisodes.cs b/src/Ombi.Api.Emby/Models/Media/Tv/EmbyEpisodes.cs index d02c99e41..d76915923 100644 --- a/src/Ombi.Api.Emby/Models/Media/Tv/EmbyEpisodes.cs +++ b/src/Ombi.Api.Emby/Models/Media/Tv/EmbyEpisodes.cs @@ -39,5 +39,6 @@ namespace Ombi.Api.Emby.Models.Media.Tv public string LocationType { get; set; } public string MediaType { get; set; } public bool HasSubtitles { get; set; } + public EmbyProviderids ProviderIds { get; set; } } } \ No newline at end of file diff --git a/src/Ombi.Api.Emby/Models/Media/Tv/EmbySeries.cs b/src/Ombi.Api.Emby/Models/Media/Tv/EmbySeries.cs index 853c64d10..2aaf8d492 100644 --- a/src/Ombi.Api.Emby/Models/Media/Tv/EmbySeries.cs +++ b/src/Ombi.Api.Emby/Models/Media/Tv/EmbySeries.cs @@ -26,5 +26,7 @@ namespace Ombi.Api.Emby.Models.Media.Tv public string[] BackdropImageTags { get; set; } public string LocationType { get; set; } public DateTime EndDate { get; set; } + + public EmbyProviderids ProviderIds { get; set; } } } \ No newline at end of file diff --git a/src/Ombi.Api.FanartTv/FanartTvApi.cs b/src/Ombi.Api.FanartTv/FanartTvApi.cs index bc819311c..55caef72c 100644 --- a/src/Ombi.Api.FanartTv/FanartTvApi.cs +++ b/src/Ombi.Api.FanartTv/FanartTvApi.cs @@ -21,6 +21,7 @@ namespace Ombi.Api.FanartTv { var request = new Request($"tv/{tvdbId}", Endpoint, HttpMethod.Get); request.AddHeader("api-key", token); + request.IgnoreErrors = true; try { return await Api.Request(request); @@ -36,6 +37,7 @@ namespace Ombi.Api.FanartTv { var request = new Request($"movies/{movieOrImdbId}", Endpoint, HttpMethod.Get); request.AddHeader("api-key", token); + request.IgnoreErrors = true; return await Api.Request(request); } diff --git a/src/Ombi.Api/Api.cs b/src/Ombi.Api/Api.cs index 98fff5e0c..b0e7066a8 100644 --- a/src/Ombi.Api/Api.cs +++ b/src/Ombi.Api/Api.cs @@ -39,7 +39,11 @@ namespace Ombi.Api if (!httpResponseMessage.IsSuccessStatusCode) { - LogError(request, httpResponseMessage); + if (!request.IgnoreErrors) + { + LogError(request, httpResponseMessage); + } + if (request.Retry) { @@ -94,7 +98,10 @@ namespace Ombi.Api var httpResponseMessage = await _client.SendAsync(httpRequestMessage); if (!httpResponseMessage.IsSuccessStatusCode) { - LogError(request, httpResponseMessage); + if (!request.IgnoreErrors) + { + LogError(request, httpResponseMessage); + } } // do something with the response var data = httpResponseMessage.Content; @@ -112,7 +119,10 @@ namespace Ombi.Api var httpResponseMessage = await _client.SendAsync(httpRequestMessage); if (!httpResponseMessage.IsSuccessStatusCode) { - LogError(request, httpResponseMessage); + if (!request.IgnoreErrors) + { + LogError(request, httpResponseMessage); + } } } } diff --git a/src/Ombi.Api/Request.cs b/src/Ombi.Api/Request.cs index 89c3a7f2d..cfd284f54 100644 --- a/src/Ombi.Api/Request.cs +++ b/src/Ombi.Api/Request.cs @@ -25,7 +25,7 @@ namespace Ombi.Api public string Endpoint { get; } public string BaseUrl { get; } public HttpMethod HttpMethod { get; } - + public bool IgnoreErrors { get; set; } public bool Retry { get; set; } public List StatusCodeToRetry { get; set; } = new List(); diff --git a/src/Ombi.Core.Tests/Ombi.Core.Tests.csproj b/src/Ombi.Core.Tests/Ombi.Core.Tests.csproj index d75ba3411..db98876df 100644 --- a/src/Ombi.Core.Tests/Ombi.Core.Tests.csproj +++ b/src/Ombi.Core.Tests/Ombi.Core.Tests.csproj @@ -9,7 +9,7 @@ - + diff --git a/src/Ombi.Core/Engine/Interfaces/ITvRequestEngine.cs b/src/Ombi.Core/Engine/Interfaces/ITvRequestEngine.cs index 28eb066d4..348dc91e7 100644 --- a/src/Ombi.Core/Engine/Interfaces/ITvRequestEngine.cs +++ b/src/Ombi.Core/Engine/Interfaces/ITvRequestEngine.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using System.Threading.Tasks; using Ombi.Core.Models.Requests; -using Ombi.Core.Models.Search; +using Ombi.Core.Models.UI; using Ombi.Store.Entities.Requests; namespace Ombi.Core.Engine.Interfaces @@ -10,8 +10,10 @@ namespace Ombi.Core.Engine.Interfaces { Task RemoveTvRequest(int requestId); + Task GetTvRequest(int requestId); Task RequestTvShow(TvRequestViewModel tv); Task DenyChildRequest(int requestId); + Task> GetRequestsLite(int count, int position, OrderFilterModel type); Task> SearchTvRequest(string search); Task>>> SearchTvRequestTree(string search); Task UpdateTvRequest(TvRequests request); @@ -20,5 +22,6 @@ namespace Ombi.Core.Engine.Interfaces Task UpdateChildRequest(ChildRequests request); Task RemoveTvChild(int requestId); Task ApproveChildRequest(int id); + Task> GetRequestsLite(); } } \ No newline at end of file diff --git a/src/Ombi.Core/Engine/MovieSearchEngine.cs b/src/Ombi.Core/Engine/MovieSearchEngine.cs index fbda62023..09b4cea6b 100644 --- a/src/Ombi.Core/Engine/MovieSearchEngine.cs +++ b/src/Ombi.Core/Engine/MovieSearchEngine.cs @@ -60,7 +60,6 @@ namespace Ombi.Core.Engine if (result != null) { - Logger.LogDebug("Search Result: {result}", result); return await TransformMovieResultsToResponse(result.Take(10)); // Take 10 to stop us overloading the API } return null; @@ -91,7 +90,6 @@ namespace Ombi.Core.Engine var result = await Cache.GetOrAdd(CacheKeys.PopularMovies, async () => await MovieApi.PopularMovies(), DateTime.Now.AddHours(12)); if (result != null) { - Logger.LogDebug("Search Result: {result}", result); return await TransformMovieResultsToResponse(result.Take(10)); // Take 10 to stop us overloading the API } return null; @@ -106,7 +104,6 @@ namespace Ombi.Core.Engine var result = await Cache.GetOrAdd(CacheKeys.TopRatedMovies, async () => await MovieApi.TopRated(), DateTime.Now.AddHours(12)); if (result != null) { - Logger.LogDebug("Search Result: {result}", result); return await TransformMovieResultsToResponse(result.Take(10)); // Take 10 to stop us overloading the API } return null; @@ -136,7 +133,6 @@ namespace Ombi.Core.Engine var result = await Cache.GetOrAdd(CacheKeys.NowPlayingMovies, async () => await MovieApi.NowPlaying(), DateTime.Now.AddHours(12)); if (result != null) { - Logger.LogDebug("Search Result: {result}", result); return await TransformMovieResultsToResponse(result.Take(10)); // Take 10 to stop us overloading the API } return null; diff --git a/src/Ombi.Core/Engine/TvRequestEngine.cs b/src/Ombi.Core/Engine/TvRequestEngine.cs index 8bb6d86e6..e8fc65a26 100644 --- a/src/Ombi.Core/Engine/TvRequestEngine.cs +++ b/src/Ombi.Core/Engine/TvRequestEngine.cs @@ -168,6 +168,35 @@ namespace Ombi.Core.Engine }; } + public async Task> GetRequestsLite(int count, int position, OrderFilterModel type) + { + var shouldHide = await HideFromOtherUsers(); + List allRequests; + if (shouldHide.Hide) + { + allRequests = await TvRepository.GetLite(shouldHide.UserId) + .OrderByDescending(x => x.ChildRequests.Max(y => y.RequestedDate)) + .Skip(position).Take(count).ToListAsync(); + + // Filter out children + + FilterChildren(allRequests, shouldHide); + } + else + { + allRequests = await TvRepository.GetLite() + .OrderByDescending(x => x.ChildRequests.Max(y => y.RequestedDate)) + .Skip(position).Take(count).ToListAsync(); + } + + allRequests.ForEach(async r => { await CheckForSubscription(shouldHide, r); }); + + return new RequestsViewModel + { + Collection = allRequests + }; + } + public async Task>>> GetRequestsTreeNode(int count, int position) { var shouldHide = await HideFromOtherUsers(); @@ -178,6 +207,7 @@ namespace Ombi.Core.Engine .Include(x => x.ChildRequests) .ThenInclude(x => x.SeasonRequests) .ThenInclude(x => x.Episodes) + .Where(x => x.ChildRequests.Any()) .OrderByDescending(x => x.ChildRequests.Max(y => y.RequestedDate)) .Skip(position).Take(count).ToListAsync(); @@ -189,6 +219,7 @@ namespace Ombi.Core.Engine .Include(x => x.ChildRequests) .ThenInclude(x => x.SeasonRequests) .ThenInclude(x => x.Episodes) + .Where(x => x.ChildRequests.Any()) .OrderByDescending(x => x.ChildRequests.Max(y => y.RequestedDate)) .Skip(position).Take(count).ToListAsync(); } @@ -216,6 +247,45 @@ namespace Ombi.Core.Engine return allRequests; } + + public async Task> GetRequestsLite() + { + var shouldHide = await HideFromOtherUsers(); + List allRequests; + if (shouldHide.Hide) + { + allRequests = await TvRepository.GetLite(shouldHide.UserId).ToListAsync(); + + FilterChildren(allRequests, shouldHide); + } + else + { + allRequests = await TvRepository.GetLite().ToListAsync(); + } + + allRequests.ForEach(async r => { await CheckForSubscription(shouldHide, r); }); + return allRequests; + } + + public async Task GetTvRequest(int requestId) + { + var shouldHide = await HideFromOtherUsers(); + TvRequests request; + if (shouldHide.Hide) + { + request = await TvRepository.Get(shouldHide.UserId).Where(x => x.Id == requestId).FirstOrDefaultAsync(); + + FilterChildren(request, shouldHide); + } + else + { + request = await TvRepository.Get().Where(x => x.Id == requestId).FirstOrDefaultAsync(); + } + + await CheckForSubscription(shouldHide, request); + return request; + } + private static void FilterChildren(IEnumerable allRequests, HideResult shouldHide) { // Filter out children @@ -223,16 +293,27 @@ namespace Ombi.Core.Engine { for (var j = 0; j < t.ChildRequests.Count; j++) { - var child = t.ChildRequests[j]; - if (child.RequestedUserId != shouldHide.UserId) - { - t.ChildRequests.RemoveAt(j); - j--; - } + FilterChildren(t, shouldHide); } } } + private static void FilterChildren(TvRequests t, HideResult shouldHide) + { + // Filter out children + + for (var j = 0; j < t.ChildRequests.Count; j++) + { + var child = t.ChildRequests[j]; + if (child.RequestedUserId != shouldHide.UserId) + { + t.ChildRequests.RemoveAt(j); + j--; + } + } + + } + public async Task> GetAllChldren(int tvId) { var shouldHide = await HideFromOtherUsers(); @@ -468,7 +549,7 @@ namespace Ombi.Core.Engine { foreach (var tv in x.ChildRequests) { - await CheckForSubscription(shouldHide, tv); + await CheckForSubscription(shouldHide, tv); } } diff --git a/src/Ombi.Helpers/OmbiRoles.cs b/src/Ombi.Helpers/OmbiRoles.cs index ba8c8d087..5b62a2bae 100644 --- a/src/Ombi.Helpers/OmbiRoles.cs +++ b/src/Ombi.Helpers/OmbiRoles.cs @@ -11,6 +11,6 @@ public const string RequestTv = nameof(RequestTv); public const string RequestMovie = nameof(RequestMovie); public const string Disabled = nameof(Disabled); - public const string RecievesNewsletter = nameof(RecievesNewsletter); + public const string ReceivesNewsletter = nameof(ReceivesNewsletter); } } \ No newline at end of file diff --git a/src/Ombi.Notifications.Templates/Templates/NewsletterTemplate.html b/src/Ombi.Notifications.Templates/Templates/NewsletterTemplate.html index 81190334a..450e7df2a 100644 --- a/src/Ombi.Notifications.Templates/Templates/NewsletterTemplate.html +++ b/src/Ombi.Notifications.Templates/Templates/NewsletterTemplate.html @@ -182,14 +182,16 @@ - {@RECENTLYADDED} + {@RECENTLYADDED} + +