1
0
Fork 0
mirror of https://github.com/Radarr/Radarr synced 2024-12-26 01:38:24 +00:00

Prevent releases with unknown series from being downloaded

This commit is contained in:
Mark McDowall 2013-09-18 12:15:34 -07:00
parent 82933fbcc3
commit 6c91639d64
3 changed files with 15 additions and 2 deletions

View file

@ -1,6 +1,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using Nancy; using Nancy;
using NzbDrone.Api.Mapping; using NzbDrone.Api.Mapping;
using NzbDrone.Api.REST;
using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.DecisionEngine.Specifications; using NzbDrone.Core.DecisionEngine.Specifications;
using NzbDrone.Core.Download; using NzbDrone.Core.Download;
@ -8,6 +9,7 @@
using NzbDrone.Core.Indexers; using NzbDrone.Core.Indexers;
using NzbDrone.Core.Parser; using NzbDrone.Core.Parser;
using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Tv;
using Omu.ValueInjecter; using Omu.ValueInjecter;
using System.Linq; using System.Linq;
using Nancy.ModelBinding; using Nancy.ModelBinding;
@ -43,6 +45,11 @@ private Response DownloadRelease(ReleaseResource release)
var remoteEpisode = _parsingService.Map(release.InjectTo<ParsedEpisodeInfo>(), 0); var remoteEpisode = _parsingService.Map(release.InjectTo<ParsedEpisodeInfo>(), 0);
remoteEpisode.Release = release.InjectTo<ReleaseInfo>(); remoteEpisode.Release = release.InjectTo<ReleaseInfo>();
if (remoteEpisode.Series == null || remoteEpisode.Episodes == null || !remoteEpisode.Episodes.Any())
{
throw new BadRequestException(release);
}
_downloadService.DownloadReport(remoteEpisode); _downloadService.DownloadReport(remoteEpisode);
return release.AsResponse(); return release.AsResponse();
@ -85,6 +92,7 @@ private static List<ReleaseResource> MapDecisions(IEnumerable<DownloadDecision>
release.InjectFrom(downloadDecision.RemoteEpisode.ParsedEpisodeInfo); release.InjectFrom(downloadDecision.RemoteEpisode.ParsedEpisodeInfo);
release.InjectFrom(downloadDecision); release.InjectFrom(downloadDecision);
release.Rejections = downloadDecision.Rejections.ToList(); release.Rejections = downloadDecision.Rejections.ToList();
release.DownloadAllowed = downloadDecision.RemoteEpisode.Series != null;
result.Add(release); result.Add(release);
} }

View file

@ -28,5 +28,6 @@ public class ReleaseResource : RestResource
public String CommentUrl { get; set; } public String CommentUrl { get; set; }
public String DownloadUrl { get; set; } public String DownloadUrl { get; set; }
public String InfoUrl { get; set; } public String InfoUrl { get; set; }
public Boolean DownloadAllowed { get; set; }
} }
} }

View file

@ -29,10 +29,14 @@ define(
}, },
render: function () { render: function () {
this.$el.html('');
if (this.model.get('downloadAllowed'))
{
this.$el.html('<i class="icon-download-alt" title="Add to download queue" />');
}
this.$el.html('<i class="icon-download-alt" title="Add to download queue" />');
return this; return this;
} }
}); });
}); });