diff --git a/src/NzbDrone.Api/Indexers/ReleaseModule.cs b/src/NzbDrone.Api/Indexers/ReleaseModule.cs index 469ac4d6e..79af69db1 100644 --- a/src/NzbDrone.Api/Indexers/ReleaseModule.cs +++ b/src/NzbDrone.Api/Indexers/ReleaseModule.cs @@ -43,10 +43,12 @@ public ReleaseModule(IFetchAndParseRss rssFetcherAndParser, _prioritizeDownloadDecision = prioritizeDownloadDecision; _downloadService = downloadService; _logger = logger; + GetResourceAll = GetReleases; Post["/"] = x => DownloadRelease(this.Bind()); PostValidator.RuleFor(s => s.DownloadAllowed).Equal(true); + PostValidator.RuleFor(s => s.Guid).NotEmpty(); _remoteEpisodeCache = cacheManager.GetCache(GetType(), "remoteEpisodes"); } diff --git a/src/NzbDrone.Api/NzbDrone.Api.csproj b/src/NzbDrone.Api/NzbDrone.Api.csproj index 916b5a631..8592a6ce5 100644 --- a/src/NzbDrone.Api/NzbDrone.Api.csproj +++ b/src/NzbDrone.Api/NzbDrone.Api.csproj @@ -100,6 +100,8 @@ + + diff --git a/src/NzbDrone.Api/Parse/ParseModule.cs b/src/NzbDrone.Api/Parse/ParseModule.cs new file mode 100644 index 000000000..462839cfd --- /dev/null +++ b/src/NzbDrone.Api/Parse/ParseModule.cs @@ -0,0 +1,49 @@ +using NzbDrone.Core.Parser; +using NzbDrone.Core.Parser.Model; + +namespace NzbDrone.Api.Parse +{ + public class ParseModule : NzbDroneRestModule + { + private readonly IParsingService _parsingService; + + public ParseModule(IParsingService parsingService) + { + _parsingService = parsingService; + + GetResourceSingle = Parse; + } + + private ParseResource Parse() + { + var title = Request.Query.Title.Value; + var parsedEpisodeInfo = Parser.ParseTitle(title); + + if (parsedEpisodeInfo == null) + { + return null; + } + + var remoteEpisode = _parsingService.Map(parsedEpisodeInfo); + + if (remoteEpisode == null) + { + remoteEpisode = new RemoteEpisode + { + ParsedEpisodeInfo = parsedEpisodeInfo + }; + + return new ParseResource + { + Title = title, + ParsedEpisodeInfo = parsedEpisodeInfo + }; + } + + var resource = ToResource(remoteEpisode); + resource.Title = title; + + return resource; + } + } +} \ No newline at end of file diff --git a/src/NzbDrone.Api/Parse/ParseResource.cs b/src/NzbDrone.Api/Parse/ParseResource.cs new file mode 100644 index 000000000..c3d11713d --- /dev/null +++ b/src/NzbDrone.Api/Parse/ParseResource.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using NzbDrone.Api.Episodes; +using NzbDrone.Api.REST; +using NzbDrone.Api.Series; +using NzbDrone.Core.Parser.Model; + +namespace NzbDrone.Api.Parse +{ + public class ParseResource : RestResource + { + public string Title { get; set; } + public ParsedEpisodeInfo ParsedEpisodeInfo { get; set; } + public SeriesResource Series { get; set; } + public List Episodes { get; set; } + } +} \ No newline at end of file