You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.1 KiB
38 lines
1.1 KiB
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using NzbDrone.Core.MediaFiles;
|
|
using Readarr.Http;
|
|
using Readarr.Http.REST;
|
|
|
|
namespace Readarr.Api.V1.Books
|
|
{
|
|
[V1ApiController("retag")]
|
|
public class RetagBookController : Controller
|
|
{
|
|
private readonly IMetadataTagService _metadataTagService;
|
|
|
|
public RetagBookController(IMetadataTagService metadataTagService)
|
|
{
|
|
_metadataTagService = metadataTagService;
|
|
}
|
|
|
|
[HttpGet]
|
|
public List<RetagBookResource> GetBooks(int? authorId, int? bookId)
|
|
{
|
|
if (bookId.HasValue)
|
|
{
|
|
return _metadataTagService.GetRetagPreviewsByBook(bookId.Value).Where(x => x.Changes.Any()).ToResource();
|
|
}
|
|
else if (authorId.HasValue)
|
|
{
|
|
return _metadataTagService.GetRetagPreviewsByAuthor(authorId.Value).Where(x => x.Changes.Any()).ToResource();
|
|
}
|
|
else
|
|
{
|
|
throw new BadRequestException("One of authorId or bookId must be specified");
|
|
}
|
|
}
|
|
}
|
|
}
|