New: Examples for Series and Season folder format

pull/4/head
Mark McDowall 11 years ago
parent 5bc820efed
commit dade3bb214

@ -92,6 +92,9 @@ namespace NzbDrone.Api.Config
? "Invalid format" ? "Invalid format"
: dailyEpisodeSampleResult.Filename; : dailyEpisodeSampleResult.Filename;
sampleResource.SeriesFolderExample = _filenameSampleService.GetSeriesFolderSample(nameSpec);
sampleResource.SeasonFolderExample = _filenameSampleService.GetSeasonFolderSample(nameSpec);
return sampleResource.AsResponse(); return sampleResource.AsResponse();
} }

@ -5,5 +5,7 @@
public string SingleEpisodeExample { get; set; } public string SingleEpisodeExample { get; set; }
public string MultiEpisodeExample { get; set; } public string MultiEpisodeExample { get; set; }
public string DailyEpisodeExample { get; set; } public string DailyEpisodeExample { get; set; }
public string SeriesFolderExample { get; set; }
public string SeasonFolderExample { get; set; }
} }
} }

@ -18,6 +18,8 @@ namespace NzbDrone.Core.Organizer
string BuildFilePath(Series series, int seasonNumber, string fileName, string extension); string BuildFilePath(Series series, int seasonNumber, string fileName, string extension);
BasicNamingConfig GetBasicNamingConfig(NamingConfig nameSpec); BasicNamingConfig GetBasicNamingConfig(NamingConfig nameSpec);
string GetSeriesFolder(string seriesTitle); string GetSeriesFolder(string seriesTitle);
string GetSeriesFolder(string seriesTitle, NamingConfig namingConfig);
string GetSeasonFolder(string seriesTitle, int seasonNumber, NamingConfig namingConfig);
} }
public class FileNameBuilder : IBuildFileNames public class FileNameBuilder : IBuildFileNames
@ -171,11 +173,7 @@ namespace NzbDrone.Core.Organizer
else else
{ {
var nameSpec = _namingConfigService.GetConfig(); var nameSpec = _namingConfigService.GetConfig();
var tokenValues = new Dictionary<string, string>(FilenameBuilderTokenEqualityComparer.Instance); seasonFolder = GetSeasonFolder(series.Title, seasonNumber, nameSpec);
tokenValues.Add("{Series Title}", series.Title);
seasonFolder = ReplaceSeasonTokens(nameSpec.SeasonFolderFormat, seasonNumber);
seasonFolder = ReplaceTokens(seasonFolder, tokenValues);
} }
seasonFolder = CleanFilename(seasonFolder); seasonFolder = CleanFilename(seasonFolder);
@ -233,14 +231,29 @@ namespace NzbDrone.Core.Organizer
} }
public string GetSeriesFolder(string seriesTitle) public string GetSeriesFolder(string seriesTitle)
{
var namingConfig = _namingConfigService.GetConfig();
return GetSeriesFolder(seriesTitle, namingConfig);
}
public string GetSeriesFolder(string seriesTitle, NamingConfig namingConfig)
{ {
seriesTitle = CleanFilename(seriesTitle); seriesTitle = CleanFilename(seriesTitle);
var nameSpec = _namingConfigService.GetConfig();
var tokenValues = new Dictionary<string, string>(FilenameBuilderTokenEqualityComparer.Instance); var tokenValues = new Dictionary<string, string>(FilenameBuilderTokenEqualityComparer.Instance);
tokenValues.Add("{Series Title}", seriesTitle); tokenValues.Add("{Series Title}", seriesTitle);
return ReplaceTokens(nameSpec.SeriesFolderFormat, tokenValues); return ReplaceTokens(namingConfig.SeriesFolderFormat, tokenValues);
}
public string GetSeasonFolder(string seriesTitle, int seasonNumber, NamingConfig namingConfig)
{
var tokenValues = new Dictionary<string, string>(FilenameBuilderTokenEqualityComparer.Instance);
tokenValues.Add("{Series Title}", seriesTitle);
var seasonFolder = ReplaceSeasonTokens(namingConfig.SeasonFolderFormat, seasonNumber);
return ReplaceTokens(seasonFolder, tokenValues);
} }
public static string CleanFilename(string name) public static string CleanFilename(string name)

