|
|
|
@ -1,7 +1,11 @@
|
|
|
|
|
using Lidarr.Api.V1.Albums;
|
|
|
|
|
using Lidarr.Api.V1.Artist;
|
|
|
|
|
using Lidarr.Api.V1.CustomFormats;
|
|
|
|
|
using Lidarr.Http;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using NzbDrone.Common.Extensions;
|
|
|
|
|
using NzbDrone.Core.CustomFormats;
|
|
|
|
|
using NzbDrone.Core.Download.Aggregation;
|
|
|
|
|
using NzbDrone.Core.Parser;
|
|
|
|
|
|
|
|
|
|
namespace Lidarr.Api.V1.Parse
|
|
|
|
@ -10,16 +14,27 @@ namespace Lidarr.Api.V1.Parse
|
|
|
|
|
public class ParseController : Controller
|
|
|
|
|
{
|
|
|
|
|
private readonly IParsingService _parsingService;
|
|
|
|
|
private readonly IRemoteAlbumAggregationService _aggregationService;
|
|
|
|
|
private readonly ICustomFormatCalculationService _formatCalculator;
|
|
|
|
|
|
|
|
|
|
public ParseController(IParsingService parsingService)
|
|
|
|
|
public ParseController(IParsingService parsingService,
|
|
|
|
|
IRemoteAlbumAggregationService aggregationService,
|
|
|
|
|
ICustomFormatCalculationService formatCalculator)
|
|
|
|
|
{
|
|
|
|
|
_parsingService = parsingService;
|
|
|
|
|
_aggregationService = aggregationService;
|
|
|
|
|
_formatCalculator = formatCalculator;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpGet]
|
|
|
|
|
[Produces("application/json")]
|
|
|
|
|
public ParseResource Parse(string title)
|
|
|
|
|
{
|
|
|
|
|
if (title.IsNullOrWhiteSpace())
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var parsedAlbumInfo = Parser.ParseAlbumTitle(title);
|
|
|
|
|
|
|
|
|
|
if (parsedAlbumInfo == null)
|
|
|
|
@ -34,12 +49,19 @@ namespace Lidarr.Api.V1.Parse
|
|
|
|
|
|
|
|
|
|
if (remoteAlbum != null)
|
|
|
|
|
{
|
|
|
|
|
_aggregationService.Augment(remoteAlbum);
|
|
|
|
|
|
|
|
|
|
remoteAlbum.CustomFormats = _formatCalculator.ParseCustomFormat(remoteAlbum, 0);
|
|
|
|
|
remoteAlbum.CustomFormatScore = remoteAlbum?.Artist?.QualityProfile?.Value.CalculateCustomFormatScore(remoteAlbum.CustomFormats) ?? 0;
|
|
|
|
|
|
|
|
|
|
return new ParseResource
|
|
|
|
|
{
|
|
|
|
|
Title = title,
|
|
|
|
|
ParsedAlbumInfo = remoteAlbum.ParsedAlbumInfo,
|
|
|
|
|
Artist = remoteAlbum.Artist.ToResource(),
|
|
|
|
|
Albums = remoteAlbum.Albums.ToResource()
|
|
|
|
|
Albums = remoteAlbum.Albums.ToResource(),
|
|
|
|
|
CustomFormats = remoteAlbum.CustomFormats?.ToResource(false),
|
|
|
|
|
CustomFormatScore = remoteAlbum.CustomFormatScore
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|