diff --git a/NzbDrone.Core/Providers/ISyncProvider.cs b/NzbDrone.Core/Providers/ISyncProvider.cs index 6a0018460..8efc55b44 100644 --- a/NzbDrone.Core/Providers/ISyncProvider.cs +++ b/NzbDrone.Core/Providers/ISyncProvider.cs @@ -7,6 +7,7 @@ namespace NzbDrone.Core.Providers public interface ISyncProvider { bool BeginSyncUnmappedFolders(List unmapped); + bool BeginAddNewSeries(string dir, int seriesId, string seriesName); List GetUnmappedFolders(string path); } } \ No newline at end of file diff --git a/NzbDrone.Core/Providers/SyncProvider.cs b/NzbDrone.Core/Providers/SyncProvider.cs index 7dba12904..030b741fa 100644 --- a/NzbDrone.Core/Providers/SyncProvider.cs +++ b/NzbDrone.Core/Providers/SyncProvider.cs @@ -65,7 +65,7 @@ namespace NzbDrone.Core.Providers public bool BeginSyncUnmappedFolders(List unmapped) { - Logger.Debug("User has request series folder scan"); + Logger.Debug("User has requested series folder scan"); if (_seriesSyncThread == null || !_seriesSyncThread.IsAlive) { Logger.Debug("Initializing background scan of series folder."); @@ -90,6 +90,42 @@ namespace NzbDrone.Core.Providers return true; } + public bool BeginAddNewSeries(string dir, int seriesId, string seriesName) + { + Logger.Debug("User has requested adding of new series"); + if (_seriesSyncThread == null || !_seriesSyncThread.IsAlive) + { + Logger.Debug("Initializing background add of of series folder."); + _seriesSyncThread = new Thread(SyncUnmappedFolders) + { + Name = "SyncUnmappedFolders", + Priority = ThreadPriority.Lowest + }; + + _syncList = new List(); + + var path = dir + Path.DirectorySeparatorChar + seriesName; + + //Create a directory for this new series + _diskProvider.CreateDirectory(path); + + //Add it to the list so it will be processed + _syncList.Add(new SeriesMappingModel { Path = path, TvDbId = seriesId }); + + _seriesSyncThread.Start(); + } + else + { + Logger.Warn("Series folder scan already in progress. Ignoring request."); + + //return false if sync was already running, then we can tell the user to try again later + return false; + } + + //return true if sync has started + return true; + } + private void SyncUnmappedFolders() { Logger.Info("Starting Series folder scan"); diff --git a/NzbDrone.Web/Controllers/SeriesController.cs b/NzbDrone.Web/Controllers/SeriesController.cs index 68400213c..da1e677d8 100644 --- a/NzbDrone.Web/Controllers/SeriesController.cs +++ b/NzbDrone.Web/Controllers/SeriesController.cs @@ -169,26 +169,38 @@ 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) + { + //Get TVDB Series Name + //Create new folder for series + //Add the new series to the Database + + if (_syncProvider.BeginAddNewSeries(dir, seriesId, seriesName)) + return Content("Adding new series has started."); + + return Content("Unable to add new series, please wait for previous scans to complete first."); + } + public ActionResult SearchForSeries(string seriesName) { var model = new List(); //Get Results from TvDb and convert them to something we can use. - foreach (var tvdbSearchResult in _tvDbProvider.SearchSeries(seriesName)) - { - model.Add(new SeriesSearchResultModel - { - TvDbId = tvdbSearchResult.Id, - TvDbName = tvdbSearchResult.SeriesName, - FirstAired = tvdbSearchResult.FirstAired - }); - } + //foreach (var tvdbSearchResult in _tvDbProvider.SearchSeries(seriesName)) + //{ + // model.Add(new SeriesSearchResultModel + // { + // TvDbId = tvdbSearchResult.Id, + // TvDbName = tvdbSearchResult.SeriesName, + // FirstAired = tvdbSearchResult.FirstAired + // }); + //} ViewData["RootDirs"] = _rootDirProvider.GetAll(); ViewData["DirSep"] = Path.DirectorySeparatorChar; - //model.Add(new SeriesSearchResultModel{ TvDbId = 12345, TvDbName = "30 Rock", FirstAired = DateTime.Today }); - //model.Add(new SeriesSearchResultModel { TvDbId = 65432, TvDbName = "The Office (US)", FirstAired = DateTime.Today.AddDays(-100) }); + model.Add(new SeriesSearchResultModel{ TvDbId = 12345, TvDbName = "30 Rock", FirstAired = DateTime.Today }); + model.Add(new SeriesSearchResultModel { TvDbId = 65432, TvDbName = "The Office (US)", FirstAired = DateTime.Today.AddDays(-100) }); return PartialView("SeriesSearchResults", model); } diff --git a/NzbDrone.Web/Views/Series/AddNew.aspx b/NzbDrone.Web/Views/Series/AddNew.aspx index cc380409d..0db4a4201 100644 --- a/NzbDrone.Web/Views/Series/AddNew.aspx +++ b/NzbDrone.Web/Views/Series/AddNew.aspx @@ -18,14 +18,6 @@

- - //Search Button - Perform AJAX search for this Series on TVDB - - //Return results with Radio Box + First Aired information, (link to TVDB too?) + Hidden ID text - - User selects radio button and then presses add (or skips which clears results and #new_series_id) - - Add, ask user to choose where to save the show in (used when sorting) then add the show... Possibly ask user to choose Quality Profile
@@ -48,7 +40,7 @@ ); } - +
diff --git a/NzbDrone.Web/Views/Series/SeriesSearchResults.ascx b/NzbDrone.Web/Views/Series/SeriesSearchResults.ascx index 6395ebb4e..46d894cbe 100644 --- a/NzbDrone.Web/Views/Series/SeriesSearchResults.ascx +++ b/NzbDrone.Web/Views/Series/SeriesSearchResults.ascx @@ -4,23 +4,32 @@
Search Results + + <% int r = 0; %> <% foreach (var result in Model) { %> - <%: Html.RadioButton("selectedSeries", result.TvDbId, new { @class="searchRadio examplePart", name = result.TvDbName }) %> - <%: Html.Label(result.TvDbName) %> (<%: Html.Label(result.FirstAired.ToString()) %>) + <%: Html.RadioButton("selectedSeries", result.TvDbId, new { @class="searchRadio examplePart", id="searchRadio_" + r }) %> + <%: Html.Label(result.TvDbName) %> (<%: Html.Label(result.FirstAired.ToString("MM/dd/yyyy"))%>) + + <%: Html.TextBox(result.TvDbName + "_text", result.TvDbName, new { id = result.TvDbId + "_text", style="display:none" }) %> + <% r++;%>
- <% } %> + <% + } %>
-
+
\ No newline at end of file diff --git a/NzbDrone.Web/Views/Settings/General.ascx b/NzbDrone.Web/Views/Settings/General.ascx index d54882ce3..8b6823da0 100644 --- a/NzbDrone.Web/Views/Settings/General.ascx +++ b/NzbDrone.Web/Views/Settings/General.ascx @@ -29,9 +29,6 @@ <%: Html.ValidationSummary(true, "Unable to save your settings. Please correct the errors and try again.") %>
General - - //Browse Button?? - //Auto-Complete?