@ -1,9 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Text;
using NzbDrone.Core.MediaFiles; using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Qualities; using NzbDrone.Core.Qualities;
using NzbDrone.Core.Tv; using NzbDrone.Core.Tv;
@ -14,6 +11,8 @@ namespace NzbDrone.Core.Organizer
SampleResult GetStandardSample(NamingConfig nameSpec); SampleResult GetStandardSample(NamingConfig nameSpec);
SampleResult GetMultiEpisodeSample(NamingConfig nameSpec); SampleResult GetMultiEpisodeSample(NamingConfig nameSpec);
SampleResult GetDailySample(NamingConfig nameSpec); SampleResult GetDailySample(NamingConfig nameSpec);
String GetSeriesFolderSample(NamingConfig nameSpec);
String GetSeasonFolderSample(NamingConfig nameSpec);
} }
public class FilenameSampleService : IFilenameSampleService public class FilenameSampleService : IFilenameSampleService
@ -123,6 +122,16 @@ namespace NzbDrone.Core.Organizer
return result; return result;
} }
public string GetSeriesFolderSample(NamingConfig nameSpec)
{
return _buildFileNames.GetSeriesFolder(_standardSeries.Title, nameSpec);
}
public string GetSeasonFolderSample(NamingConfig nameSpec)
{
return _buildFileNames.GetSeasonFolder(_standardSeries.Title, _episode1.SeasonNumber, nameSpec);
}
private string BuildSample(List<Episode> episodes, Series series, EpisodeFile episodeFile, NamingConfig nameSpec) private string BuildSample(List<Episode> episodes, Series series, EpisodeFile episodeFile, NamingConfig nameSpec)
{ {
try try

@ -19,7 +19,9 @@ define(
multiEpisodeExample : '.x-multi-episode-example', multiEpisodeExample : '.x-multi-episode-example',
dailyEpisodeExample : '.x-daily-episode-example', dailyEpisodeExample : '.x-daily-episode-example',
namingTokenHelper : '.x-naming-token-helper', namingTokenHelper : '.x-naming-token-helper',
multiEpisodeStyle : '.x-multi-episode-style' multiEpisodeStyle : '.x-multi-episode-style',
seriesFolderExample : '.x-series-folder-example',
seasonFolderExample : '.x-season-folder-example'
}, },
events: { events: {
@ -66,6 +68,8 @@ define(
this.ui.singleEpisodeExample.html(this.namingSampleModel.get('singleEpisodeExample')); this.ui.singleEpisodeExample.html(this.namingSampleModel.get('singleEpisodeExample'));
this.ui.multiEpisodeExample.html(this.namingSampleModel.get('multiEpisodeExample')); this.ui.multiEpisodeExample.html(this.namingSampleModel.get('multiEpisodeExample'));
this.ui.dailyEpisodeExample.html(this.namingSampleModel.get('dailyEpisodeExample')); this.ui.dailyEpisodeExample.html(this.namingSampleModel.get('dailyEpisodeExample'));
this.ui.seriesFolderExample.html(this.namingSampleModel.get('seriesFolderExample'));
this.ui.seasonFolderExample.html(this.namingSampleModel.get('seasonFolderExample'));
}, },
_addToken: function (e) { _addToken: function (e) {

@ -103,7 +103,7 @@
<div class="controls"> <div class="controls">
<div class="input-append x-helper-input"> <div class="input-append x-helper-input">
<input type="text" class="naming-format" name="seriesFolderFormat"/> <input type="text" class="naming-format" name="seriesFolderFormat" data-onkeyup="true"/>
<div class="btn-group x-naming-token-helper"> <div class="btn-group x-naming-token-helper">
<button class="btn btn-icon-only dropdown-toggle" data-toggle="dropdown"> <button class="btn btn-icon-only dropdown-toggle" data-toggle="dropdown">
<i class="icon-plus"></i> <i class="icon-plus"></i>
@ -124,7 +124,7 @@
<div class="controls"> <div class="controls">
<div class="input-append x-helper-input"> <div class="input-append x-helper-input">
<input type="text" class="naming-format" name="seasonFolderFormat"/> <input type="text" class="naming-format" name="seasonFolderFormat" data-onkeyup="true"/>
<div class="btn-group x-naming-token-helper"> <div class="btn-group x-naming-token-helper">
<button class="btn btn-icon-only dropdown-toggle" data-toggle="dropdown"> <button class="btn btn-icon-only dropdown-toggle" data-toggle="dropdown">
<i class="icon-plus"></i> <i class="icon-plus"></i>
@ -162,4 +162,20 @@
<span class="x-daily-episode-example naming-example"></span> <span class="x-daily-episode-example naming-example"></span>
</div> </div>
</div> </div>
<div class="control-group">
<label class="control-label">Series Folder Example</label>
<div class="controls">
<span class="x-series-folder-example naming-example"></span>
</div>
</div>
<div class="control-group">
<label class="control-label">Season Folder Example</label>
<div class="controls">
<span class="x-season-folder-example naming-example"></span>
</div>
</div>
</fieldset> </fieldset>

Loading…
Cancel
Save