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.
52 lines
1.3 KiB
52 lines
1.3 KiB
7 years ago
|
using Lidarr.Api.V1.Albums;
|
||
|
using Lidarr.Api.V1.Artist;
|
||
7 years ago
|
using Lidarr.Http;
|
||
3 years ago
|
using Microsoft.AspNetCore.Mvc;
|
||
5 years ago
|
using NzbDrone.Core.Parser;
|
||
7 years ago
|
|
||
7 years ago
|
namespace Lidarr.Api.V1.Parse
|
||
7 years ago
|
{
|
||
3 years ago
|
[V1ApiController]
|
||
|
public class ParseController : Controller
|
||
7 years ago
|
{
|
||
|
private readonly IParsingService _parsingService;
|
||
|
|
||
3 years ago
|
public ParseController(IParsingService parsingService)
|
||
7 years ago
|
{
|
||
|
_parsingService = parsingService;
|
||
|
}
|
||
|
|
||
3 years ago
|
[HttpGet]
|
||
|
public ParseResource Parse(string title)
|
||
7 years ago
|
{
|
||
6 years ago
|
var parsedAlbumInfo = Parser.ParseAlbumTitle(title);
|
||
7 years ago
|
|
||
6 years ago
|
if (parsedAlbumInfo == null)
|
||
7 years ago
|
{
|
||
|
return null;
|
||
|
}
|
||
|
|
||
6 years ago
|
var remoteAlbum = _parsingService.Map(parsedAlbumInfo);
|
||
7 years ago
|
|
||
6 years ago
|
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
|
||
|
};
|
||
|
}
|
||
7 years ago
|
}
|
||
|
}
|
||
|
}
|