1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-10 04:52:42 +01:00

New: Examples for Series and Season folder format

This commit is contained in:
Mark McDowall 2014-04-15 07:16:49 -07:00
parent 5bc820efed
commit dade3bb214
6 changed files with 60 additions and 13 deletions

View File

@ -92,6 +92,9 @@ private JsonResponse<NamingSampleResource> GetExamples(NamingConfigResource conf
? "Invalid format"
: dailyEpisodeSampleResult.Filename;
sampleResource.SeriesFolderExample = _filenameSampleService.GetSeriesFolderSample(nameSpec);
sampleResource.SeasonFolderExample = _filenameSampleService.GetSeasonFolderSample(nameSpec);
return sampleResource.AsResponse();
}

View File

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

View File

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

View File

@ -1,9 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Tv;
@ -14,6 +11,8 @@ public interface IFilenameSampleService
SampleResult GetStandardSample(NamingConfig nameSpec);
SampleResult GetMultiEpisodeSample(NamingConfig nameSpec);
SampleResult GetDailySample(NamingConfig nameSpec);
String GetSeriesFolderSample(NamingConfig nameSpec);
String GetSeasonFolderSample(NamingConfig nameSpec);
}
public class FilenameSampleService : IFilenameSampleService
@ -123,6 +122,16 @@ public SampleResult GetDailySample(NamingConfig nameSpec)
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)
{
try

View File

@ -19,7 +19,9 @@ define(
multiEpisodeExample : '.x-multi-episode-example',
dailyEpisodeExample : '.x-daily-episode-example',
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: {
@ -66,6 +68,8 @@ define(
this.ui.singleEpisodeExample.html(this.namingSampleModel.get('singleEpisodeExample'));
this.ui.multiEpisodeExample.html(this.namingSampleModel.get('multiEpisodeExample'));
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) {

View File

@ -103,7 +103,7 @@
<div class="controls">
<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">
<button class="btn btn-icon-only dropdown-toggle" data-toggle="dropdown">
<i class="icon-plus"></i>
@ -124,7 +124,7 @@
<div class="controls">
<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">
<button class="btn btn-icon-only dropdown-toggle" data-toggle="dropdown">
<i class="icon-plus"></i>
@ -162,4 +162,20 @@
<span class="x-daily-episode-example naming-example"></span>
</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>