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.
Lidarr/src/Lidarr.Api.V1/Parse/ParseController.cs

55 lines
1.4 KiB

using Lidarr.Api.V1.Albums;
using Lidarr.Api.V1.Artist;
using Lidarr.Http;
using Microsoft.AspNetCore.Mvc;
using NzbDrone.Core.Parser;
namespace Lidarr.Api.V1.Parse
{
[V1ApiController]
public class ParseController : Controller
{
private readonly IParsingService _parsingService;
public ParseController(IParsingService parsingService)
{
_parsingService = parsingService;
}
[HttpGet]
public ParseResource Parse(string title)
{
var parsedAlbumInfo = Parser.ParseAlbumTitle(title);
if (parsedAlbumInfo == null)
{
return new ParseResource
{
Title = title
};
}
var remoteAlbum = _parsingService.Map(parsedAlbumInfo);
if (remoteAlbum != null)
{
return new ParseResource
{
Title = title,
ParsedAlbumInfo = remoteAlbum.ParsedAlbumInfo,
Artist = remoteAlbum.Artist.ToResource(),
Albums = remoteAlbum.Albums.ToResource()
};
}
else
{
return new ParseResource
{
Title = title,
ParsedAlbumInfo = parsedAlbumInfo
};
}
}
}
}