From 6c91639d6482d069d6dcc693ea3b6b5950d28d18 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Wed, 18 Sep 2013 12:15:34 -0700 Subject: [PATCH] Prevent releases with unknown series from being downloaded --- NzbDrone.Api/Indexers/ReleaseModule.cs | 8 ++++++++ NzbDrone.Api/Indexers/ReleaseResource.cs | 1 + UI/Release/DownloadReportCell.js | 8 ++++++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/NzbDrone.Api/Indexers/ReleaseModule.cs b/NzbDrone.Api/Indexers/ReleaseModule.cs index 8945c6b44..f9f6e88cd 100644 --- a/NzbDrone.Api/Indexers/ReleaseModule.cs +++ b/NzbDrone.Api/Indexers/ReleaseModule.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using Nancy; using NzbDrone.Api.Mapping; +using NzbDrone.Api.REST; using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.DecisionEngine.Specifications; using NzbDrone.Core.Download; @@ -8,6 +9,7 @@ using NzbDrone.Core.Indexers; using NzbDrone.Core.Parser; using NzbDrone.Core.Parser.Model; +using NzbDrone.Core.Tv; using Omu.ValueInjecter; using System.Linq; using Nancy.ModelBinding; @@ -43,6 +45,11 @@ private Response DownloadRelease(ReleaseResource release) var remoteEpisode = _parsingService.Map(release.InjectTo(), 0); remoteEpisode.Release = release.InjectTo(); + if (remoteEpisode.Series == null || remoteEpisode.Episodes == null || !remoteEpisode.Episodes.Any()) + { + throw new BadRequestException(release); + } + _downloadService.DownloadReport(remoteEpisode); return release.AsResponse(); @@ -85,6 +92,7 @@ private static List MapDecisions(IEnumerable release.InjectFrom(downloadDecision.RemoteEpisode.ParsedEpisodeInfo); release.InjectFrom(downloadDecision); release.Rejections = downloadDecision.Rejections.ToList(); + release.DownloadAllowed = downloadDecision.RemoteEpisode.Series != null; result.Add(release); } diff --git a/NzbDrone.Api/Indexers/ReleaseResource.cs b/NzbDrone.Api/Indexers/ReleaseResource.cs index 3cc4a054a..a745f3869 100644 --- a/NzbDrone.Api/Indexers/ReleaseResource.cs +++ b/NzbDrone.Api/Indexers/ReleaseResource.cs @@ -28,5 +28,6 @@ public class ReleaseResource : RestResource public String CommentUrl { get; set; } public String DownloadUrl { get; set; } public String InfoUrl { get; set; } + public Boolean DownloadAllowed { get; set; } } } \ No newline at end of file diff --git a/UI/Release/DownloadReportCell.js b/UI/Release/DownloadReportCell.js index 2bddb6827..47694fab5 100644 --- a/UI/Release/DownloadReportCell.js +++ b/UI/Release/DownloadReportCell.js @@ -29,10 +29,14 @@ define( }, render: function () { + this.$el.html(''); + + if (this.model.get('downloadAllowed')) + { + this.$el.html(''); + } - this.$el.html(''); return this; - } }); });