diff --git a/back/src/Kyoo.Core/Views/Resources/CollectionApi.cs b/back/src/Kyoo.Core/Views/Resources/CollectionApi.cs index 24acee4a..a8a7a73c 100644 --- a/back/src/Kyoo.Core/Views/Resources/CollectionApi.cs +++ b/back/src/Kyoo.Core/Views/Resources/CollectionApi.cs @@ -47,6 +47,29 @@ public class CollectionApi( LibraryItemRepository items ) : CrudThumbsApi(collections) { + /// + /// Refresh + /// + /// + /// Ask a metadata refresh. + /// + /// The ID or slug of the . + /// Nothing + /// No episode with the given ID or slug could be found. + [HttpPost("{identifier:id}/refresh")] + [PartialPermission(Kind.Write)] + [ProducesResponseType(StatusCodes.Status204NoContent)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + public async Task Refresh(Identifier identifier, [FromServices] IScanner scanner) + { + Guid id = await identifier.Match( + id => Task.FromResult(id), + async slug => (await collections.Get(slug)).Id + ); + await scanner.SendRefreshRequest(nameof(Collection), id); + return NoContent(); + } + /// /// Add a movie /// diff --git a/back/src/Kyoo.Core/Views/Resources/MovieApi.cs b/back/src/Kyoo.Core/Views/Resources/MovieApi.cs index 629c3d0f..1d95ab6f 100644 --- a/back/src/Kyoo.Core/Views/Resources/MovieApi.cs +++ b/back/src/Kyoo.Core/Views/Resources/MovieApi.cs @@ -38,10 +38,33 @@ namespace Kyoo.Core.Api; [Route("movies")] [Route("movie", Order = AlternativeRoute)] [ApiController] -[PartialPermission(nameof(Show))] -[ApiDefinition("Shows", Group = ResourcesGroup)] +[PartialPermission(nameof(Movie))] +[ApiDefinition("Movie", Group = ResourcesGroup)] public class MovieApi(ILibraryManager libraryManager) : TranscoderApi(libraryManager.Movies) { + /// + /// Refresh + /// + /// + /// Ask a metadata refresh. + /// + /// The ID or slug of the . + /// Nothing + /// No episode with the given ID or slug could be found. + [HttpPost("{identifier:id}/refresh")] + [PartialPermission(Kind.Write)] + [ProducesResponseType(StatusCodes.Status204NoContent)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + public async Task Refresh(Identifier identifier, [FromServices] IScanner scanner) + { + Guid id = await identifier.Match( + id => Task.FromResult(id), + async slug => (await libraryManager.Movies.Get(slug)).Id + ); + await scanner.SendRefreshRequest(nameof(Movie), id); + return NoContent(); + } + /// /// Get studio that made the show /// diff --git a/back/src/Kyoo.Core/Views/Resources/SeasonApi.cs b/back/src/Kyoo.Core/Views/Resources/SeasonApi.cs index 8df85291..dcbdae8c 100644 --- a/back/src/Kyoo.Core/Views/Resources/SeasonApi.cs +++ b/back/src/Kyoo.Core/Views/Resources/SeasonApi.cs @@ -16,6 +16,7 @@ // You should have received a copy of the GNU General Public License // along with Kyoo. If not, see . +using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; @@ -41,6 +42,29 @@ namespace Kyoo.Core.Api; public class SeasonApi(ILibraryManager libraryManager) : CrudThumbsApi(libraryManager.Seasons) { + /// + /// Refresh + /// + /// + /// Ask a metadata refresh. + /// + /// The ID or slug of the . + /// Nothing + /// No episode with the given ID or slug could be found. + [HttpPost("{identifier:id}/refresh")] + [PartialPermission(Kind.Write)] + [ProducesResponseType(StatusCodes.Status204NoContent)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + public async Task Refresh(Identifier identifier, [FromServices] IScanner scanner) + { + Guid id = await identifier.Match( + id => Task.FromResult(id), + async slug => (await libraryManager.Seasons.Get(slug)).Id + ); + await scanner.SendRefreshRequest(nameof(Season), id); + return NoContent(); + } + /// /// Get episodes in the season /// diff --git a/back/src/Kyoo.Core/Views/Resources/ShowApi.cs b/back/src/Kyoo.Core/Views/Resources/ShowApi.cs index 54138ac9..fb23e4f3 100644 --- a/back/src/Kyoo.Core/Views/Resources/ShowApi.cs +++ b/back/src/Kyoo.Core/Views/Resources/ShowApi.cs @@ -42,6 +42,29 @@ namespace Kyoo.Core.Api; [ApiDefinition("Shows", Group = ResourcesGroup)] public class ShowApi(ILibraryManager libraryManager) : CrudThumbsApi(libraryManager.Shows) { + /// + /// Refresh + /// + /// + /// Ask a metadata refresh. + /// + /// The ID or slug of the . + /// Nothing + /// No episode with the given ID or slug could be found. + [HttpPost("{identifier:id}/refresh")] + [PartialPermission(Kind.Write)] + [ProducesResponseType(StatusCodes.Status204NoContent)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + public async Task Refresh(Identifier identifier, [FromServices] IScanner scanner) + { + Guid id = await identifier.Match( + id => Task.FromResult(id), + async slug => (await libraryManager.Shows.Get(slug)).Id + ); + await scanner.SendRefreshRequest(nameof(Show), id); + return NoContent(); + } + /// /// Get seasons of this show ///