mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Add refresh routes for seasons/shows/collections/movies
This commit is contained in:
parent
525da02fce
commit
12aa73376a
@ -47,6 +47,29 @@ public class CollectionApi(
|
||||
LibraryItemRepository items
|
||||
) : CrudThumbsApi<Collection>(collections)
|
||||
{
|
||||
/// <summary>
|
||||
/// Refresh
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Ask a metadata refresh.
|
||||
/// </remarks>
|
||||
/// <param name="identifier">The ID or slug of the <see cref="Collection"/>.</param>
|
||||
/// <returns>Nothing</returns>
|
||||
/// <response code="404">No episode with the given ID or slug could be found.</response>
|
||||
[HttpPost("{identifier:id}/refresh")]
|
||||
[PartialPermission(Kind.Write)]
|
||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||
public async Task<ActionResult> 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();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add a movie
|
||||
/// </summary>
|
||||
|
@ -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<Movie>(libraryManager.Movies)
|
||||
{
|
||||
/// <summary>
|
||||
/// Refresh
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Ask a metadata refresh.
|
||||
/// </remarks>
|
||||
/// <param name="identifier">The ID or slug of the <see cref="Movie"/>.</param>
|
||||
/// <returns>Nothing</returns>
|
||||
/// <response code="404">No episode with the given ID or slug could be found.</response>
|
||||
[HttpPost("{identifier:id}/refresh")]
|
||||
[PartialPermission(Kind.Write)]
|
||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||
public async Task<ActionResult> 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();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get studio that made the show
|
||||
/// </summary>
|
||||
|
@ -16,6 +16,7 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
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<Season>(libraryManager.Seasons)
|
||||
{
|
||||
/// <summary>
|
||||
/// Refresh
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Ask a metadata refresh.
|
||||
/// </remarks>
|
||||
/// <param name="identifier">The ID or slug of the <see cref="Season"/>.</param>
|
||||
/// <returns>Nothing</returns>
|
||||
/// <response code="404">No episode with the given ID or slug could be found.</response>
|
||||
[HttpPost("{identifier:id}/refresh")]
|
||||
[PartialPermission(Kind.Write)]
|
||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||
public async Task<ActionResult> 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();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get episodes in the season
|
||||
/// </summary>
|
||||
|
@ -42,6 +42,29 @@ namespace Kyoo.Core.Api;
|
||||
[ApiDefinition("Shows", Group = ResourcesGroup)]
|
||||
public class ShowApi(ILibraryManager libraryManager) : CrudThumbsApi<Show>(libraryManager.Shows)
|
||||
{
|
||||
/// <summary>
|
||||
/// Refresh
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Ask a metadata refresh.
|
||||
/// </remarks>
|
||||
/// <param name="identifier">The ID or slug of the <see cref="Show"/>.</param>
|
||||
/// <returns>Nothing</returns>
|
||||
/// <response code="404">No episode with the given ID or slug could be found.</response>
|
||||
[HttpPost("{identifier:id}/refresh")]
|
||||
[PartialPermission(Kind.Write)]
|
||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||
public async Task<ActionResult> 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();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get seasons of this show
|
||||
/// </summary>
|
||||
|
Loading…
x
Reference in New Issue
Block a user