diff --git a/Kyoo.Common/Controllers/IRepository.cs b/Kyoo.Common/Controllers/IRepository.cs index e3ae3f65..c88ffbc2 100644 --- a/Kyoo.Common/Controllers/IRepository.cs +++ b/Kyoo.Common/Controllers/IRepository.cs @@ -93,6 +93,19 @@ namespace Kyoo.Controllers Task Create([NotNull] T obj); Task CreateIfNotExists([NotNull] T obj); + Task CreateIfNotExists([NotNull] T obj, bool silentFail) + { + try + { + return CreateIfNotExists(obj); + } + catch + { + if (!silentFail) + throw; + return null; + } + } Task Edit([NotNull] T edited, bool resetOld); Task Delete(int id); diff --git a/Kyoo.CommonAPI/CrudApi.cs b/Kyoo.CommonAPI/CrudApi.cs index a15c0e33..52cf057c 100644 --- a/Kyoo.CommonAPI/CrudApi.cs +++ b/Kyoo.CommonAPI/CrudApi.cs @@ -28,11 +28,11 @@ namespace Kyoo.CommonApi [JsonDetailed] public virtual async Task> Get(int id) { - T ressource = await _repository.Get(id); - if (ressource == null) + T resource = await _repository.Get(id); + if (resource == null) return NotFound(); - return ressource; + return resource; } [HttpGet("{slug}")] @@ -60,11 +60,11 @@ namespace Kyoo.CommonApi try { - ICollection ressources = await _repository.GetAll(ApiHelper.ParseWhere(where), + ICollection resources = await _repository.GetAll(ApiHelper.ParseWhere(where), new Sort(sortBy), new Pagination(limit, afterID)); - return Page(ressources, limit); + return Page(resources, limit); } catch (ArgumentException ex) { @@ -72,10 +72,10 @@ namespace Kyoo.CommonApi } } - protected Page Page(ICollection ressources, int limit) + protected Page Page(ICollection resources, int limit) where TResult : IResource { - return new Page(ressources, + return new Page(resources, _baseURL + Request.Path, Request.Query.ToDictionary(x => x.Key, x => x.Value.ToString(), StringComparer.InvariantCultureIgnoreCase), limit); @@ -83,11 +83,11 @@ namespace Kyoo.CommonApi [HttpPost] [Authorize(Policy = "Write")] - public virtual async Task> Create([FromBody] T ressource) + public virtual async Task> Create([FromBody] T resource) { try { - return await _repository.Create(ressource); + return await _repository.Create(resource); } catch (ArgumentException ex) { @@ -95,34 +95,34 @@ namespace Kyoo.CommonApi } catch (DuplicatedItemException) { - T existing = await _repository.Get(ressource.Slug); + T existing = await _repository.Get(resource.Slug); return Conflict(existing); } } [HttpPut] [Authorize(Policy = "Write")] - public virtual async Task> Edit([FromQuery] bool resetOld, [FromBody] T ressource) + public virtual async Task> Edit([FromQuery] bool resetOld, [FromBody] T resource) { - if (ressource.ID > 0) - return await _repository.Edit(ressource, resetOld); + if (resource.ID > 0) + return await _repository.Edit(resource, resetOld); - T old = await _repository.Get(ressource.Slug); + T old = await _repository.Get(resource.Slug); if (old == null) return NotFound(); - ressource.ID = old.ID; - return await _repository.Edit(ressource, resetOld); + resource.ID = old.ID; + return await _repository.Edit(resource, resetOld); } [HttpPut("{id:int}")] [Authorize(Policy = "Write")] - public virtual async Task> Edit(int id, [FromQuery] bool resetOld, [FromBody] T ressource) + public virtual async Task> Edit(int id, [FromQuery] bool resetOld, [FromBody] T resource) { - ressource.ID = id; + resource.ID = id; try { - return await _repository.Edit(ressource, resetOld); + return await _repository.Edit(resource, resetOld); } catch (ItemNotFound) { @@ -132,13 +132,13 @@ namespace Kyoo.CommonApi [HttpPut("{slug}")] [Authorize(Policy = "Write")] - public virtual async Task> Edit(string slug, [FromQuery] bool resetOld, [FromBody] T ressource) + public virtual async Task> Edit(string slug, [FromQuery] bool resetOld, [FromBody] T resource) { T old = await _repository.Get(slug); if (old == null) return NotFound(); - ressource.ID = old.ID; - return await _repository.Edit(ressource, resetOld); + resource.ID = old.ID; + return await _repository.Edit(resource, resetOld); } [HttpDelete("{id:int}")] diff --git a/Kyoo.CommonAPI/LocalRepository.cs b/Kyoo.CommonAPI/LocalRepository.cs index 7cad6a9d..2c7fa9ec 100644 --- a/Kyoo.CommonAPI/LocalRepository.cs +++ b/Kyoo.CommonAPI/LocalRepository.cs @@ -138,7 +138,7 @@ namespace Kyoo.Controllers T old = await Get(edited.Slug); if (old == null) - throw new ItemNotFound($"No ressource found with the slug {edited.Slug}."); + throw new ItemNotFound($"No resource found with the slug {edited.Slug}."); if (resetOld) Utility.Nullify(old); @@ -148,34 +148,49 @@ namespace Kyoo.Controllers return old; } - protected virtual Task Validate(T ressource) + protected virtual Task Validate(T resource) { - if (ressource.Slug == null) - throw new ArgumentException("Ressource can't have null as a slug."); + if (string.IsNullOrEmpty(resource.Slug)) + throw new ArgumentException("Resource can't have null as a slug."); + if (int.TryParse(resource.Slug, out int _)) + { + try + { + MethodInfo setter = typeof(T).GetProperty(nameof(resource.Slug))!.GetSetMethod(); + if (setter != null) + setter.Invoke(resource, new object[] {resource.Slug + '!'}); + else + throw new ArgumentException("Resources slug can't be number only."); + } + catch + { + throw new ArgumentException("Resources slug can't be number only."); + } + } foreach (PropertyInfo property in typeof(T).GetProperties() .Where(x => typeof(IEnumerable).IsAssignableFrom(x.PropertyType) && !typeof(string).IsAssignableFrom(x.PropertyType))) { - object value = property.GetValue(ressource); + object value = property.GetValue(resource); if (value is ICollection || value == null) continue; value = Utility.RunGenericMethod(typeof(Enumerable), "ToList", Utility.GetEnumerableType((IEnumerable)value), value); - property.SetValue(ressource, value); + property.SetValue(resource, value); } return Task.CompletedTask; } public virtual async Task Delete(int id) { - T ressource = await Get(id); - await Delete(ressource); + T resource = await Get(id); + await Delete(resource); } public virtual async Task Delete(string slug) { - T ressource = await Get(slug); - await Delete(ressource); + T resource = await Get(slug); + await Delete(resource); } public abstract Task Delete(T obj); diff --git a/Kyoo/Controllers/Repositories/EpisodeRepository.cs b/Kyoo/Controllers/Repositories/EpisodeRepository.cs index fee27276..5a9491da 100644 --- a/Kyoo/Controllers/Repositories/EpisodeRepository.cs +++ b/Kyoo/Controllers/Repositories/EpisodeRepository.cs @@ -110,17 +110,17 @@ namespace Kyoo.Controllers return obj; } - protected override async Task Validate(Episode obj) + protected override async Task Validate(Episode resource) { - if (obj.ShowID <= 0) - throw new InvalidOperationException($"Can't store an episode not related to any show (showID: {obj.ShowID})."); + if (resource.ShowID <= 0) + throw new InvalidOperationException($"Can't store an episode not related to any show (showID: {resource.ShowID})."); - await base.Validate(obj); + await base.Validate(resource); - if (obj.ExternalIDs != null) + if (resource.ExternalIDs != null) { - foreach (MetadataID link in obj.ExternalIDs) - link.Provider = await _providers.CreateIfNotExists(link.Provider); + foreach (MetadataID link in resource.ExternalIDs) + link.Provider = await _providers.CreateIfNotExists(link.Provider, true); } } diff --git a/Kyoo/Controllers/Repositories/LibraryItemRepository.cs b/Kyoo/Controllers/Repositories/LibraryItemRepository.cs index 137e1419..faf0feaf 100644 --- a/Kyoo/Controllers/Repositories/LibraryItemRepository.cs +++ b/Kyoo/Controllers/Repositories/LibraryItemRepository.cs @@ -94,7 +94,7 @@ namespace Kyoo.Controllers public override Task Create(LibraryItem obj) => throw new InvalidOperationException(); public override Task CreateIfNotExists(LibraryItem obj) => throw new InvalidOperationException(); public override Task Edit(LibraryItem obj, bool reset) => throw new InvalidOperationException(); - protected override Task Validate(LibraryItem obj) => throw new InvalidOperationException(); + protected override Task Validate(LibraryItem resource) => throw new InvalidOperationException(); public override Task Delete(int id) => throw new InvalidOperationException(); public override Task Delete(string slug) => throw new InvalidOperationException(); public override Task Delete(LibraryItem obj) => throw new InvalidOperationException(); diff --git a/Kyoo/Controllers/Repositories/LibraryRepository.cs b/Kyoo/Controllers/Repositories/LibraryRepository.cs index 225f2532..99ec0b8e 100644 --- a/Kyoo/Controllers/Repositories/LibraryRepository.cs +++ b/Kyoo/Controllers/Repositories/LibraryRepository.cs @@ -63,20 +63,20 @@ namespace Kyoo.Controllers return obj; } - protected override async Task Validate(LibraryDE obj) + protected override async Task Validate(LibraryDE resource) { - if (string.IsNullOrEmpty(obj.Slug)) + if (string.IsNullOrEmpty(resource.Slug)) throw new ArgumentException("The library's slug must be set and not empty"); - if (string.IsNullOrEmpty(obj.Name)) + if (string.IsNullOrEmpty(resource.Name)) throw new ArgumentException("The library's name must be set and not empty"); - if (obj.Paths == null || !obj.Paths.Any()) + if (resource.Paths == null || !resource.Paths.Any()) throw new ArgumentException("The library should have a least one path."); - await base.Validate(obj); + await base.Validate(resource); - if (obj.ProviderLinks != null) - foreach (ProviderLink link in obj.ProviderLinks) - link.Provider = await _providers.CreateIfNotExists(link.Provider); + if (resource.ProviderLinks != null) + foreach (ProviderLink link in resource.ProviderLinks) + link.Provider = await _providers.CreateIfNotExists(link.Provider, true); } public override async Task Delete(LibraryDE obj) diff --git a/Kyoo/Controllers/Repositories/PeopleRepository.cs b/Kyoo/Controllers/Repositories/PeopleRepository.cs index 8bf57f02..1ec75e24 100644 --- a/Kyoo/Controllers/Repositories/PeopleRepository.cs +++ b/Kyoo/Controllers/Repositories/PeopleRepository.cs @@ -69,13 +69,13 @@ namespace Kyoo.Controllers return obj; } - protected override async Task Validate(People obj) + protected override async Task Validate(People resource) { - await base.Validate(obj); + await base.Validate(resource); - if (obj.ExternalIDs != null) - foreach (MetadataID link in obj.ExternalIDs) - link.Provider = await _providers.CreateIfNotExists(link.Provider); + if (resource.ExternalIDs != null) + foreach (MetadataID link in resource.ExternalIDs) + link.Provider = await _providers.CreateIfNotExists(link.Provider, true); } public override async Task Delete(People obj) diff --git a/Kyoo/Controllers/Repositories/SeasonRepository.cs b/Kyoo/Controllers/Repositories/SeasonRepository.cs index 81a7c2af..e75b7790 100644 --- a/Kyoo/Controllers/Repositories/SeasonRepository.cs +++ b/Kyoo/Controllers/Repositories/SeasonRepository.cs @@ -94,17 +94,17 @@ namespace Kyoo.Controllers return obj; } - protected override async Task Validate(Season obj) + protected override async Task Validate(Season resource) { - if (obj.ShowID <= 0) - throw new InvalidOperationException($"Can't store a season not related to any show (showID: {obj.ShowID})."); + if (resource.ShowID <= 0) + throw new InvalidOperationException($"Can't store a season not related to any show (showID: {resource.ShowID})."); - await base.Validate(obj); + await base.Validate(resource); - if (obj.ExternalIDs != null) + if (resource.ExternalIDs != null) { - foreach (MetadataID link in obj.ExternalIDs) - link.Provider = await _providers.CreateIfNotExists(link.Provider); + foreach (MetadataID link in resource.ExternalIDs) + link.Provider = await _providers.CreateIfNotExists(link.Provider, true); } } diff --git a/Kyoo/Controllers/Repositories/ShowRepository.cs b/Kyoo/Controllers/Repositories/ShowRepository.cs index 0991eda7..da1be292 100644 --- a/Kyoo/Controllers/Repositories/ShowRepository.cs +++ b/Kyoo/Controllers/Repositories/ShowRepository.cs @@ -106,24 +106,24 @@ namespace Kyoo.Controllers return obj; } - protected override async Task Validate(ShowDE obj) + protected override async Task Validate(ShowDE resource) { - await base.Validate(obj); + await base.Validate(resource); - if (obj.Studio != null) - obj.Studio = await _studios.CreateIfNotExists(obj.Studio); + if (resource.Studio != null) + resource.Studio = await _studios.CreateIfNotExists(resource.Studio, true); - if (obj.GenreLinks != null) - foreach (GenreLink link in obj.GenreLinks) - link.Genre = await _genres.CreateIfNotExists(link.Genre); + if (resource.GenreLinks != null) + foreach (GenreLink link in resource.GenreLinks) + link.Genre = await _genres.CreateIfNotExists(link.Genre, true); - if (obj.People != null) - foreach (PeopleRole link in obj.People) - link.People = await _people.CreateIfNotExists(link.People); + if (resource.People != null) + foreach (PeopleRole link in resource.People) + link.People = await _people.CreateIfNotExists(link.People, true); - if (obj.ExternalIDs != null) - foreach (MetadataID link in obj.ExternalIDs) - link.Provider = await _providers.CreateIfNotExists(link.Provider); + if (resource.ExternalIDs != null) + foreach (MetadataID link in resource.ExternalIDs) + link.Provider = await _providers.CreateIfNotExists(link.Provider, true); } public async Task AddShowLink(int showID, int? libraryID, int? collectionID) diff --git a/Kyoo/Controllers/Repositories/TrackRepository.cs b/Kyoo/Controllers/Repositories/TrackRepository.cs index 724e5c93..f1d4fa54 100644 --- a/Kyoo/Controllers/Repositories/TrackRepository.cs +++ b/Kyoo/Controllers/Repositories/TrackRepository.cs @@ -75,7 +75,7 @@ namespace Kyoo.Controllers return obj; } - protected override Task Validate(Track ressource) + protected override Task Validate(Track resource) { return Task.CompletedTask; } diff --git a/Kyoo/Views/API/CollectionApi.cs b/Kyoo/Views/API/CollectionApi.cs index 501f15bc..2a3b3b4d 100644 --- a/Kyoo/Views/API/CollectionApi.cs +++ b/Kyoo/Views/API/CollectionApi.cs @@ -40,12 +40,12 @@ namespace Kyoo.Api try { - ICollection ressources = await _libraryManager.GetShows( + ICollection resources = await _libraryManager.GetShows( ApiHelper.ParseWhere(where, x => x.Collections.Any(y => y.ID == id)), new Sort(sortBy), new Pagination(limit, afterID)); - return Page(ressources, limit); + return Page(resources, limit); } catch (ItemNotFound) { @@ -72,12 +72,12 @@ namespace Kyoo.Api try { - ICollection ressources = await _libraryManager.GetShows( + ICollection resources = await _libraryManager.GetShows( ApiHelper.ParseWhere(where, x => x.Collections.Any(y => y.Slug == slug)), new Sort(sortBy), new Pagination(limit, afterID)); - return Page(ressources, limit); + return Page(resources, limit); } catch (ItemNotFound) { @@ -104,12 +104,12 @@ namespace Kyoo.Api try { - ICollection ressources = await _libraryManager.GetLibraries( + ICollection resources = await _libraryManager.GetLibraries( ApiHelper.ParseWhere(where, x => x.Collections.Any(y => y.ID == id)), new Sort(sortBy), new Pagination(limit, afterID)); - return Page(ressources, limit); + return Page(resources, limit); } catch (ItemNotFound) { @@ -136,12 +136,12 @@ namespace Kyoo.Api try { - ICollection ressources = await _libraryManager.GetLibraries( + ICollection resources = await _libraryManager.GetLibraries( ApiHelper.ParseWhere(where, x => x.Collections.Any(y => y.Slug == slug)), new Sort(sortBy), new Pagination(limit, afterID)); - return Page(ressources, limit); + return Page(resources, limit); } catch (ItemNotFound) { diff --git a/Kyoo/Views/API/EpisodeApi.cs b/Kyoo/Views/API/EpisodeApi.cs index 13400016..7df8f87b 100644 --- a/Kyoo/Views/API/EpisodeApi.cs +++ b/Kyoo/Views/API/EpisodeApi.cs @@ -82,12 +82,12 @@ namespace Kyoo.Api try { - ICollection ressources = await _libraryManager.GetTracks( + ICollection resources = await _libraryManager.GetTracks( ApiHelper.ParseWhere(where, x => x.Episode.ID == episodeID), new Sort(sortBy), new Pagination(limit, afterID)); - return Page(ressources, limit); + return Page(resources, limit); } catch (ItemNotFound) { @@ -116,14 +116,14 @@ namespace Kyoo.Api try { - ICollection ressources = await _libraryManager.GetTracks( + ICollection resources = await _libraryManager.GetTracks( ApiHelper.ParseWhere(where, x => x.Episode.ShowID == showID && x.Episode.SeasonNumber == seasonNumber && x.Episode.EpisodeNumber == episodeNumber), new Sort(sortBy), new Pagination(limit, afterID)); - return Page(ressources, limit); + return Page(resources, limit); } catch (ItemNotFound) { @@ -152,13 +152,13 @@ namespace Kyoo.Api try { - ICollection ressources = await _libraryManager.GetTracks(ApiHelper.ParseWhere(where, x => x.Episode.Show.Slug == showSlug + ICollection resources = await _libraryManager.GetTracks(ApiHelper.ParseWhere(where, x => x.Episode.Show.Slug == showSlug && x.Episode.SeasonNumber == seasonNumber && x.Episode.EpisodeNumber == episodeNumber), new Sort(sortBy), new Pagination(limit, afterID)); - return Page(ressources, limit); + return Page(resources, limit); } catch (ItemNotFound) { diff --git a/Kyoo/Views/API/GenreApi.cs b/Kyoo/Views/API/GenreApi.cs index efe626cc..fcad684f 100644 --- a/Kyoo/Views/API/GenreApi.cs +++ b/Kyoo/Views/API/GenreApi.cs @@ -40,14 +40,14 @@ namespace Kyoo.Api try { - ICollection ressources = await _libraryManager.GetShows( + ICollection resources = await _libraryManager.GetShows( ApiHelper.ParseWhere(where, x => x.Genres.Any(y => y.ID == id)), new Sort(sortBy), new Pagination(limit, afterID)); - if (!ressources.Any() && await _libraryManager.GetGenre(id) == null) + if (!resources.Any() && await _libraryManager.GetGenre(id) == null) return NotFound(); - return Page(ressources, limit); + return Page(resources, limit); } catch (ItemNotFound) { @@ -74,14 +74,14 @@ namespace Kyoo.Api try { - ICollection ressources = await _libraryManager.GetShows( + ICollection resources = await _libraryManager.GetShows( ApiHelper.ParseWhere(where, x => x.Genres.Any(y => y.Slug == slug)), new Sort(sortBy), new Pagination(limit, afterID)); - if (!ressources.Any() && await _libraryManager.GetGenre(slug) == null) + if (!resources.Any() && await _libraryManager.GetGenre(slug) == null) return NotFound(); - return Page(ressources, limit); + return Page(resources, limit); } catch (ItemNotFound) { diff --git a/Kyoo/Views/API/LibraryApi.cs b/Kyoo/Views/API/LibraryApi.cs index 8e573bf4..fdd0624a 100644 --- a/Kyoo/Views/API/LibraryApi.cs +++ b/Kyoo/Views/API/LibraryApi.cs @@ -28,9 +28,9 @@ namespace Kyoo.Api } [Authorize(Policy = "Admin")] - public override async Task> Create(Library ressource) + public override async Task> Create(Library resource) { - ActionResult result = await base.Create(ressource); + ActionResult result = await base.Create(resource); if (result.Value != null) _taskManager.StartTask("scan", result.Value.Slug); return result; @@ -51,12 +51,12 @@ namespace Kyoo.Api try { - ICollection ressources = await _libraryManager.GetShows( + ICollection resources = await _libraryManager.GetShows( ApiHelper.ParseWhere(where, x => x.Libraries.Any(y => y.ID == id)), new Sort(sortBy), new Pagination(limit, afterID)); - return Page(ressources, limit); + return Page(resources, limit); } catch (ItemNotFound) { @@ -83,12 +83,12 @@ namespace Kyoo.Api try { - ICollection ressources = await _libraryManager.GetShows( + ICollection resources = await _libraryManager.GetShows( ApiHelper.ParseWhere(where, x => x.Libraries.Any(y => y.Slug == slug)), new Sort(sortBy), new Pagination(limit, afterID)); - return Page(ressources, limit); + return Page(resources, limit); } catch (ItemNotFound) { @@ -115,12 +115,12 @@ namespace Kyoo.Api try { - ICollection ressources = await _libraryManager.GetCollections( + ICollection resources = await _libraryManager.GetCollections( ApiHelper.ParseWhere(where, x => x.Libraries.Any(y => y.ID == id)), new Sort(sortBy), new Pagination(limit, afterID)); - return Page(ressources, limit); + return Page(resources, limit); } catch (ItemNotFound) { @@ -147,12 +147,12 @@ namespace Kyoo.Api try { - ICollection ressources = await _libraryManager.GetCollections( + ICollection resources = await _libraryManager.GetCollections( ApiHelper.ParseWhere(where, x => x.Libraries.Any(y => y.Slug == slug)), new Sort(sortBy), new Pagination(limit, afterID)); - return Page(ressources, limit); + return Page(resources, limit); } catch (ItemNotFound) { @@ -179,12 +179,12 @@ namespace Kyoo.Api try { - ICollection ressources = await _libraryManager.GetItemsFromLibrary(id, + ICollection resources = await _libraryManager.GetItemsFromLibrary(id, ApiHelper.ParseWhere(where), new Sort(sortBy), new Pagination(limit, afterID)); - return Page(ressources, limit); + return Page(resources, limit); } catch (ItemNotFound) { @@ -211,12 +211,12 @@ namespace Kyoo.Api try { - ICollection ressources = await _libraryManager.GetItemsFromLibrary(slug, + ICollection resources = await _libraryManager.GetItemsFromLibrary(slug, ApiHelper.ParseWhere(where), new Sort(sortBy), new Pagination(limit, afterID)); - return Page(ressources, limit); + return Page(resources, limit); } catch (ItemNotFound) { diff --git a/Kyoo/Views/API/LibraryItemApi.cs b/Kyoo/Views/API/LibraryItemApi.cs index e5918a3c..19132fa1 100644 --- a/Kyoo/Views/API/LibraryItemApi.cs +++ b/Kyoo/Views/API/LibraryItemApi.cs @@ -40,12 +40,12 @@ namespace Kyoo.Api try { - ICollection ressources = await _libraryItems.GetAll( + ICollection resources = await _libraryItems.GetAll( ApiHelper.ParseWhere(where), new Sort(sortBy), new Pagination(limit, afterID)); - return new Page(ressources, + return new Page(resources, _baseURL + Request.Path, Request.Query.ToDictionary(x => x.Key, x => x.Value.ToString(), StringComparer.InvariantCultureIgnoreCase), limit); diff --git a/Kyoo/Views/API/PeopleApi.cs b/Kyoo/Views/API/PeopleApi.cs index 2803ead9..b671fe8a 100644 --- a/Kyoo/Views/API/PeopleApi.cs +++ b/Kyoo/Views/API/PeopleApi.cs @@ -73,12 +73,12 @@ namespace Kyoo.Api try { - ICollection ressources = await _libraryManager.GetRolesFromPeople(slug, + ICollection resources = await _libraryManager.GetRolesFromPeople(slug, ApiHelper.ParseWhere(where), new Sort(sortBy), new Pagination(limit, afterID)); - return Page(ressources, limit); + return Page(resources, limit); } catch (ItemNotFound) { diff --git a/Kyoo/Views/API/SeasonApi.cs b/Kyoo/Views/API/SeasonApi.cs index 819351b9..077edf6a 100644 --- a/Kyoo/Views/API/SeasonApi.cs +++ b/Kyoo/Views/API/SeasonApi.cs @@ -40,12 +40,12 @@ namespace Kyoo.Api try { - ICollection ressources = await _libraryManager.GetEpisodes( + ICollection resources = await _libraryManager.GetEpisodes( ApiHelper.ParseWhere(where, x => x.SeasonID == seasonID), new Sort(sortBy), new Pagination(limit, afterID)); - return Page(ressources, limit); + return Page(resources, limit); } catch (ItemNotFound) { @@ -73,13 +73,13 @@ namespace Kyoo.Api try { - ICollection ressources = await _libraryManager.GetEpisodes( + ICollection resources = await _libraryManager.GetEpisodes( ApiHelper.ParseWhere(where, x => x.Show.Slug == showSlug && x.SeasonNumber == seasonNumber), new Sort(sortBy), new Pagination(limit, afterID)); - return Page(ressources, limit); + return Page(resources, limit); } catch (ItemNotFound) { @@ -107,12 +107,12 @@ namespace Kyoo.Api try { - ICollection ressources = await _libraryManager.GetEpisodes( + ICollection resources = await _libraryManager.GetEpisodes( ApiHelper.ParseWhere(where, x => x.ShowID == showID && x.SeasonNumber == seasonNumber), new Sort(sortBy), new Pagination(limit, afterID)); - return Page(ressources, limit); + return Page(resources, limit); } catch (ItemNotFound) { diff --git a/Kyoo/Views/API/ShowApi.cs b/Kyoo/Views/API/ShowApi.cs index 8e764457..846f61ca 100644 --- a/Kyoo/Views/API/ShowApi.cs +++ b/Kyoo/Views/API/ShowApi.cs @@ -40,12 +40,12 @@ namespace Kyoo.Api try { - ICollection ressources = await _libraryManager.GetSeasons( + ICollection resources = await _libraryManager.GetSeasons( ApiHelper.ParseWhere(where, x => x.ShowID == showID), new Sort(sortBy), new Pagination(limit, afterID)); - return Page(ressources, limit); + return Page(resources, limit); } catch (ItemNotFound) { @@ -72,12 +72,12 @@ namespace Kyoo.Api try { - ICollection ressources = await _libraryManager.GetSeasons( + ICollection resources = await _libraryManager.GetSeasons( ApiHelper.ParseWhere(where, x => x.Show.Slug == slug), new Sort(sortBy), new Pagination(limit, afterID)); - return Page(ressources, limit); + return Page(resources, limit); } catch (ItemNotFound) { @@ -104,12 +104,12 @@ namespace Kyoo.Api try { - ICollection ressources = await _libraryManager.GetEpisodes( + ICollection resources = await _libraryManager.GetEpisodes( ApiHelper.ParseWhere(where, x => x.ShowID == showID), new Sort(sortBy), new Pagination(limit, afterID)); - return Page(ressources, limit); + return Page(resources, limit); } catch (ItemNotFound) { @@ -136,12 +136,12 @@ namespace Kyoo.Api try { - ICollection ressources = await _libraryManager.GetEpisodes( + ICollection resources = await _libraryManager.GetEpisodes( ApiHelper.ParseWhere(where, x => x.Show.Slug == slug), new Sort(sortBy), new Pagination(limit, afterID)); - return Page(ressources, limit); + return Page(resources, limit); } catch (ItemNotFound) { @@ -167,12 +167,12 @@ namespace Kyoo.Api try { - ICollection ressources = await _libraryManager.GetPeopleFromShow(showID, + ICollection resources = await _libraryManager.GetPeopleFromShow(showID, ApiHelper.ParseWhere(where), new Sort(sortBy), new Pagination(limit, afterID)); - return Page(ressources, limit); + return Page(resources, limit); } catch (ItemNotFound) { @@ -198,12 +198,12 @@ namespace Kyoo.Api try { - ICollection ressources = await _libraryManager.GetPeopleFromShow(slug, + ICollection resources = await _libraryManager.GetPeopleFromShow(slug, ApiHelper.ParseWhere(where), new Sort(sortBy), new Pagination(limit, afterID)); - return Page(ressources, limit); + return Page(resources, limit); } catch (ItemNotFound) { @@ -230,12 +230,12 @@ namespace Kyoo.Api try { - ICollection ressources = await _libraryManager.GetGenres( + ICollection resources = await _libraryManager.GetGenres( ApiHelper.ParseWhere(where, x => x.Shows.Any(y => y.ID == showID)), new Sort(sortBy), new Pagination(limit, afterID)); - return Page(ressources, limit); + return Page(resources, limit); } catch (ItemNotFound) { @@ -262,12 +262,12 @@ namespace Kyoo.Api try { - ICollection ressources = await _libraryManager.GetGenres( + ICollection resources = await _libraryManager.GetGenres( ApiHelper.ParseWhere(where, x => x.Shows.Any(y => y.Slug == slug)), new Sort(sortBy), new Pagination(limit, afterID)); - return Page(ressources, limit); + return Page(resources, limit); } catch (ItemNotFound) { @@ -322,12 +322,12 @@ namespace Kyoo.Api try { - ICollection ressources = await _libraryManager.GetLibraries( + ICollection resources = await _libraryManager.GetLibraries( ApiHelper.ParseWhere(where, x => x.Shows.Any(y => y.ID == showID)), new Sort(sortBy), new Pagination(limit, afterID)); - return Page(ressources, limit); + return Page(resources, limit); } catch (ItemNotFound) { @@ -354,12 +354,12 @@ namespace Kyoo.Api try { - ICollection ressources = await _libraryManager.GetLibraries( + ICollection resources = await _libraryManager.GetLibraries( ApiHelper.ParseWhere(where, x => x.Shows.Any(y => y.Slug == slug)), new Sort(sortBy), new Pagination(limit, afterID)); - return Page(ressources, limit); + return Page(resources, limit); } catch (ItemNotFound) { @@ -386,12 +386,12 @@ namespace Kyoo.Api try { - ICollection ressources = await _libraryManager.GetCollections( + ICollection resources = await _libraryManager.GetCollections( ApiHelper.ParseWhere(where, x => x.Shows.Any(y => y.ID == showID)), new Sort(sortBy), new Pagination(limit, afterID)); - return Page(ressources, limit); + return Page(resources, limit); } catch (ItemNotFound) { @@ -418,12 +418,12 @@ namespace Kyoo.Api try { - ICollection ressources = await _libraryManager.GetCollections( + ICollection resources = await _libraryManager.GetCollections( ApiHelper.ParseWhere(where, x => x.Shows.Any(y => y.Slug == slug)), new Sort(sortBy), new Pagination(limit, afterID)); - return Page(ressources, limit); + return Page(resources, limit); } catch (ItemNotFound) { diff --git a/Kyoo/Views/API/StudioApi.cs b/Kyoo/Views/API/StudioApi.cs index e2b7f88a..648265e7 100644 --- a/Kyoo/Views/API/StudioApi.cs +++ b/Kyoo/Views/API/StudioApi.cs @@ -40,14 +40,14 @@ namespace Kyoo.Api try { - ICollection ressources = await _libraryManager.GetShows( + ICollection resources = await _libraryManager.GetShows( ApiHelper.ParseWhere(where, x => x.StudioID == id), new Sort(sortBy), new Pagination(limit, afterID)); - if (!ressources.Any() && await _libraryManager.GetStudio(id) == null) + if (!resources.Any() && await _libraryManager.GetStudio(id) == null) return NotFound(); - return Page(ressources, limit); + return Page(resources, limit); } catch (ItemNotFound) { @@ -74,14 +74,14 @@ namespace Kyoo.Api try { - ICollection ressources = await _libraryManager.GetShows( + ICollection resources = await _libraryManager.GetShows( ApiHelper.ParseWhere(where, x => x.Studio.Slug == slug), new Sort(sortBy), new Pagination(limit, afterID)); - if (!ressources.Any() && await _libraryManager.GetStudio(slug) == null) + if (!resources.Any() && await _libraryManager.GetStudio(slug) == null) return NotFound(); - return Page(ressources, limit); + return Page(resources, limit); } catch (ItemNotFound) {