From e62cb3b5da1a4f23ef3f192bef6012baa2ac8467 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Mon, 28 Mar 2011 13:22:12 -0700 Subject: [PATCH] Updated .gitignore to not store .nzb Add [PROPER] to titleFix if it's a proper. User can now change the QualityProfile when adding a series (new or existing), option will default to their DefaultQualityProfile. --- .gitignore | 3 +- NzbDrone.Core/Model/SeriesMappingModel.cs | 1 + NzbDrone.Core/Providers/ISeriesProvider.cs | 2 +- NzbDrone.Core/Providers/ISyncProvider.cs | 4 +- .../Providers/RssItemProcessingProvider.cs | 8 ++++ NzbDrone.Core/Providers/SeriesProvider.cs | 7 +++- NzbDrone.Core/Providers/SyncProvider.cs | 10 ++--- NzbDrone.Web/Controllers/SeriesController.cs | 37 +++++++++++++++---- NzbDrone.Web/Models/AddExistingManualModel.cs | 7 ++++ NzbDrone.Web/Models/AddNewSeriesModel.cs | 6 +++ NzbDrone.Web/Views/Series/AddExisting.aspx | 8 +++- .../Views/Series/AddExistingManual.aspx | 19 ++++++++-- NzbDrone.Web/Views/Series/AddNew.aspx | 17 +++++++-- 13 files changed, 103 insertions(+), 26 deletions(-) diff --git a/.gitignore b/.gitignore index f091a3646..10fe732d4 100644 --- a/.gitignore +++ b/.gitignore @@ -21,11 +21,12 @@ Thumbs.db [Dd]ebug*/ *.lib *.sbr +*.nzb obj/ [Rr]elease*/ _ReSharper*/ [Tt]est[Rr]esult[s] - +[Nn]zbs [Bb]uild/ [Ll]ogs/ /[Pp]ackage/ diff --git a/NzbDrone.Core/Model/SeriesMappingModel.cs b/NzbDrone.Core/Model/SeriesMappingModel.cs index 30632266a..91522c3f6 100644 --- a/NzbDrone.Core/Model/SeriesMappingModel.cs +++ b/NzbDrone.Core/Model/SeriesMappingModel.cs @@ -9,5 +9,6 @@ namespace NzbDrone.Core.Model { public string Path { get; set; } public int TvDbId { get; set; } + public int QualityProfileId { get; set; } } } diff --git a/NzbDrone.Core/Providers/ISeriesProvider.cs b/NzbDrone.Core/Providers/ISeriesProvider.cs index f9d09e7d3..84763b350 100644 --- a/NzbDrone.Core/Providers/ISeriesProvider.cs +++ b/NzbDrone.Core/Providers/ISeriesProvider.cs @@ -20,7 +20,7 @@ namespace NzbDrone.Core.Providers bool IsMonitored(long id); TvdbSeries MapPathToSeries(string path); TvdbSeries MapPathToSeries(int tvDbId); - void AddSeries(string path, TvdbSeries series); + void AddSeries(string path, TvdbSeries series, int qualityProfileId); Series FindSeries(string cleanTitle); bool QualityWanted(int seriesId, QualityTypes quality); void UpdateSeries(Series series); diff --git a/NzbDrone.Core/Providers/ISyncProvider.cs b/NzbDrone.Core/Providers/ISyncProvider.cs index 1ab4865e1..0aa902b8c 100644 --- a/NzbDrone.Core/Providers/ISyncProvider.cs +++ b/NzbDrone.Core/Providers/ISyncProvider.cs @@ -7,8 +7,8 @@ namespace NzbDrone.Core.Providers public interface ISyncProvider { bool BeginSyncUnmappedFolders(List unmapped); - bool BeginAddNewSeries(string dir, int seriesId, string seriesName); - bool BeginAddExistingSeries(string path, int seriesId); + bool BeginAddNewSeries(string dir, int seriesId, string seriesName, int qualityProfileId); + bool BeginAddExistingSeries(string path, int seriesId, int qualityProfileId); List GetUnmappedFolders(string path); } } \ No newline at end of file diff --git a/NzbDrone.Core/Providers/RssItemProcessingProvider.cs b/NzbDrone.Core/Providers/RssItemProcessingProvider.cs index 1e91915cb..8553e85cd 100644 --- a/NzbDrone.Core/Providers/RssItemProcessingProvider.cs +++ b/NzbDrone.Core/Providers/RssItemProcessingProvider.cs @@ -154,6 +154,10 @@ namespace NzbDrone.Core.Providers var titleFix = GetTitleFix(new List { episode }, episodeModel.SeriesId); titleFix = String.Format("{0} [{1}]", titleFix, nzb.Quality); //Add Quality to the titleFix + //If it is a PROPER we want to put PROPER in the titleFix + if (nzb.Proper) + titleFix = String.Format("{0} [PROPER]", titleFix); + if (!Convert.ToBoolean(_configProvider.GetValue("UseBlackhole", true, true))) if (_sabProvider.IsInQueue(titleFix)) return; @@ -162,6 +166,10 @@ namespace NzbDrone.Core.Providers nzb.TitleFix = GetTitleFix(episodeParseResults, series.SeriesId); //Get the TitleFix so we can use it later nzb.TitleFix = String.Format("{0} [{1}]", nzb.TitleFix, nzb.Quality); //Add Quality to the titleFix + //If it is a PROPER we want to put PROPER in the titleFix + if (nzb.Proper) + nzb.TitleFix = String.Format("{0} [PROPER]", nzb.TitleFix); + if (Convert.ToBoolean(_configProvider.GetValue("UseBlackHole", true, true))) { if (DownloadNzb(nzb)) diff --git a/NzbDrone.Core/Providers/SeriesProvider.cs b/NzbDrone.Core/Providers/SeriesProvider.cs index 4e8dbcc56..92bbcd4d2 100644 --- a/NzbDrone.Core/Providers/SeriesProvider.cs +++ b/NzbDrone.Core/Providers/SeriesProvider.cs @@ -81,7 +81,7 @@ namespace NzbDrone.Core.Providers return _tvDb.GetSeries(tvDbId, false); } - public void AddSeries(string path, TvdbSeries series) + public void AddSeries(string path, TvdbSeries series, int qualityProfileId) { Logger.Info("Adding Series [{0}]:{1} Path: {2}", series.Id, series.SeriesName, path); var repoSeries = new Series(); @@ -95,7 +95,10 @@ namespace NzbDrone.Core.Providers repoSeries.Path = path; repoSeries.CleanTitle = Parser.NormalizeTitle(series.SeriesName); repoSeries.Monitored = true; //New shows should be monitored - repoSeries.QualityProfileId = Convert.ToInt32(_config.GetValue("DefaultQualityProfile", "1", true)); + repoSeries.QualityProfileId = qualityProfileId; + if (qualityProfileId == 0) + repoSeries.QualityProfileId = Convert.ToInt32(_config.GetValue("DefaultQualityProfile", "1", true)); + repoSeries.SeasonFolder = true; if (!Convert.ToBoolean(_config.GetValue("Sorting_SeasonFolder", true, true))) diff --git a/NzbDrone.Core/Providers/SyncProvider.cs b/NzbDrone.Core/Providers/SyncProvider.cs index 64bc283ce..b0bb106c5 100644 --- a/NzbDrone.Core/Providers/SyncProvider.cs +++ b/NzbDrone.Core/Providers/SyncProvider.cs @@ -90,7 +90,7 @@ namespace NzbDrone.Core.Providers return true; } - public bool BeginAddNewSeries(string dir, int seriesId, string seriesName) + public bool BeginAddNewSeries(string dir, int seriesId, string seriesName, int qualityProfileId) { Logger.Debug("User has requested adding of new series"); if (_seriesSyncThread == null || !_seriesSyncThread.IsAlive) @@ -110,7 +110,7 @@ namespace NzbDrone.Core.Providers _diskProvider.CreateDirectory(path); //Add it to the list so it will be processed - _syncList.Add(new SeriesMappingModel { Path = path, TvDbId = seriesId }); + _syncList.Add(new SeriesMappingModel { Path = path, TvDbId = seriesId, QualityProfileId = qualityProfileId }); _seriesSyncThread.Start(); } @@ -126,7 +126,7 @@ namespace NzbDrone.Core.Providers return true; } - public bool BeginAddExistingSeries(string path, int seriesId) + public bool BeginAddExistingSeries(string path, int seriesId, int qualityProfileId) { Logger.Debug("User has requested adding of new series"); if (_seriesSyncThread == null || !_seriesSyncThread.IsAlive) @@ -141,7 +141,7 @@ namespace NzbDrone.Core.Providers _syncList = new List(); //Add it to the list so it will be processed - _syncList.Add(new SeriesMappingModel { Path = path, TvDbId = seriesId }); + _syncList.Add(new SeriesMappingModel { Path = path, TvDbId = seriesId, QualityProfileId = qualityProfileId }); _seriesSyncThread.Start(); } @@ -194,7 +194,7 @@ namespace NzbDrone.Core.Providers if (_seriesProvider.GetSeries(mappedSeries.Id) == null) { _seriesSyncNotification.CurrentStatus = String.Format("{0}: downloading series info...", mappedSeries.SeriesName); - _seriesProvider.AddSeries(seriesFolder.Path, mappedSeries); + _seriesProvider.AddSeries(seriesFolder.Path, mappedSeries, seriesFolder.QualityProfileId); _episodeProvider.RefreshEpisodeInfo(mappedSeries.Id); _seriesSyncNotification.CurrentStatus = String.Format("{0}: finding episodes on disk...", mappedSeries.SeriesName); _mediaFileProvider.Scan(_seriesProvider.GetSeries(mappedSeries.Id)); diff --git a/NzbDrone.Web/Controllers/SeriesController.cs b/NzbDrone.Web/Controllers/SeriesController.cs index e70d55482..f544bc45c 100644 --- a/NzbDrone.Web/Controllers/SeriesController.cs +++ b/NzbDrone.Web/Controllers/SeriesController.cs @@ -29,6 +29,7 @@ namespace NzbDrone.Web.Controllers private readonly IRootDirProvider _rootDirProvider; private readonly ITvDbProvider _tvDbProvider; private readonly IDiskProvider _diskProvider; + private readonly IConfigProvider _configProvider; // // GET: /Series/ @@ -37,7 +38,8 @@ namespace NzbDrone.Web.Controllers IEpisodeProvider episodeProvider, IRssSyncProvider rssSyncProvider, IQualityProvider qualityProvider, IMediaFileProvider mediaFileProvider, IRenameProvider renameProvider, IRootDirProvider rootDirProvider, - ITvDbProvider tvDbProvider, IDiskProvider diskProvider) + ITvDbProvider tvDbProvider, IDiskProvider diskProvider, + IConfigProvider configProvider) { _seriesProvider = seriesProvider; _episodeProvider = episodeProvider; @@ -49,6 +51,7 @@ namespace NzbDrone.Web.Controllers _rootDirProvider = rootDirProvider; _tvDbProvider = tvDbProvider; _diskProvider = diskProvider; + _configProvider = configProvider; } public ActionResult Index() @@ -64,6 +67,13 @@ namespace NzbDrone.Web.Controllers public ActionResult AddExisting() { + var defaultQuality = Convert.ToInt32(_configProvider.GetValue("DefaultQualityProfile", "1", true)); + var profiles = _qualityProvider.GetAllProfiles(); + var selectList = new SelectList(profiles, "QualityProfileId", "Name"); + + ViewData["QualityProfileId"] = defaultQuality; + ViewData["QualitySelectList"] = selectList; + return View(); } @@ -72,10 +82,16 @@ namespace NzbDrone.Web.Controllers ViewData["RootDirs"] = _rootDirProvider.GetAll(); ViewData["DirSep"] = Path.DirectorySeparatorChar; + var profiles = _qualityProvider.GetAllProfiles(); + var selectList = new SelectList(profiles, "QualityProfileId", "Name"); + var defaultQuality = Convert.ToInt32(_configProvider.GetValue("DefaultQualityProfile", "1", true)); + var model = new AddNewSeriesModel { DirectorySeparatorChar = Path.DirectorySeparatorChar.ToString(), - RootDirectories = _rootDirProvider.GetAll() + RootDirectories = _rootDirProvider.GetAll(), + QualityProfileId = defaultQuality, + QualitySelectList = selectList }; return View(model); @@ -83,9 +99,15 @@ namespace NzbDrone.Web.Controllers public ActionResult AddExistingManual(string path) { + var profiles = _qualityProvider.GetAllProfiles(); + var selectList = new SelectList(profiles, "QualityProfileId", "Name"); + var defaultQuality = Convert.ToInt32(_configProvider.GetValue("DefaultQualityProfile", "1", true)); + var model = new AddExistingManualModel(); model.Path = path; model.FolderName = _diskProvider.GetFolderName(path); + model.QualityProfileId = defaultQuality; + model.QualitySelectList = selectList; return View(model); } @@ -177,11 +199,12 @@ namespace NzbDrone.Web.Controllers var path = HttpUtility.UrlDecode(nvc["path"]); var tvDbId = Convert.ToInt32(HttpUtility.UrlDecode(nvc["tvdbid"])); + var qualityProfileId = Convert.ToInt32(HttpUtility.UrlDecode(nvc["qualityProfileId"])); //If the TvDbId for this show is 0 then skip it... User made a mistake... They will have to manually map it if (tvDbId < 1) continue; - unmappedList.Add(new SeriesMappingModel{Path = path, TvDbId = tvDbId}); + unmappedList.Add(new SeriesMappingModel{Path = path, TvDbId = tvDbId, QualityProfileId = qualityProfileId}); } if(_syncProvider.BeginSyncUnmappedFolders(unmappedList)) @@ -190,25 +213,25 @@ namespace NzbDrone.Web.Controllers return Content("Sync already in progress, please wait for it to complete before retrying."); } - public ActionResult AddNewSeries(string dir, int seriesId, string seriesName) + public ActionResult AddNewSeries(string dir, int seriesId, string seriesName, int qualityProfileId) { //Get TVDB Series Name //Create new folder for series //Add the new series to the Database - if (_syncProvider.BeginAddNewSeries(dir, seriesId, seriesName)) + if (_syncProvider.BeginAddNewSeries(dir, seriesId, seriesName, qualityProfileId)) return Content("Adding new series has started."); return Content("Unable to add new series, please wait for previous scans to complete first."); } - public ActionResult AddExistingSeries(string path, int seriesId) + public ActionResult AddExistingSeries(string path, int seriesId, int qualityProfileId) { //Get TVDB Series Name //Create new folder for series //Add the new series to the Database - if (_syncProvider.BeginAddExistingSeries(path, seriesId)) + if (_syncProvider.BeginAddExistingSeries(path, seriesId, qualityProfileId)) return Content("Manual adding of existing series has started"); return Content("Unable to add existing series, please wait for previous scans to complete first."); diff --git a/NzbDrone.Web/Models/AddExistingManualModel.cs b/NzbDrone.Web/Models/AddExistingManualModel.cs index bb1090daf..0b612a486 100644 --- a/NzbDrone.Web/Models/AddExistingManualModel.cs +++ b/NzbDrone.Web/Models/AddExistingManualModel.cs @@ -1,7 +1,9 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.Linq; using System.Web; +using System.Web.Mvc; namespace NzbDrone.Web.Models { @@ -9,5 +11,10 @@ namespace NzbDrone.Web.Models { public string Path { get; set; } public string FolderName { get; set; } + + [DisplayName("Quality Profile")] + public int QualityProfileId { get; set; } + + public SelectList QualitySelectList { get; set; } } } \ No newline at end of file diff --git a/NzbDrone.Web/Models/AddNewSeriesModel.cs b/NzbDrone.Web/Models/AddNewSeriesModel.cs index 705967573..b79dacaff 100644 --- a/NzbDrone.Web/Models/AddNewSeriesModel.cs +++ b/NzbDrone.Web/Models/AddNewSeriesModel.cs @@ -4,6 +4,7 @@ using System.ComponentModel; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Web; +using System.Web.Mvc; using NzbDrone.Core.Repository; namespace NzbDrone.Web.Models @@ -19,5 +20,10 @@ namespace NzbDrone.Web.Models public string DirectorySeparatorChar { get; set; } public List RootDirectories { get; set; } + + [DisplayName("Quality Profile")] + public int QualityProfileId { get; set; } + + public SelectList QualitySelectList { get; set; } } } \ No newline at end of file diff --git a/NzbDrone.Web/Views/Series/AddExisting.aspx b/NzbDrone.Web/Views/Series/AddExisting.aspx index 512c31119..b39133a17 100644 --- a/NzbDrone.Web/Views/Series/AddExisting.aspx +++ b/NzbDrone.Web/Views/Series/AddExisting.aspx @@ -38,6 +38,9 @@ + <%= Html.Label("Quality Profile")%> + <%: Html.DropDownList("qualityProfileId", (SelectList)ViewData["QualitySelectList"], ViewData["QualityProfileId"])%> + - <%= Html.Label("Enter a Series Name") %> - <%= Html.TextBoxFor(m => m.FolderName, new { id="existing_series_id" }) %> - <%= Html.TextBoxFor(m => m.Path, new { id ="series_path", style="display:none" }) %> +
+
+ <%= Html.Label("Enter a Series Name") %> + <%= Html.TextBoxFor(m => m.FolderName, new { id="existing_series_id" }) %> + <%= Html.TextBoxFor(m => m.Path, new { id ="series_path", style="display:none" }) %> +
+ +
+ <%= Html.LabelFor(m => m.QualityProfileId)%> + <%: Html.DropDownListFor(m => m.QualityProfileId, Model.QualitySelectList)%> +
+

