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.
Prowlarr/src/NzbDrone.Api/Parse/ParseModule.cs

51 lines
1.3 KiB

using System.Collections.Generic;
using NzbDrone.Api.Movies;
using NzbDrone.Core.Parser;
namespace NzbDrone.Api.Parse
{
public class ParseModule : NzbDroneRestModule<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 parsedMovieInfo = _parsingService.ParseMovieInfo(title, new List<object>());
if (parsedMovieInfo == null)
{
return null;
}
var remoteMovie = _parsingService.Map(parsedMovieInfo, "");
if (remoteMovie != null)
{
return new ParseResource
{
Title = title,
ParsedMovieInfo = remoteMovie.RemoteMovie.ParsedMovieInfo,
Movie = remoteMovie.Movie.ToResource()
};
}
else
{
return new ParseResource
{
Title = title,
ParsedMovieInfo = parsedMovieInfo
};
}
}
}
}