diff --git a/NzbDrone.Core/Jobs/BacklogSearchJob.cs b/NzbDrone.Core/Jobs/BacklogSearchJob.cs
index 04989c524..f9f270f90 100644
--- a/NzbDrone.Core/Jobs/BacklogSearchJob.cs
+++ b/NzbDrone.Core/Jobs/BacklogSearchJob.cs
@@ -3,6 +3,7 @@ using System.Linq;
using NLog;
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Providers;
+using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
namespace NzbDrone.Core.Jobs
@@ -12,15 +13,17 @@ namespace NzbDrone.Core.Jobs
private readonly EpisodeProvider _episodeProvider;
private readonly EpisodeSearchJob _episodeSearchJob;
private readonly SeasonSearchJob _seasonSearchJob;
+ private readonly ConfigProvider _configProvider;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
public BacklogSearchJob(EpisodeProvider episodeProvider, EpisodeSearchJob episodeSearchJob,
- SeasonSearchJob seasonSearchJob)
+ SeasonSearchJob seasonSearchJob, ConfigProvider configProvider)
{
_episodeProvider = episodeProvider;
_episodeSearchJob = episodeSearchJob;
_seasonSearchJob = seasonSearchJob;
+ _configProvider = configProvider;
}
public string Name
@@ -35,6 +38,12 @@ namespace NzbDrone.Core.Jobs
public void Start(ProgressNotification notification, int targetId, int secondaryTargetId)
{
+ if (!_configProvider.EnableBacklogSearching)
+ {
+ Logger.Trace("Backlog searching is not enabled, aborting job.");
+ return;
+ }
+
var missingEpisodes = _episodeProvider.EpisodesWithoutFiles(true)
.GroupBy(e => new { e.SeriesId, e.SeasonNumber });
diff --git a/NzbDrone.Core/Jobs/RecentBacklogSearchJob.cs b/NzbDrone.Core/Jobs/RecentBacklogSearchJob.cs
index be399ec08..518a2f928 100644
--- a/NzbDrone.Core/Jobs/RecentBacklogSearchJob.cs
+++ b/NzbDrone.Core/Jobs/RecentBacklogSearchJob.cs
@@ -3,6 +3,7 @@ using System.Linq;
using NLog;
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Providers;
+using NzbDrone.Core.Providers.Core;
namespace NzbDrone.Core.Jobs
{
@@ -10,13 +11,16 @@ namespace NzbDrone.Core.Jobs
{
private readonly EpisodeProvider _episodeProvider;
private readonly EpisodeSearchJob _episodeSearchJob;
+ private readonly ConfigProvider _configProvider;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
- public RecentBacklogSearchJob(EpisodeProvider episodeProvider, EpisodeSearchJob episodeSearchJob)
+ public RecentBacklogSearchJob(EpisodeProvider episodeProvider, EpisodeSearchJob episodeSearchJob,
+ ConfigProvider configProvider)
{
_episodeProvider = episodeProvider;
_episodeSearchJob = episodeSearchJob;
+ _configProvider = configProvider;
}
public string Name
@@ -31,6 +35,12 @@ namespace NzbDrone.Core.Jobs
public void Start(ProgressNotification notification, int targetId, int secondaryTargetId)
{
+ if (!_configProvider.EnableBacklogSearching)
+ {
+ Logger.Trace("Backlog searching is not enabled, aborting job.");
+ return;
+ }
+
//Get episodes that are considered missing and aired in the last 30 days
var missingEpisodes = _episodeProvider.EpisodesWithoutFiles(true).Where(e => e.AirDate >= DateTime.Today.AddDays(-30));
diff --git a/NzbDrone.Core/Providers/Core/ConfigProvider.cs b/NzbDrone.Core/Providers/Core/ConfigProvider.cs
index 407fbc6f1..dc74e7c7f 100644
--- a/NzbDrone.Core/Providers/Core/ConfigProvider.cs
+++ b/NzbDrone.Core/Providers/Core/ConfigProvider.cs
@@ -396,6 +396,12 @@ namespace NzbDrone.Core.Providers.Core
set { SetValue("ProwlPriority", value); }
}
+ public virtual bool EnableBacklogSearching
+ {
+ get { return GetValueBoolean("EnableBacklogSearching"); }
+ set { SetValue("EnableBacklogSearching", value); }
+ }
+
private string GetValue(string key)
{
return GetValue(key, String.Empty);
diff --git a/NzbDrone.Web/Controllers/SettingsController.cs b/NzbDrone.Web/Controllers/SettingsController.cs
index 0904e1ac9..9492194ca 100644
--- a/NzbDrone.Web/Controllers/SettingsController.cs
+++ b/NzbDrone.Web/Controllers/SettingsController.cs
@@ -221,6 +221,14 @@ namespace NzbDrone.Web.Controllers
return View(model);
}
+ public ActionResult Misc()
+ {
+ var model = new MiscSettingsModel();
+ model.EnableBacklogSearching = _configProvider.EnableBacklogSearching;
+
+ return View(model);
+ }
+
public PartialViewResult AddProfile()
{
var qualityProfile = new QualityProfile
@@ -582,6 +590,19 @@ namespace NzbDrone.Web.Controllers
return GetInvalidModelResult();
}
+ [HttpPost]
+ public JsonResult SaveMisc(MiscSettingsModel data)
+ {
+ if (ModelState.IsValid)
+ {
+ _configProvider.EnableBacklogSearching = data.EnableBacklogSearching;
+
+ return GetSuccessResult();
+ }
+
+ return GetInvalidModelResult();
+ }
+
private JsonResult GetSuccessResult()
{
return Json(new NotificationResult() { Title = "Settings Saved" });
diff --git a/NzbDrone.Web/Models/MiscSettingsModel.cs b/NzbDrone.Web/Models/MiscSettingsModel.cs
new file mode 100644
index 000000000..d71ccf9ad
--- /dev/null
+++ b/NzbDrone.Web/Models/MiscSettingsModel.cs
@@ -0,0 +1,15 @@
+using System;
+using System.ComponentModel;
+using System.ComponentModel.DataAnnotations;
+using System.Web.Mvc;
+using NzbDrone.Core.Model;
+
+namespace NzbDrone.Web.Models
+{
+ public class MiscSettingsModel
+ {
+ [DisplayName("Enable Backlog Searching")]
+ [Description("Should NzbDrone try tp download missing episodes automatically?")]
+ public bool EnableBacklogSearching { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/NzbDrone.Web/NzbDrone.Web.csproj b/NzbDrone.Web/NzbDrone.Web.csproj
index 2547789bb..df16431a0 100644
--- a/NzbDrone.Web/NzbDrone.Web.csproj
+++ b/NzbDrone.Web/NzbDrone.Web.csproj
@@ -226,6 +226,7 @@
+
@@ -525,6 +526,9 @@
+
+
+