Radarr/src/NzbDrone.Api/Parse/ParseModule.cs

51 lines
1.3 KiB
C#
Raw Normal View History

using System.Collections.Generic;
2018-02-19 07:18:14 +00:00
using NzbDrone.Api.Movies;
using NzbDrone.Core.Parser;
2018-11-23 07:03:32 +00:00
using Radarr.Http;
2015-04-10 14:30:06 +00:00
namespace NzbDrone.Api.Parse
{
2018-11-23 07:03:32 +00:00
public class ParseModule : RadarrRestModule<ParseResource>
2015-04-10 14:30:06 +00:00
{
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>());
2018-02-19 07:18:14 +00:00
if (parsedMovieInfo == null)
2015-04-10 14:30:06 +00:00
{
return null;
}
2018-02-19 07:18:14 +00:00
var remoteMovie = _parsingService.Map(parsedMovieInfo, "");
2015-04-10 14:30:06 +00:00
2018-02-19 07:18:14 +00:00
if (remoteMovie != null)
2015-04-10 14:30:06 +00:00
{
return new ParseResource
{
Title = title,
2018-02-19 07:18:14 +00:00
ParsedMovieInfo = remoteMovie.RemoteMovie.ParsedMovieInfo,
Movie = remoteMovie.Movie.ToResource()
};
}
else
{
return new ParseResource
{
Title = title,
2018-02-19 07:18:14 +00:00
ParsedMovieInfo = parsedMovieInfo
};
2015-04-10 14:30:06 +00:00
}
}
}
2018-02-19 07:18:14 +00:00
}