@@ -72,13 +81,15 @@ var id = "#" + checkedSeries + "_text"; var seriesName = $(id).val(); + var qualityProfileId = $("#QualityProfileId").val(); var pathTest = $('#series_path').val(); $('#tester').text(pathTest); $("#addResult").load('<%=Url.Action("AddExistingSeries", "Series") %>', { path: pathTest, - seriesId: checkedSeries + seriesId: checkedSeries, + qualityProfileId: qualityProfileId }); } diff --git a/NzbDrone.Web/Views/Series/AddNew.aspx b/NzbDrone.Web/Views/Series/AddNew.aspx index fc015ab6a..7b974e7f3 100644 --- a/NzbDrone.Web/Views/Series/AddNew.aspx +++ b/NzbDrone.Web/Views/Series/AddNew.aspx @@ -20,8 +20,17 @@ - <%= Html.Label("Enter a Series Name") %> - <%= Html.TextBox("new_series_name", String.Empty, new { id="new_series_id" }) %> +

+
+ <%= Html.Label("Enter a Series Name") %> + <%= Html.TextBox("new_series_name", String.Empty, new { id="new_series_id" }) %> +
+ +
+ <%= Html.LabelFor(m => m.QualityProfileId)%> + <%: Html.DropDownListFor(m => m.QualityProfileId, Model.QualitySelectList)%> +
+

@@ -90,11 +99,13 @@ var id = "#" + checkedSeries + "_text"; var seriesName = $(id).val(); + var qualityProfileId = $("#QualityProfileId").val(); $("#addResult").load('<%=Url.Action("AddNewSeries", "Series") %>', { dir: checkedDir, seriesId: checkedSeries, - seriesName: seriesName + seriesName: seriesName, + qualityProfileId: qualityProfileId }); }