New: Rename all series added to Series Editor

pull/3113/head
Mark McDowall 12 years ago
parent 4ca828db81
commit e5b6f63e6e

@ -43,11 +43,20 @@ namespace NzbDrone.Core.Jobs
public void Start(ProgressNotification notification, int targetId, int secondaryTargetId) public void Start(ProgressNotification notification, int targetId, int secondaryTargetId)
{ {
List<Series> seriesToRename;
if (targetId <= 0) if (targetId <= 0)
throw new ArgumentOutOfRangeException("targetId"); {
seriesToRename = _seriesProvider.GetAllSeries().ToList();
}
var series = _seriesProvider.GetSeries(targetId); else
{
seriesToRename = new List<Series>{ _seriesProvider.GetSeries(targetId) };
}
foreach(var series in seriesToRename)
{
notification.CurrentMessage = String.Format("Renaming episodes for '{0}'", series.Title); notification.CurrentMessage = String.Format("Renaming episodes for '{0}'", series.Title);
Logger.Debug("Getting episodes from database for series: {0}", series.SeriesId); Logger.Debug("Getting episodes from database for series: {0}", series.SeriesId);
@ -76,7 +85,7 @@ namespace NzbDrone.Core.Jobs
} }
} }
catch(Exception e) catch (Exception e)
{ {
Logger.WarnException("An error has occurred while renaming file", e); Logger.WarnException("An error has occurred while renaming file", e);
} }
@ -94,4 +103,5 @@ namespace NzbDrone.Core.Jobs
notification.CurrentMessage = String.Format("Rename completed for {0}", series.Title); notification.CurrentMessage = String.Format("Rename completed for {0}", series.Title);
} }
} }
}
} }

@ -41,10 +41,16 @@ namespace NzbDrone.Web.Controllers
} }
public JsonResult RenameEpisodes(int seriesId) public JsonResult RenameSeries(int seriesId)
{ {
_jobProvider.QueueJob(typeof(RenameSeriesJob), seriesId); _jobProvider.QueueJob(typeof(RenameSeriesJob), seriesId);
return JsonNotificationResult.Queued("Series rename"); return JsonNotificationResult.Queued("Series rename");
} }
public JsonResult RenameAllSeries()
{
_jobProvider.QueueJob(typeof(RenameSeriesJob));
return JsonNotificationResult.Queued("Series rename");
}
} }
} }

@ -72,7 +72,7 @@
<li><a class="editButton" value="@Model.SeriesId" rel="@Model.Title" title="Edit series">Edit</a></li> <li><a class="editButton" value="@Model.SeriesId" rel="@Model.Title" title="Edit series">Edit</a></li>
<li>@Ajax.ActionLink("Force Refresh", "ForceRefresh", "Command", new { seriesId = Model.SeriesId }, null, new { Title = "Refresh episode and series information and scan for new episodes" })</li> <li>@Ajax.ActionLink("Force Refresh", "ForceRefresh", "Command", new { seriesId = Model.SeriesId }, null, new { Title = "Refresh episode and series information and scan for new episodes" })</li>
<li>@Ajax.ActionLink("Search for missing episodes", "BacklogSeries", "Episode", new { seriesId = Model.SeriesId }, null, new { Title = "Search for episodes missing from this series" })</li> <li>@Ajax.ActionLink("Search for missing episodes", "BacklogSeries", "Episode", new { seriesId = Model.SeriesId }, null, new { Title = "Search for episodes missing from this series" })</li>
<li>@Ajax.ActionLink("Rename Episode Files", "RenameEpisodes", "Episode", new { seriesId = Model.SeriesId }, null, new { Title = "Rename all episode files to match your preferred naming" })</li> <li>@Ajax.ActionLink("Rename Episode Files", "RenameSeries", "Episode", new { seriesId = Model.SeriesId }, null, new { Title = "Rename all episode files to match your preferred naming" })</li>
</ul> </ul>
} }

@ -58,6 +58,7 @@
{ {
<ul class="sub-menu"> <ul class="sub-menu">
<li>@Ajax.ActionLink("Force Refresh", "ForceRefreshAll", "Command", null, null, new { Title = "Refresh episode and series information and scan for new episodes for all series" })</li> <li>@Ajax.ActionLink("Force Refresh", "ForceRefreshAll", "Command", null, null, new { Title = "Refresh episode and series information and scan for new episodes for all series" })</li>
<li>@Ajax.ActionLink("Rename All Series", "RenameAllSeries", "Episode", null, new AjaxOptions { Confirm = "Are you sure you want to rename all series?" }, new { Title = "Rename all series monitored by NzbDrone" })</li>
</ul> </ul>
} }

Loading…
Cancel
Save