New: Series Folder format now configurable (used when adding series only)
This commit is contained in:
parent
7c6605c02b
commit
b5b9fababb
|
@ -9,8 +9,8 @@ namespace NzbDrone.Api.Config
|
||||||
public Int32 MultiEpisodeStyle { get; set; }
|
public Int32 MultiEpisodeStyle { get; set; }
|
||||||
public string StandardEpisodeFormat { get; set; }
|
public string StandardEpisodeFormat { get; set; }
|
||||||
public string DailyEpisodeFormat { get; set; }
|
public string DailyEpisodeFormat { get; set; }
|
||||||
|
public string SeriesFolderFormat { get; set; }
|
||||||
public string SeasonFolderFormat { get; set; }
|
public string SeasonFolderFormat { get; set; }
|
||||||
|
|
||||||
public bool IncludeSeriesTitle { get; set; }
|
public bool IncludeSeriesTitle { get; set; }
|
||||||
public bool IncludeEpisodeTitle { get; set; }
|
public bool IncludeEpisodeTitle { get; set; }
|
||||||
public bool IncludeQuality { get; set; }
|
public bool IncludeQuality { get; set; }
|
||||||
|
|
|
@ -176,6 +176,7 @@
|
||||||
<Compile Include="NotificationTests\Xbmc\Json\UpdateFixture.cs" />
|
<Compile Include="NotificationTests\Xbmc\Json\UpdateFixture.cs" />
|
||||||
<Compile Include="NotificationTests\Xbmc\OnDownloadFixture.cs" />
|
<Compile Include="NotificationTests\Xbmc\OnDownloadFixture.cs" />
|
||||||
<Compile Include="OrganizerTests\BuildFilePathFixture.cs" />
|
<Compile Include="OrganizerTests\BuildFilePathFixture.cs" />
|
||||||
|
<Compile Include="OrganizerTests\GetSeriesFolderFixture.cs" />
|
||||||
<Compile Include="ParserTests\ParsingServiceTests\GetEpisodesFixture.cs" />
|
<Compile Include="ParserTests\ParsingServiceTests\GetEpisodesFixture.cs" />
|
||||||
<Compile Include="ParserTests\ParsingServiceTests\GetSeriesFixture.cs" />
|
<Compile Include="ParserTests\ParsingServiceTests\GetSeriesFixture.cs" />
|
||||||
<Compile Include="ParserTests\ParsingServiceTests\MapFixture.cs" />
|
<Compile Include="ParserTests\ParsingServiceTests\MapFixture.cs" />
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
using FluentAssertions;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using NzbDrone.Core.Organizer;
|
||||||
|
using NzbDrone.Core.Test.Framework;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Test.OrganizerTests
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
|
||||||
|
public class GetSeriesFolderFixture : CoreTest<FileNameBuilder>
|
||||||
|
{
|
||||||
|
private NamingConfig namingConfig;
|
||||||
|
|
||||||
|
[SetUp]
|
||||||
|
public void Setup()
|
||||||
|
{
|
||||||
|
namingConfig = new NamingConfig();
|
||||||
|
|
||||||
|
Mocker.GetMock<INamingConfigService>()
|
||||||
|
.Setup(c => c.GetConfig()).Returns(namingConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestCase("30 Rock", "{Series Title}", "30 Rock")]
|
||||||
|
[TestCase("30 Rock", "{Series.Title}", "30.Rock")]
|
||||||
|
[TestCase("24/7 Road to the NHL Winter Classic", "{Series Title}", "24+7 Road to the NHL Winter Classic")]
|
||||||
|
public void should_use_seriesFolderFormat_to_build_folder_name(string seriesTitle, string format, string expected)
|
||||||
|
{
|
||||||
|
namingConfig.SeriesFolderFormat = format;
|
||||||
|
|
||||||
|
Subject.GetSeriesFolder(seriesTitle).Should().Be(expected);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
using FluentMigrator;
|
||||||
|
using NzbDrone.Core.Datastore.Migration.Framework;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Datastore.Migration
|
||||||
|
{
|
||||||
|
[Migration(35)]
|
||||||
|
public class add_series_folder_format_to_naming_config : NzbDroneMigrationBase
|
||||||
|
{
|
||||||
|
protected override void MainDbUpgrade()
|
||||||
|
{
|
||||||
|
Alter.Table("NamingConfig").AddColumn("SeriesFolderFormat").AsString().Nullable();
|
||||||
|
|
||||||
|
Execute.Sql("UPDATE NamingConfig SET SeriesFolderFormat = '{Series Title}'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -190,6 +190,7 @@
|
||||||
<Compile Include="Datastore\Migration\032_set_default_release_group.cs" />
|
<Compile Include="Datastore\Migration\032_set_default_release_group.cs" />
|
||||||
<Compile Include="Datastore\Migration\033_add_api_key_to_pushover.cs" />
|
<Compile Include="Datastore\Migration\033_add_api_key_to_pushover.cs" />
|
||||||
<Compile Include="Datastore\Migration\034_remove_series_contraints.cs" />
|
<Compile Include="Datastore\Migration\034_remove_series_contraints.cs" />
|
||||||
|
<Compile Include="Datastore\Migration\035_add_series_folder_format_to_naming_config.cs" />
|
||||||
<Compile Include="Datastore\Migration\Framework\MigrationContext.cs" />
|
<Compile Include="Datastore\Migration\Framework\MigrationContext.cs" />
|
||||||
<Compile Include="Datastore\Migration\Framework\MigrationController.cs" />
|
<Compile Include="Datastore\Migration\Framework\MigrationController.cs" />
|
||||||
<Compile Include="Datastore\Migration\Framework\MigrationExtension.cs" />
|
<Compile Include="Datastore\Migration\Framework\MigrationExtension.cs" />
|
||||||
|
|
|
@ -16,6 +16,7 @@ namespace NzbDrone.Core.Organizer
|
||||||
string BuildFilename(IList<Episode> episodes, Series series, EpisodeFile episodeFile, NamingConfig namingConfig);
|
string BuildFilename(IList<Episode> episodes, Series series, EpisodeFile episodeFile, NamingConfig namingConfig);
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class FileNameBuilder : IBuildFileNames
|
public class FileNameBuilder : IBuildFileNames
|
||||||
|
@ -151,6 +152,7 @@ namespace NzbDrone.Core.Organizer
|
||||||
public string BuildFilePath(Series series, int seasonNumber, string fileName, string extension)
|
public string BuildFilePath(Series series, int seasonNumber, string fileName, string extension)
|
||||||
{
|
{
|
||||||
string path = series.Path;
|
string path = series.Path;
|
||||||
|
|
||||||
if (series.SeasonFolder)
|
if (series.SeasonFolder)
|
||||||
{
|
{
|
||||||
string seasonFolder;
|
string seasonFolder;
|
||||||
|
@ -222,6 +224,17 @@ namespace NzbDrone.Core.Organizer
|
||||||
return basicNamingConfig;
|
return basicNamingConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string GetSeriesFolder(string seriesTitle)
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
public static string CleanFilename(string name)
|
public static string CleanFilename(string name)
|
||||||
{
|
{
|
||||||
string result = name;
|
string result = name;
|
||||||
|
|
|
@ -14,6 +14,7 @@ namespace NzbDrone.Core.Organizer
|
||||||
MultiEpisodeStyle = 0,
|
MultiEpisodeStyle = 0,
|
||||||
StandardEpisodeFormat = "{Series Title} - S{season:00}E{episode:00} - {Episode Title} {Quality Title}",
|
StandardEpisodeFormat = "{Series Title} - S{season:00}E{episode:00} - {Episode Title} {Quality Title}",
|
||||||
DailyEpisodeFormat = "{Series Title} - {Air-Date} - {Episode Title} {Quality Title}",
|
DailyEpisodeFormat = "{Series Title} - {Air-Date} - {Episode Title} {Quality Title}",
|
||||||
|
SeriesFolderFormat = "{Series Title}",
|
||||||
SeasonFolderFormat = "Season {season}"
|
SeasonFolderFormat = "Season {season}"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -23,6 +24,7 @@ namespace NzbDrone.Core.Organizer
|
||||||
public int MultiEpisodeStyle { get; set; }
|
public int MultiEpisodeStyle { get; set; }
|
||||||
public string StandardEpisodeFormat { get; set; }
|
public string StandardEpisodeFormat { get; set; }
|
||||||
public string DailyEpisodeFormat { get; set; }
|
public string DailyEpisodeFormat { get; set; }
|
||||||
|
public string SeriesFolderFormat { get; set; }
|
||||||
public string SeasonFolderFormat { get; set; }
|
public string SeasonFolderFormat { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -31,24 +31,24 @@ namespace NzbDrone.Core.Tv
|
||||||
public class SeriesService : ISeriesService
|
public class SeriesService : ISeriesService
|
||||||
{
|
{
|
||||||
private readonly ISeriesRepository _seriesRepository;
|
private readonly ISeriesRepository _seriesRepository;
|
||||||
private readonly IConfigService _configService;
|
|
||||||
private readonly IEventAggregator _eventAggregator;
|
private readonly IEventAggregator _eventAggregator;
|
||||||
private readonly ISceneMappingService _sceneMappingService;
|
private readonly ISceneMappingService _sceneMappingService;
|
||||||
private readonly IEpisodeService _episodeService;
|
private readonly IEpisodeService _episodeService;
|
||||||
|
private readonly IBuildFileNames _fileNameBuilder;
|
||||||
private readonly Logger _logger;
|
private readonly Logger _logger;
|
||||||
|
|
||||||
public SeriesService(ISeriesRepository seriesRepository,
|
public SeriesService(ISeriesRepository seriesRepository,
|
||||||
IConfigService configServiceService,
|
|
||||||
IEventAggregator eventAggregator,
|
IEventAggregator eventAggregator,
|
||||||
ISceneMappingService sceneMappingService,
|
ISceneMappingService sceneMappingService,
|
||||||
IEpisodeService episodeService,
|
IEpisodeService episodeService,
|
||||||
|
IBuildFileNames fileNameBuilder,
|
||||||
Logger logger)
|
Logger logger)
|
||||||
{
|
{
|
||||||
_seriesRepository = seriesRepository;
|
_seriesRepository = seriesRepository;
|
||||||
_configService = configServiceService;
|
|
||||||
_eventAggregator = eventAggregator;
|
_eventAggregator = eventAggregator;
|
||||||
_sceneMappingService = sceneMappingService;
|
_sceneMappingService = sceneMappingService;
|
||||||
_episodeService = episodeService;
|
_episodeService = episodeService;
|
||||||
|
_fileNameBuilder = fileNameBuilder;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ namespace NzbDrone.Core.Tv
|
||||||
|
|
||||||
if (String.IsNullOrWhiteSpace(newSeries.Path))
|
if (String.IsNullOrWhiteSpace(newSeries.Path))
|
||||||
{
|
{
|
||||||
var folderName = FileNameBuilder.CleanFilename(newSeries.Title);
|
var folderName = _fileNameBuilder.GetSeriesFolder(newSeries.Title);
|
||||||
newSeries.Path = Path.Combine(newSeries.RootFolderPath, folderName);
|
newSeries.Path = Path.Combine(newSeries.RootFolderPath, folderName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -98,6 +98,24 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="control-group">
|
||||||
|
<label class="control-label">Series Folder Format</label>
|
||||||
|
|
||||||
|
<div class="controls">
|
||||||
|
<div class="input-append x-helper-input">
|
||||||
|
<input type="text" class="naming-format" name="seriesFolderFormat"/>
|
||||||
|
<div class="btn-group x-naming-token-helper">
|
||||||
|
<button class="btn btn-icon-only dropdown-toggle" data-toggle="dropdown">
|
||||||
|
<i class="icon-plus"></i>
|
||||||
|
</button>
|
||||||
|
<ul class="dropdown-menu">
|
||||||
|
{{> SeriesTitleNamingPartial}}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label">Season Folder Format</label>
|
<label class="control-label">Season Folder Format</label>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue