EpisodeAiredAfter added to AddSeries UI

New: Ability to skip episodes that aired before a certain date, per
series.
pull/4/head
Mark McDowall 12 years ago
parent 713c4225c0
commit 6c78187601

@ -729,7 +729,7 @@ namespace NzbDrone.Core.Test.ProviderTests
//act //act
var seriesProvider = Mocker.Resolve<SeriesProvider>(); var seriesProvider = Mocker.Resolve<SeriesProvider>();
seriesProvider.AddSeries("Test Series","c:\\test\\", tvDbSeriesId, 1); seriesProvider.AddSeries("Test Series","c:\\test\\", tvDbSeriesId, 1, null);
var episodeProvider = Mocker.Resolve<EpisodeProvider>(); var episodeProvider = Mocker.Resolve<EpisodeProvider>();
episodeProvider.RefreshEpisodeInfo(seriesProvider.GetSeries(tvDbSeriesId)); episodeProvider.RefreshEpisodeInfo(seriesProvider.GetSeries(tvDbSeriesId));

@ -36,7 +36,7 @@ namespace NzbDrone.Core.Test.ProviderTests
//Act //Act
var seriesProvider = Mocker.Resolve<SeriesProvider>(); var seriesProvider = Mocker.Resolve<SeriesProvider>();
seriesProvider.AddSeries(title, path, tvDbId, qualityProfileId); seriesProvider.AddSeries(title, path, tvDbId, qualityProfileId, null);
//Assert //Assert
var series = seriesProvider.GetAllSeries(); var series = seriesProvider.GetAllSeries();
@ -54,7 +54,7 @@ namespace NzbDrone.Core.Test.ProviderTests
public void add_series_should_fail_if_series_is_less_than_zero(int seriesId) public void add_series_should_fail_if_series_is_less_than_zero(int seriesId)
{ {
WithRealDb(); WithRealDb();
Assert.Throws<ArgumentOutOfRangeException>(() => Mocker.Resolve<SeriesProvider>().AddSeries("Title", "C:\\Test", seriesId, 1)); Assert.Throws<ArgumentOutOfRangeException>(() => Mocker.Resolve<SeriesProvider>().AddSeries("Title", "C:\\Test", seriesId, 1, null));
} }
[Test] [Test]

@ -110,7 +110,7 @@ namespace NzbDrone.Core.Providers
return series; return series;
} }
public virtual void AddSeries(string title, string path, int tvDbSeriesId, int qualityProfileId) public virtual void AddSeries(string title, string path, int tvDbSeriesId, int qualityProfileId, DateTime? airedAfter)
{ {
Logger.Info("Adding Series [{0}] Path: [{1}]", tvDbSeriesId, path); Logger.Info("Adding Series [{0}] Path: [{1}]", tvDbSeriesId, path);
@ -131,6 +131,9 @@ namespace NzbDrone.Core.Providers
repoSeries.SeasonFolder = _configProvider.UseSeasonFolder; repoSeries.SeasonFolder = _configProvider.UseSeasonFolder;
repoSeries.BacklogSetting = BacklogSettingType.Inherit; repoSeries.BacklogSetting = BacklogSettingType.Inherit;
if (airedAfter.HasValue)
repoSeries.DownloadEpisodesAiredAfter = airedAfter;
_database.Insert(repoSeries); _database.Insert(repoSeries);
} }

@ -115,7 +115,7 @@ hr
} }
input[type=text], select input[type=text], input[type=date], select
{ {
font-size: small; font-size: small;
padding: 2px 2px; padding: 2px 2px;

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Web.Mvc; using System.Web.Mvc;
@ -116,7 +117,7 @@ namespace NzbDrone.Web.Controllers
} }
[HttpPost] [HttpPost]
public JsonResult AddNewSeries(string path, string seriesName, int seriesId, int qualityProfileId) public JsonResult AddNewSeries(string path, string seriesName, int seriesId, int qualityProfileId, string airedAfter)
{ {
if (string.IsNullOrWhiteSpace(path) || String.Equals(path,"null",StringComparison.InvariantCultureIgnoreCase)) if (string.IsNullOrWhiteSpace(path) || String.Equals(path,"null",StringComparison.InvariantCultureIgnoreCase))
return JsonNotificationResult.Error("Couldn't add " + seriesName, "You need a valid root folder"); return JsonNotificationResult.Error("Couldn't add " + seriesName, "You need a valid root folder");
@ -127,17 +128,22 @@ namespace NzbDrone.Web.Controllers
//Use the created folder name when adding the series //Use the created folder name when adding the series
path = _diskProvider.CreateDirectory(path); path = _diskProvider.CreateDirectory(path);
return AddExistingSeries(path, seriesName, seriesId, qualityProfileId); return AddExistingSeries(path, seriesName, seriesId, qualityProfileId, airedAfter);
} }
[HttpPost] [HttpPost]
[JsonErrorFilter] [JsonErrorFilter]
public JsonResult AddExistingSeries(string path, string seriesName, int seriesId, int qualityProfileId) public JsonResult AddExistingSeries(string path, string seriesName, int seriesId, int qualityProfileId, string airedAfter)
{ {
if (seriesId == 0 || String.IsNullOrWhiteSpace(seriesName)) if (seriesId == 0 || String.IsNullOrWhiteSpace(seriesName))
return JsonNotificationResult.Error("Add Existing series failed.", "Invalid Series information"); return JsonNotificationResult.Error("Add Existing series failed.", "Invalid Series information");
_seriesProvider.AddSeries(seriesName,path, seriesId, qualityProfileId); DateTime? date = null;
if (!String.IsNullOrWhiteSpace(airedAfter))
date = DateTime.Parse(airedAfter, null, DateTimeStyles.RoundtripKind);
_seriesProvider.AddSeries(seriesName,path, seriesId, qualityProfileId, date);
ScanNewSeries(); ScanNewSeries();
return JsonNotificationResult.Info(seriesName, "Was added successfully"); return JsonNotificationResult.Info(seriesName, "Was added successfully");
@ -153,7 +159,7 @@ namespace NzbDrone.Web.Controllers
//Use the created folder name when adding the series //Use the created folder name when adding the series
path = _diskProvider.CreateDirectory(path); path = _diskProvider.CreateDirectory(path);
return AddExistingSeries(path, seriesName, seriesId, qualityProfileId); return AddExistingSeries(path, seriesName, seriesId, qualityProfileId, null);
} }
[ChildActionOnly] [ChildActionOnly]

@ -44,4 +44,10 @@
} }
}); });
}); });
$('.jQuery-dateTime').livequery(function () {
$(this).datepicker({
dateFormat: "yy-mm-dd"
});
});
}); });

@ -24,6 +24,7 @@ $(".addExistingButton").live('click', function() {
var title = $(this).siblings(".seriesLookup").val(); var title = $(this).siblings(".seriesLookup").val();
var seriesId = $(this).siblings(".seriesId").val(); var seriesId = $(this).siblings(".seriesId").val();
var qualityId = $(this).siblings(".qualitySelector").val(); var qualityId = $(this).siblings(".qualitySelector").val();
var date = $(this).siblings('.aired-after').val();
var path = root.find(".seriesPathValue Label").text(); var path = root.find(".seriesPathValue Label").text();
@ -41,7 +42,7 @@ $(".addExistingButton").live('click', function() {
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: addSeriesUrl, url: addSeriesUrl,
data: jQuery.param({ path: path, seriesName: title, seriesId: seriesId, qualityProfileId: qualityId }), data: jQuery.param({ path: path, seriesName: title, seriesId: seriesId, qualityProfileId: qualityId, airedAfter: date }),
error: function(req, status, error) { error: function(req, status, error) {
alert("Sorry! We could not add " + path + " at this time. " + error); alert("Sorry! We could not add " + path + " at this time. " + error);
}, },
@ -64,6 +65,14 @@ function reloadExistingSeries() {
}); });
} }
$(".aired-after-master").live('change', function () {
var date = $(this).val();
$("#existingSeries").find(".aired-after").each(function () {
$(this).val(date);
});
});
//RootDir //RootDir
//Delete RootDir //Delete RootDir
$('#rootDirs .actionButton img').live('click', function (image) { $('#rootDirs .actionButton img').live('click', function (image) {
@ -116,11 +125,12 @@ $('#saveNewSeries').live('click', function () {
var seriesId = $("#newSeriesId").val(); var seriesId = $("#newSeriesId").val();
var qualityId = $("#qualityList").val(); var qualityId = $("#qualityList").val();
var path = $('#newSeriesPath').val(); var path = $('#newSeriesPath').val();
var date = $('#newAiredAfter').val();
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: addNewSeriesUrl, url: addNewSeriesUrl,
data: jQuery.param({ path: path, seriesName: seriesTitle, seriesId: seriesId, qualityProfileId: qualityId }), data: jQuery.param({ path: path, seriesName: seriesTitle, seriesId: seriesId, qualityProfileId: qualityId, airedAfter: date }),
error: function (req, status, error) { error: function (req, status, error) {
alert("Sorry! We could not add " + path + " at this time. " + error); alert("Sorry! We could not add " + path + " at this time. " + error);
}, },

@ -7,6 +7,7 @@
</div> </div>
@Html.DropDownList("newSeriesPath", new SelectList((IList)ViewData["RootDirs"]), new { style = "width: 406px; margin-left: 0px;" }) @Html.DropDownList("newSeriesPath", new SelectList((IList)ViewData["RootDirs"]), new { style = "width: 406px; margin-left: 0px;" })
@Html.DropDownList("qualityList", (SelectList)ViewData["QualityProfiles"], new { @class = "qualitySelector" }) @Html.DropDownList("qualityList", (SelectList)ViewData["QualityProfiles"], new { @class = "qualitySelector" })
@Html.TextBox("newAiredAfter", "", new { type = "date", @class = "jQuery-dateTime aired-after", title = "Only download episodes that aired after the choosen date" })
<button id="saveNewSeries"> <button id="saveNewSeries">
Add</button> Add</button>
</div> </div>

@ -23,6 +23,8 @@ else
{ {
@Html.DropDownList(Guid.NewGuid().ToString(), Model.Quality, new { @class = "qualitySelector masterQualitySelector" }) @Html.DropDownList(Guid.NewGuid().ToString(), Model.Quality, new { @class = "qualitySelector masterQualitySelector" })
@Html.TextBox(Guid.NewGuid().ToString(), "", new { type="date", @class = "jQuery-dateTime aired-after-master", title = "Skip episodes that aired before the choosen date" })
foreach (var series in Model.ExistingSeries) foreach (var series in Model.ExistingSeries)
{ {
<div class="existingSeries"> <div class="existingSeries">
@ -30,9 +32,10 @@ else
<label>@series.Item1</label> <label>@series.Item1</label>
</span> </span>
<div class="existingSeriesContainer"> <div class="existingSeriesContainer">
<input class="seriesLookup" type="text" style="width: 400px;" value="@series.Item2" /> <input class="seriesLookup" type="text" style="width: 400px;" value="@series.Item2" placeholder="Series Title" />
@Html.Hidden("seriesId", series.Item3, new { @class = "seriesId" }) @Html.Hidden("seriesId", series.Item3, new { @class = "seriesId" })
@Html.DropDownList(Guid.NewGuid().ToString(), Model.Quality, new { @class = "qualitySelector" }) @Html.DropDownList(Guid.NewGuid().ToString(), Model.Quality, new { @class = "qualitySelector" })
@Html.TextBox(Guid.NewGuid().ToString(), "", new { type="date", @class = "jQuery-dateTime aired-after", title = "Only download episodes that aired after the choosen date" })
<button class="addExistingButton"> <button class="addExistingButton">
Add</button> Add</button>
</div> </div>

@ -20,6 +20,11 @@
position: relative; position: relative;
} }
.aired-after-master {
left: 430px;
position: relative;
}
.seriesPathValue .seriesPathValue
{ {
display: block; display: block;
@ -45,6 +50,10 @@
cursor: pointer; cursor: pointer;
text-decoration: underline; text-decoration: underline;
} }
input[type=date].aired-after {
margin-left: 10px;
}
</style> </style>
} }

Loading…
Cancel
Save