mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-25 22:36:59 -04:00
New: Lidarr to Readarr
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
using NzbDrone.Core.Parser;
|
||||
using Readarr.Api.V1.Albums;
|
||||
using Readarr.Api.V1.Artist;
|
||||
using Readarr.Http;
|
||||
|
||||
namespace Readarr.Api.V1.Parse
|
||||
{
|
||||
public class ParseModule : ReadarrRestModule<ParseResource>
|
||||
{
|
||||
private readonly IParsingService _parsingService;
|
||||
|
||||
public ParseModule(IParsingService parsingService)
|
||||
{
|
||||
_parsingService = parsingService;
|
||||
|
||||
GetResourceSingle = Parse;
|
||||
}
|
||||
|
||||
private ParseResource Parse()
|
||||
{
|
||||
var title = Request.Query.Title.Value as string;
|
||||
var parsedAlbumInfo = Parser.ParseAlbumTitle(title);
|
||||
|
||||
if (parsedAlbumInfo == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
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
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using System.Collections.Generic;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using Readarr.Api.V1.Albums;
|
||||
using Readarr.Api.V1.Artist;
|
||||
using Readarr.Http.REST;
|
||||
|
||||
namespace Readarr.Api.V1.Parse
|
||||
{
|
||||
public class ParseResource : RestResource
|
||||
{
|
||||
public string Title { get; set; }
|
||||
public ParsedAlbumInfo ParsedAlbumInfo { get; set; }
|
||||
public ArtistResource Artist { get; set; }
|
||||
public List<AlbumResource> Albums { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user