mirror of https://github.com/lidarr/Lidarr
Add custom format score to parse endpoint
This commit is contained in:
parent
c98131905c
commit
8cca919f6b
|
@ -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
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using System.Collections.Generic;
|
||||
using Lidarr.Api.V1.Albums;
|
||||
using Lidarr.Api.V1.Artist;
|
||||
using Lidarr.Api.V1.CustomFormats;
|
||||
using Lidarr.Http.REST;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
|
||||
|
@ -12,5 +13,7 @@ namespace Lidarr.Api.V1.Parse
|
|||
public ParsedAlbumInfo ParsedAlbumInfo { get; set; }
|
||||
public ArtistResource Artist { get; set; }
|
||||
public List<AlbumResource> Albums { get; set; }
|
||||
public List<CustomFormatResource> CustomFormats { get; set; }
|
||||
public int CustomFormatScore { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue