From 97ab1affa0b7a431f42982f066f0e155a764a481 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Sat, 27 Feb 2021 02:43:15 +0100 Subject: [PATCH] Adding a 'fields' query param to every requests to load related data --- Kyoo.Common/Controllers/ILibraryManager.cs | 13 +- .../Implementations/LibraryManager.cs | 114 ++++++++++++------ Kyoo.Common/Utility.cs | 20 ++- Kyoo.CommonAPI/CrudApi.cs | 10 +- Kyoo.CommonAPI/ResourceViewAttribute.cs | 60 +++++++++ Kyoo/Views/API/CollectionApi.cs | 16 --- Kyoo/Views/API/EpisodeApi.cs | 12 +- Kyoo/Views/API/GenreApi.cs | 8 -- Kyoo/Views/API/LibraryApi.cs | 24 ---- Kyoo/Views/API/LibraryItemApi.cs | 4 - Kyoo/Views/API/PeopleApi.cs | 8 -- Kyoo/Views/API/SeasonApi.cs | 12 -- Kyoo/Views/API/ShowApi.cs | 48 -------- Kyoo/Views/API/StudioApi.cs | 8 -- 14 files changed, 166 insertions(+), 191 deletions(-) create mode 100644 Kyoo.CommonAPI/ResourceViewAttribute.cs diff --git a/Kyoo.Common/Controllers/ILibraryManager.cs b/Kyoo.Common/Controllers/ILibraryManager.cs index 30129de8..f3f0910a 100644 --- a/Kyoo.Common/Controllers/ILibraryManager.cs +++ b/Kyoo.Common/Controllers/ILibraryManager.cs @@ -61,14 +61,19 @@ namespace Kyoo.Controllers Task GetStudio(Expression> where); Task GetPerson(Expression> where); - Task Load([NotNull] T obj, [CanBeNull] Expression> member) + Task Load([NotNull] T obj, Expression> member) where T : class, IResource where T2 : class, IResource, new(); - - Task Load([NotNull] T obj, [CanBeNull] Expression>> member) + + Task Load([NotNull] T obj, Expression>> member) where T : class, IResource where T2 : class, new(); - + + Task Load(T obj, string memberName) + where T : class, IResource; + + Task Load(IResource obj, string memberName); + // Library Items relations Task> GetItemsFromLibrary(int id, Expression> where = null, diff --git a/Kyoo.Common/Controllers/Implementations/LibraryManager.cs b/Kyoo.Common/Controllers/Implementations/LibraryManager.cs index d239f401..ad1554a6 100644 --- a/Kyoo.Common/Controllers/Implementations/LibraryManager.cs +++ b/Kyoo.Common/Controllers/Implementations/LibraryManager.cs @@ -236,83 +236,117 @@ namespace Kyoo.Controllers return PeopleRepository.Get(where); } - public Task Load(T obj, Expression> member) + public Task Load(T obj, Expression> member) where T : class, IResource where T2 : class, IResource, new() { - return (obj, new T2()) switch - { - (Show s, Studio) => StudioRepository.Get(x => x.Shows.Any(Utility.ResourceEqualsFunc(obj))) - .Then(x => s.Studio = x), - - (Season s, Show) => ShowRepository.Get(Utility.ResourceEquals(obj)).Then(x => s.Show = x), - - (Episode e, Show) => ShowRepository.Get(Utility.ResourceEquals(obj)).Then(x => e.Show = x), - (Episode e, Season) => SeasonRepository.Get(Utility.ResourceEquals(obj)) - .Then(x => e.Season = x), - - (Track t, Episode) => EpisodeRepository.Get(Utility.ResourceEquals(obj)) - .Then(x => t.Episode = x), - - _ => throw new ArgumentException($"Couldn't find a way to load {member} of {typeof(T).Name}.") - }; + if (member == null) + throw new ArgumentNullException(nameof(member)); + return Load(obj, Utility.GetPropertyName(member)); } - public Task Load(T obj, Expression>> member) + public Task Load(T obj, Expression>> member) where T : class, IResource where T2 : class, new() { - return (obj, new T2()) switch + if (member == null) + throw new ArgumentNullException(nameof(member)); + return Load(obj, Utility.GetPropertyName(member)); + } + + public async Task Load(T obj, string member) + where T : class, IResource + { + await Load(obj as IResource, member); + return obj; + } + + public Task Load(IResource obj, string member) + { + return (obj, member) switch { - (Library l, ProviderID) => ProviderRepository.GetAll(Utility.ResourceEquals(obj)) + (Library l, nameof(Library.Providers)) => ProviderRepository + .GetAll(Utility.ResourceEquals(obj)) .Then(x => l.Providers = x), - (Library l, Show) => ShowRepository.GetAll(Utility.ResourceEquals(obj)) + (Library l, nameof(Library.Shows)) => ShowRepository.GetAll(Utility.ResourceEquals(obj)) .Then(x => l.Shows = x), - (Library l, Collection) => CollectionRepository.GetAll(Utility.ResourceEquals(obj)) + (Library l, nameof(Library.Collections)) => CollectionRepository + .GetAll(Utility.ResourceEquals(obj)) .Then(x => l.Collections = x), - (Collection c, Show) => ShowRepository.GetAll(Utility.ResourceEquals(obj)) + (Collection c, nameof(Library.Shows)) => ShowRepository + .GetAll(Utility.ResourceEquals(obj)) .Then(x => c.Shows = x), - (Collection c, Library) => LibraryRepository.GetAll(Utility.ResourceEquals(obj)) + (Collection c, nameof(Collection.Libraries)) => LibraryRepository + .GetAll(Utility.ResourceEquals(obj)) .Then(x => c.Libraries = x), - (Show s, MetadataID) => ProviderRepository.GetMetadataID(x => x.ShowID == obj.ID) + (Show s, nameof(Show.ExternalIDs)) => ProviderRepository + .GetMetadataID(x => x.ShowID == obj.ID) .Then(x => s.ExternalIDs = x), - (Show s, Genre) => GenreRepository.GetAll(Utility.ResourceEquals(obj)) + (Show s, nameof(Show.Genres)) => GenreRepository + .GetAll(Utility.ResourceEquals(obj)) .Then(x => s.Genres = x), - (Show s, PeopleRole) => (PeopleRepository.GetFromShow((dynamic)(obj.ID > 0 ? obj.ID : obj.Slug)) + (Show s, nameof(Show.People)) => ( + PeopleRepository.GetFromShow((dynamic)(obj.ID > 0 ? obj.ID : obj.Slug)) as Task>).Then(x => s.People = x), - (Show s, Season) => SeasonRepository.GetAll(Utility.ResourceEquals(obj)) + (Show s, nameof(Show.Seasons)) => SeasonRepository + .GetAll(Utility.ResourceEquals(obj)) .Then(x => s.Seasons = x), - (Show s, Episode) => EpisodeRepository.GetAll(Utility.ResourceEquals(obj)) + (Show s, nameof(Show.Episodes)) => EpisodeRepository + .GetAll(Utility.ResourceEquals(obj)) .Then(x => s.Episodes = x), - (Show s, Library) => LibraryRepository.GetAll(Utility.ResourceEquals(obj)) + (Show s, nameof(Show.Libraries)) => LibraryRepository + .GetAll(Utility.ResourceEquals(obj)) .Then(x => s.Libraries = x), - (Show s, Collection) => CollectionRepository.GetAll(Utility.ResourceEquals(obj)) + (Show s, nameof(Show.Collections)) => CollectionRepository + .GetAll(Utility.ResourceEquals(obj)) .Then(x => s.Collections = x), + (Show s, nameof(Show.Studio)) => StudioRepository + .Get(x => x.Shows.Any(Utility.ResourceEqualsFunc(obj))) + .Then(x => s.Studio = x), - (Season s, MetadataID) => ProviderRepository.GetMetadataID(x => x.SeasonID == obj.ID) + (Season s, nameof(Season.ExternalIDs)) => ProviderRepository + .GetMetadataID(x => x.SeasonID == obj.ID) .Then(x => s.ExternalIDs = x), - (Season s, Episode) => EpisodeRepository.GetAll(Utility.ResourceEquals(obj)) + (Season s, nameof(Season.Episodes)) => EpisodeRepository + .GetAll(Utility.ResourceEquals(obj)) .Then(x => s.Episodes = x), + (Season s, nameof(Season.Show)) => ShowRepository + .Get(Utility.ResourceEquals(obj)).Then(x => s.Show = x), - (Episode e, MetadataID) => ProviderRepository.GetMetadataID(x => x.EpisodeID == obj.ID) + (Episode e, nameof(Episode.ExternalIDs)) => ProviderRepository + .GetMetadataID(x => x.EpisodeID == obj.ID) .Then(x => e.ExternalIDs = x), - (Episode e, Track) => TrackRepository.GetAll(Utility.ResourceEquals(obj)) + (Episode e, nameof(Episode.Tracks)) => TrackRepository + .GetAll(Utility.ResourceEquals(obj)) .Then(x => e.Tracks = x), + (Episode e, nameof(Episode.Show)) => ShowRepository + .Get(Utility.ResourceEquals(obj)).Then(x => e.Show = x), + (Episode e, nameof(Episode.Season)) => SeasonRepository + .Get(Utility.ResourceEquals(obj)) + .Then(x => e.Season = x), - (Genre g, Show) => ShowRepository.GetAll(Utility.ResourceEquals(obj)) + (Track t, nameof(Track.Episode)) => EpisodeRepository + .Get(Utility.ResourceEquals(obj)) + .Then(x => t.Episode = x), + + (Genre g, nameof(Genre.Shows)) => ShowRepository + .GetAll(Utility.ResourceEquals(obj)) .Then(x => g.Shows = x), - (Studio s, Show) => ShowRepository.GetAll(Utility.ResourceEquals(obj)) + (Studio s, nameof(Studio.Shows)) => ShowRepository + .GetAll(Utility.ResourceEquals(obj)) .Then(x => s.Shows = x), - (People p, MetadataID) => ProviderRepository.GetMetadataID(x => x.PeopleID == obj.ID) + (People p, nameof(People.ExternalIDs)) => ProviderRepository + .GetMetadataID(x => x.PeopleID == obj.ID) .Then(x => p.ExternalIDs = x), - (People p, PeopleRole) => (PeopleRepository.GetFromPeople((dynamic)(obj.ID > 0 ? obj.ID : obj.Slug)) + (People p, nameof(People.Roles)) => ( + PeopleRepository.GetFromPeople((dynamic)(obj.ID > 0 ? obj.ID : obj.Slug)) as Task>).Then(x => p.Roles = x), - _ => throw new ArgumentException($"Couldn't find a way to load {member} of {typeof(T).Name}.") + _ => throw new ArgumentException($"Couldn't find a way to load {member} of {obj.Slug}.") }; } diff --git a/Kyoo.Common/Utility.cs b/Kyoo.Common/Utility.cs index defa3f47..ae13b2f7 100644 --- a/Kyoo.Common/Utility.cs +++ b/Kyoo.Common/Utility.cs @@ -24,6 +24,16 @@ namespace Kyoo ex.Body.NodeType == ExpressionType.Convert && ((UnaryExpression)ex.Body).Operand is MemberExpression; } + public static string GetPropertyName(LambdaExpression ex) + { + if (!IsPropertyExpression(ex)) + throw new ArgumentException($"{ex} is not a property expression."); + MemberExpression member = ex.Body.NodeType == ExpressionType.Convert + ? ((UnaryExpression)ex.Body).Operand as MemberExpression + : ex.Body as MemberExpression; + return member!.Member.Name; + } + public static string ToSlug(string str) { if (str == null) @@ -32,7 +42,7 @@ namespace Kyoo str = str.ToLowerInvariant(); string normalizedString = str.Normalize(NormalizationForm.FormD); - StringBuilder stringBuilder = new StringBuilder(); + StringBuilder stringBuilder = new(); foreach (char c in normalizedString) { UnicodeCategory unicodeCategory = CharUnicodeInfo.GetUnicodeCategory(c); @@ -238,10 +248,12 @@ namespace Kyoo action(); yield break; } - - yield return enumerator.Current; - while (enumerator.MoveNext()) + + do + { yield return enumerator.Current; + } + while (enumerator.MoveNext()); } private static MethodInfo GetMethod(Type type, BindingFlags flag, string name, Type[] generics, object[] args) diff --git a/Kyoo.CommonAPI/CrudApi.cs b/Kyoo.CommonAPI/CrudApi.cs index 23d409ec..b5270c4d 100644 --- a/Kyoo.CommonAPI/CrudApi.cs +++ b/Kyoo.CommonAPI/CrudApi.cs @@ -12,6 +12,7 @@ using Microsoft.Extensions.Configuration; namespace Kyoo.CommonApi { [ApiController] + [ResourceView] public class CrudApi : ControllerBase where T : class, IResource { private readonly IRepository _repository; @@ -22,7 +23,8 @@ namespace Kyoo.CommonApi _repository = repository; BaseURL = configuration.GetValue("public_url").TrimEnd('/'); } - + + [HttpGet("{id:int}")] [Authorize(Policy = "Read")] [JsonDetailed] @@ -68,10 +70,6 @@ namespace Kyoo.CommonApi [FromQuery] Dictionary where, [FromQuery] int limit = 20) { - where.Remove("sortBy"); - where.Remove("limit"); - where.Remove("afterID"); - try { ICollection resources = await _repository.GetAll(ApiHelper.ParseWhere(where), @@ -89,7 +87,7 @@ namespace Kyoo.CommonApi protected Page Page(ICollection resources, int limit) where TResult : IResource { - return new Page(resources, + return new(resources, BaseURL + Request.Path, Request.Query.ToDictionary(x => x.Key, x => x.Value.ToString(), StringComparer.InvariantCultureIgnoreCase), limit); diff --git a/Kyoo.CommonAPI/ResourceViewAttribute.cs b/Kyoo.CommonAPI/ResourceViewAttribute.cs new file mode 100644 index 00000000..a30683db --- /dev/null +++ b/Kyoo.CommonAPI/ResourceViewAttribute.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Kyoo.Controllers; +using Kyoo.Models; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Filters; +using Microsoft.Extensions.DependencyInjection; + +namespace Kyoo.CommonApi +{ + public class ResourceViewAttribute : ActionFilterAttribute + { + public override void OnActionExecuting(ActionExecutingContext context) + { + if (context.ActionArguments.TryGetValue("where", out object dic) && dic is Dictionary where) + { + where.Remove("fields"); + foreach ((string key, _) in context.ActionArguments) + where.Remove(key); + } + + context.HttpContext.Items["fields"] = context.HttpContext.Request.Query["fields"].ToArray(); + // TODO Check if fields are loadable properties of the return type. If not, shorfail the request. + base.OnActionExecuting(context); + } + + public override async Task OnResultExecutionAsync(ResultExecutingContext context, ResultExecutionDelegate next) + { + if (context.Result is ObjectResult result) + await LoadResultRelations(context, result); + await base.OnResultExecutionAsync(context, next); + } + + private static async Task LoadResultRelations(ActionContext context, ObjectResult result) + { + if (result.DeclaredType == null) + return; + + await using ILibraryManager library = context.HttpContext.RequestServices.GetService(); + string[] fields = (string[])context.HttpContext.Items["fields"]; + Type pageType = Utility.GetGenericDefinition(result.DeclaredType, typeof(Page<>)); + + + if (pageType != null) + { + foreach (IResource resource in ((Page)result.Value).Items) + { + foreach (string field in fields!) + await library!.Load(resource, field); + } + } + else if (result.DeclaredType.IsAssignableTo(typeof(IResource))) + { + foreach (string field in fields!) + await library!.Load(result.Value as IResource, field); + } + } + } +} \ No newline at end of file diff --git a/Kyoo/Views/API/CollectionApi.cs b/Kyoo/Views/API/CollectionApi.cs index 254be6b6..5bba0650 100644 --- a/Kyoo/Views/API/CollectionApi.cs +++ b/Kyoo/Views/API/CollectionApi.cs @@ -33,10 +33,6 @@ namespace Kyoo.Api [FromQuery] Dictionary where, [FromQuery] int limit = 30) { - where.Remove("sortBy"); - where.Remove("limit"); - where.Remove("afterID"); - try { ICollection resources = await _libraryManager.GetShows( @@ -63,10 +59,6 @@ namespace Kyoo.Api [FromQuery] Dictionary where, [FromQuery] int limit = 30) { - where.Remove("sortBy"); - where.Remove("limit"); - where.Remove("afterID"); - try { ICollection resources = await _libraryManager.GetShows( @@ -93,10 +85,6 @@ namespace Kyoo.Api [FromQuery] Dictionary where, [FromQuery] int limit = 30) { - where.Remove("sortBy"); - where.Remove("limit"); - where.Remove("afterID"); - try { ICollection resources = await _libraryManager.GetLibraries( @@ -123,10 +111,6 @@ namespace Kyoo.Api [FromQuery] Dictionary where, [FromQuery] int limit = 30) { - where.Remove("sortBy"); - where.Remove("limit"); - where.Remove("afterID"); - try { ICollection resources = await _libraryManager.GetLibraries( diff --git a/Kyoo/Views/API/EpisodeApi.cs b/Kyoo/Views/API/EpisodeApi.cs index eff5fe78..d01468b2 100644 --- a/Kyoo/Views/API/EpisodeApi.cs +++ b/Kyoo/Views/API/EpisodeApi.cs @@ -77,9 +77,7 @@ namespace Kyoo.Api [FromQuery] Dictionary where, [FromQuery] int limit = 30) { - where.Remove("sortBy"); - where.Remove("limit"); - where.Remove("afterID"); + try { @@ -109,9 +107,7 @@ namespace Kyoo.Api [FromQuery] Dictionary where, [FromQuery] int limit = 30) { - where.Remove("sortBy"); - where.Remove("limit"); - where.Remove("afterID"); + try { @@ -143,9 +139,7 @@ namespace Kyoo.Api [FromQuery] Dictionary where, [FromQuery] int limit = 30) { - where.Remove("sortBy"); - where.Remove("limit"); - where.Remove("afterID"); + try { diff --git a/Kyoo/Views/API/GenreApi.cs b/Kyoo/Views/API/GenreApi.cs index 2571f347..29393e97 100644 --- a/Kyoo/Views/API/GenreApi.cs +++ b/Kyoo/Views/API/GenreApi.cs @@ -34,10 +34,6 @@ namespace Kyoo.Api [FromQuery] Dictionary where, [FromQuery] int limit = 20) { - where.Remove("sortBy"); - where.Remove("limit"); - where.Remove("afterID"); - try { ICollection resources = await _libraryManager.GetShows( @@ -64,10 +60,6 @@ namespace Kyoo.Api [FromQuery] Dictionary where, [FromQuery] int limit = 20) { - where.Remove("sortBy"); - where.Remove("limit"); - where.Remove("afterID"); - try { ICollection resources = await _libraryManager.GetShows( diff --git a/Kyoo/Views/API/LibraryApi.cs b/Kyoo/Views/API/LibraryApi.cs index c66ae7f1..ba9ad3d0 100644 --- a/Kyoo/Views/API/LibraryApi.cs +++ b/Kyoo/Views/API/LibraryApi.cs @@ -45,10 +45,6 @@ namespace Kyoo.Api [FromQuery] Dictionary where, [FromQuery] int limit = 50) { - where.Remove("sortBy"); - where.Remove("limit"); - where.Remove("afterID"); - try { ICollection resources = await _libraryManager.GetShows( @@ -75,10 +71,6 @@ namespace Kyoo.Api [FromQuery] Dictionary where, [FromQuery] int limit = 20) { - where.Remove("sortBy"); - where.Remove("limit"); - where.Remove("afterID"); - try { ICollection resources = await _libraryManager.GetShows( @@ -105,10 +97,6 @@ namespace Kyoo.Api [FromQuery] Dictionary where, [FromQuery] int limit = 50) { - where.Remove("sortBy"); - where.Remove("limit"); - where.Remove("afterID"); - try { ICollection resources = await _libraryManager.GetCollections( @@ -135,10 +123,6 @@ namespace Kyoo.Api [FromQuery] Dictionary where, [FromQuery] int limit = 20) { - where.Remove("sortBy"); - where.Remove("limit"); - where.Remove("afterID"); - try { ICollection resources = await _libraryManager.GetCollections( @@ -165,10 +149,6 @@ namespace Kyoo.Api [FromQuery] Dictionary where, [FromQuery] int limit = 50) { - where.Remove("sortBy"); - where.Remove("limit"); - where.Remove("afterID"); - try { ICollection resources = await _libraryManager.GetItemsFromLibrary(id, @@ -195,10 +175,6 @@ namespace Kyoo.Api [FromQuery] Dictionary where, [FromQuery] int limit = 50) { - where.Remove("sortBy"); - where.Remove("limit"); - where.Remove("afterID"); - try { ICollection resources = await _libraryManager.GetItemsFromLibrary(slug, diff --git a/Kyoo/Views/API/LibraryItemApi.cs b/Kyoo/Views/API/LibraryItemApi.cs index 19132fa1..e0ae3560 100644 --- a/Kyoo/Views/API/LibraryItemApi.cs +++ b/Kyoo/Views/API/LibraryItemApi.cs @@ -34,10 +34,6 @@ namespace Kyoo.Api [FromQuery] Dictionary where, [FromQuery] int limit = 50) { - where.Remove("sortBy"); - where.Remove("limit"); - where.Remove("afterID"); - try { ICollection resources = await _libraryItems.GetAll( diff --git a/Kyoo/Views/API/PeopleApi.cs b/Kyoo/Views/API/PeopleApi.cs index 41d16f04..96d73490 100644 --- a/Kyoo/Views/API/PeopleApi.cs +++ b/Kyoo/Views/API/PeopleApi.cs @@ -36,10 +36,6 @@ namespace Kyoo.Api [FromQuery] Dictionary where, [FromQuery] int limit = 20) { - where.Remove("sortBy"); - where.Remove("limit"); - where.Remove("afterID"); - try { ICollection resources = await _libraryManager.GetRolesFromPeople(id, @@ -69,10 +65,6 @@ namespace Kyoo.Api [FromQuery] Dictionary where, [FromQuery] int limit = 20) { - where.Remove("sortBy"); - where.Remove("limit"); - where.Remove("afterID"); - try { ICollection resources = await _libraryManager.GetRolesFromPeople(slug, diff --git a/Kyoo/Views/API/SeasonApi.cs b/Kyoo/Views/API/SeasonApi.cs index 67206ca1..f6650617 100644 --- a/Kyoo/Views/API/SeasonApi.cs +++ b/Kyoo/Views/API/SeasonApi.cs @@ -33,10 +33,6 @@ namespace Kyoo.Api [FromQuery] Dictionary where, [FromQuery] int limit = 30) { - where.Remove("sortBy"); - where.Remove("limit"); - where.Remove("afterID"); - try { ICollection resources = await _libraryManager.GetEpisodes( @@ -64,10 +60,6 @@ namespace Kyoo.Api [FromQuery] Dictionary where, [FromQuery] int limit = 30) { - where.Remove("sortBy"); - where.Remove("limit"); - where.Remove("afterID"); - try { ICollection resources = await _libraryManager.GetEpisodes( @@ -96,10 +88,6 @@ namespace Kyoo.Api [FromQuery] Dictionary where, [FromQuery] int limit = 30) { - where.Remove("sortBy"); - where.Remove("limit"); - where.Remove("afterID"); - try { ICollection resources = await _libraryManager.GetEpisodes( diff --git a/Kyoo/Views/API/ShowApi.cs b/Kyoo/Views/API/ShowApi.cs index dcb90a66..28b6ef94 100644 --- a/Kyoo/Views/API/ShowApi.cs +++ b/Kyoo/Views/API/ShowApi.cs @@ -37,10 +37,6 @@ namespace Kyoo.Api [FromQuery] Dictionary where, [FromQuery] int limit = 20) { - where.Remove("sortBy"); - where.Remove("limit"); - where.Remove("afterID"); - try { ICollection resources = await _libraryManager.GetSeasons( @@ -67,10 +63,6 @@ namespace Kyoo.Api [FromQuery] Dictionary where, [FromQuery] int limit = 20) { - where.Remove("sortBy"); - where.Remove("limit"); - where.Remove("afterID"); - try { ICollection resources = await _libraryManager.GetSeasons( @@ -97,10 +89,6 @@ namespace Kyoo.Api [FromQuery] Dictionary where, [FromQuery] int limit = 50) { - where.Remove("sortBy"); - where.Remove("limit"); - where.Remove("afterID"); - try { ICollection resources = await _libraryManager.GetEpisodes( @@ -127,10 +115,6 @@ namespace Kyoo.Api [FromQuery] Dictionary where, [FromQuery] int limit = 50) { - where.Remove("sortBy"); - where.Remove("limit"); - where.Remove("afterID"); - try { ICollection resources = await _libraryManager.GetEpisodes( @@ -156,10 +140,6 @@ namespace Kyoo.Api [FromQuery] Dictionary where, [FromQuery] int limit = 30) { - where.Remove("sortBy"); - where.Remove("limit"); - where.Remove("afterID"); - try { ICollection resources = await _libraryManager.GetPeopleFromShow(showID, @@ -185,10 +165,6 @@ namespace Kyoo.Api [FromQuery] Dictionary where, [FromQuery] int limit = 30) { - where.Remove("sortBy"); - where.Remove("limit"); - where.Remove("afterID"); - try { ICollection resources = await _libraryManager.GetPeopleFromShow(slug, @@ -215,10 +191,6 @@ namespace Kyoo.Api [FromQuery] Dictionary where, [FromQuery] int limit = 30) { - where.Remove("sortBy"); - where.Remove("limit"); - where.Remove("afterID"); - try { ICollection resources = await _libraryManager.GetGenres( @@ -245,10 +217,6 @@ namespace Kyoo.Api [FromQuery] Dictionary where, [FromQuery] int limit = 30) { - where.Remove("sortBy"); - where.Remove("limit"); - where.Remove("afterID"); - try { ICollection resources = await _libraryManager.GetGenres( @@ -303,10 +271,6 @@ namespace Kyoo.Api [FromQuery] Dictionary where, [FromQuery] int limit = 30) { - where.Remove("sortBy"); - where.Remove("limit"); - where.Remove("afterID"); - try { ICollection resources = await _libraryManager.GetLibraries( @@ -333,10 +297,6 @@ namespace Kyoo.Api [FromQuery] Dictionary where, [FromQuery] int limit = 30) { - where.Remove("sortBy"); - where.Remove("limit"); - where.Remove("afterID"); - try { ICollection resources = await _libraryManager.GetLibraries( @@ -363,10 +323,6 @@ namespace Kyoo.Api [FromQuery] Dictionary where, [FromQuery] int limit = 30) { - where.Remove("sortBy"); - where.Remove("limit"); - where.Remove("afterID"); - try { ICollection resources = await _libraryManager.GetCollections( @@ -393,10 +349,6 @@ namespace Kyoo.Api [FromQuery] Dictionary where, [FromQuery] int limit = 30) { - where.Remove("sortBy"); - where.Remove("limit"); - where.Remove("afterID"); - try { ICollection resources = await _libraryManager.GetCollections( diff --git a/Kyoo/Views/API/StudioApi.cs b/Kyoo/Views/API/StudioApi.cs index 96c91463..e244575d 100644 --- a/Kyoo/Views/API/StudioApi.cs +++ b/Kyoo/Views/API/StudioApi.cs @@ -34,10 +34,6 @@ namespace Kyoo.Api [FromQuery] Dictionary where, [FromQuery] int limit = 20) { - where.Remove("sortBy"); - where.Remove("limit"); - where.Remove("afterID"); - try { ICollection resources = await _libraryManager.GetShows( @@ -64,10 +60,6 @@ namespace Kyoo.Api [FromQuery] Dictionary where, [FromQuery] int limit = 20) { - where.Remove("sortBy"); - where.Remove("limit"); - where.Remove("afterID"); - try { ICollection resources = await _libraryManager.GetShows(