Merge branch 'develop'
This commit is contained in:
commit
a832e7a0ad
|
@ -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; }
|
||||||
|
|
|
@ -4,7 +4,6 @@ using System.Linq;
|
||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
using FluentValidation.Results;
|
using FluentValidation.Results;
|
||||||
using Nancy.Responses;
|
using Nancy.Responses;
|
||||||
using NzbDrone.Api.REST;
|
|
||||||
using NzbDrone.Core.Organizer;
|
using NzbDrone.Core.Organizer;
|
||||||
using Nancy.ModelBinding;
|
using Nancy.ModelBinding;
|
||||||
using NzbDrone.Api.Mapping;
|
using NzbDrone.Api.Mapping;
|
||||||
|
@ -39,6 +38,7 @@ namespace NzbDrone.Api.Config
|
||||||
SharedValidator.RuleFor(c => c.MultiEpisodeStyle).InclusiveBetween(0, 3);
|
SharedValidator.RuleFor(c => c.MultiEpisodeStyle).InclusiveBetween(0, 3);
|
||||||
SharedValidator.RuleFor(c => c.StandardEpisodeFormat).ValidEpisodeFormat();
|
SharedValidator.RuleFor(c => c.StandardEpisodeFormat).ValidEpisodeFormat();
|
||||||
SharedValidator.RuleFor(c => c.DailyEpisodeFormat).ValidDailyEpisodeFormat();
|
SharedValidator.RuleFor(c => c.DailyEpisodeFormat).ValidDailyEpisodeFormat();
|
||||||
|
SharedValidator.RuleFor(c => c.SeriesFolderFormat).ValidSeriesFolderFormat();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateNamingConfig(NamingConfigResource resource)
|
private void UpdateNamingConfig(NamingConfigResource resource)
|
||||||
|
|
|
@ -97,10 +97,8 @@ namespace NzbDrone.Core.Test.Datastore.SQLiteMigrationHelperTests
|
||||||
var columns = _subject.GetColumns("QualitySizes");
|
var columns = _subject.GetColumns("QualitySizes");
|
||||||
var indexes = _subject.GetIndexes("QualitySizes");
|
var indexes = _subject.GetIndexes("QualitySizes");
|
||||||
|
|
||||||
|
|
||||||
_subject.CreateTable("QualityB", columns.Values, indexes);
|
_subject.CreateTable("QualityB", columns.Values, indexes);
|
||||||
|
|
||||||
|
|
||||||
var newIndexes = _subject.GetIndexes("QualityB");
|
var newIndexes = _subject.GetIndexes("QualityB");
|
||||||
|
|
||||||
newIndexes.Should().HaveSameCount(indexes);
|
newIndexes.Should().HaveSameCount(indexes);
|
||||||
|
@ -122,6 +120,5 @@ namespace NzbDrone.Core.Test.Datastore.SQLiteMigrationHelperTests
|
||||||
newColumns.Values.Should().HaveSameCount(columns.Values);
|
newColumns.Values.Should().HaveSameCount(columns.Values);
|
||||||
newIndexes.Should().Contain(i=>i.Column == "AirTime");
|
newIndexes.Should().Contain(i=>i.Column == "AirTime");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,258 +0,0 @@
|
||||||
/*
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using FizzWare.NBuilder;
|
|
||||||
using FluentAssertions;
|
|
||||||
using NUnit.Framework;
|
|
||||||
using NzbDrone.Core.Parser.Model;
|
|
||||||
using NzbDrone.Core.Qualities;
|
|
||||||
using NzbDrone.Core.Tv;
|
|
||||||
using NzbDrone.Core.Model;
|
|
||||||
using NzbDrone.Core.Test.Framework;
|
|
||||||
|
|
||||||
namespace NzbDrone.Core.Test
|
|
||||||
{
|
|
||||||
[TestFixture]
|
|
||||||
|
|
||||||
public class EpisodeParseResultTest : CoreTest
|
|
||||||
{
|
|
||||||
[Test]
|
|
||||||
public void tostring_single_season_episode()
|
|
||||||
{
|
|
||||||
var parseResult = new RemoteEpisode();
|
|
||||||
parseResult.SeriesTitle = "My Series";
|
|
||||||
parseResult.SeasonNumber = 12;
|
|
||||||
parseResult.EpisodeNumbers = new List<int> { 3 };
|
|
||||||
parseResult.FullSeason = false;
|
|
||||||
parseResult.AirDate = null;
|
|
||||||
parseResult.Quality = new QualityModel(Quality.HDTV720p, false);
|
|
||||||
|
|
||||||
|
|
||||||
parseResult.ToString().Should().Be("My Series - S12E03 HDTV-720p");
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void tostring_single_season_episode_proper()
|
|
||||||
{
|
|
||||||
var parseResult = new RemoteEpisode();
|
|
||||||
parseResult.SeriesTitle = "My Series";
|
|
||||||
parseResult.SeasonNumber = 12;
|
|
||||||
parseResult.EpisodeNumbers = new List<int> { 3 };
|
|
||||||
parseResult.FullSeason = false;
|
|
||||||
parseResult.AirDate = null;
|
|
||||||
parseResult.Quality = new QualityModel(Quality.HDTV720p, true);
|
|
||||||
|
|
||||||
|
|
||||||
parseResult.ToString().Should().Be("My Series - S12E03 HDTV-720p [proper]");
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void tostring_multi_season_episode()
|
|
||||||
{
|
|
||||||
var parseResult = new RemoteEpisode();
|
|
||||||
parseResult.SeriesTitle = "My Series";
|
|
||||||
parseResult.SeasonNumber = 12;
|
|
||||||
parseResult.EpisodeNumbers = new List<int> { 3, 4, 5 };
|
|
||||||
parseResult.FullSeason = false;
|
|
||||||
parseResult.AirDate = null;
|
|
||||||
parseResult.Quality = new QualityModel(Quality.HDTV720p, false);
|
|
||||||
|
|
||||||
|
|
||||||
parseResult.ToString().Should().Be("My Series - S12E03-04-05 HDTV-720p");
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void tostring_multi_season_episode_proper()
|
|
||||||
{
|
|
||||||
var parseResult = new RemoteEpisode();
|
|
||||||
parseResult.SeriesTitle = "My Series";
|
|
||||||
parseResult.SeasonNumber = 12;
|
|
||||||
parseResult.EpisodeNumbers = new List<int> { 3, 4, 5 };
|
|
||||||
parseResult.FullSeason = false;
|
|
||||||
parseResult.AirDate = null;
|
|
||||||
parseResult.Quality = new QualityModel(Quality.HDTV720p, true);
|
|
||||||
|
|
||||||
|
|
||||||
parseResult.ToString().Should().Be("My Series - S12E03-04-05 HDTV-720p [proper]");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void tostring_full_season()
|
|
||||||
{
|
|
||||||
var parseResult = new RemoteEpisode();
|
|
||||||
parseResult.SeriesTitle = "My Series";
|
|
||||||
parseResult.SeasonNumber = 12;
|
|
||||||
parseResult.FullSeason = true;
|
|
||||||
parseResult.AirDate = null;
|
|
||||||
parseResult.Quality = new QualityModel(Quality.HDTV720p, false);
|
|
||||||
|
|
||||||
|
|
||||||
parseResult.ToString().Should().Be("My Series - Season 12 HDTV-720p");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void tostring_full_season_proper()
|
|
||||||
{
|
|
||||||
var parseResult = new RemoteEpisode();
|
|
||||||
parseResult.SeriesTitle = "My Series";
|
|
||||||
parseResult.SeasonNumber = 12;
|
|
||||||
parseResult.FullSeason = true;
|
|
||||||
parseResult.AirDate = null;
|
|
||||||
parseResult.Quality = new QualityModel(Quality.HDTV720p, true);
|
|
||||||
|
|
||||||
|
|
||||||
parseResult.ToString().Should().Be("My Series - Season 12 HDTV-720p [proper]");
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void tostring_daily_show()
|
|
||||||
{
|
|
||||||
var parseResult = new RemoteEpisode();
|
|
||||||
parseResult.SeriesTitle = "My Series";
|
|
||||||
parseResult.SeasonNumber = 12;
|
|
||||||
parseResult.FullSeason = true;
|
|
||||||
parseResult.AirDate = new DateTime(2010, 12, 30);
|
|
||||||
parseResult.Quality = new QualityModel(Quality.HDTV720p, false);
|
|
||||||
|
|
||||||
|
|
||||||
parseResult.ToString().Should().Be("My Series - 2010-12-30 HDTV-720p");
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void tostring_daily_show_proper()
|
|
||||||
{
|
|
||||||
var parseResult = new RemoteEpisode();
|
|
||||||
parseResult.SeriesTitle = "My Series";
|
|
||||||
parseResult.SeasonNumber = 12;
|
|
||||||
parseResult.FullSeason = true;
|
|
||||||
parseResult.AirDate = new DateTime(2010, 12, 30);
|
|
||||||
parseResult.Quality = new QualityModel(Quality.HDTV720p, true);
|
|
||||||
|
|
||||||
|
|
||||||
parseResult.ToString().Should().Be("My Series - 2010-12-30 HDTV-720p [proper]");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static readonly object[] SabNamingCases =
|
|
||||||
{
|
|
||||||
new object[] { 1, new[] { 2 }, "My Episode Title", Quality.DVD, false, "My Series Name - 1x02 - My Episode Title [DVD]" },
|
|
||||||
new object[] { 1, new[] { 2 }, "My Episode Title", Quality.DVD, true, "My Series Name - 1x02 - My Episode Title [DVD] [Proper]" },
|
|
||||||
new object[] { 1, new[] { 2 }, "", Quality.DVD, true, "My Series Name - 1x02 - [DVD] [Proper]" },
|
|
||||||
new object[] { 1, new[] { 2, 4 }, "My Episode Title", Quality.HDTV720p, false, "My Series Name - 1x02-1x04 - My Episode Title [HDTV-720p]" },
|
|
||||||
new object[] { 1, new[] { 2, 4 }, "My Episode Title", Quality.HDTV720p, true, "My Series Name - 1x02-1x04 - My Episode Title [HDTV-720p] [Proper]" },
|
|
||||||
new object[] { 1, new[] { 2, 4 }, "", Quality.HDTV720p, true, "My Series Name - 1x02-1x04 - [HDTV-720p] [Proper]" },
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
[Test, TestCaseSource("SabNamingCases")]
|
|
||||||
public void create_proper_sab_titles(int seasons, int[] episodes, string title, Quality quality, bool proper, string expected)
|
|
||||||
{
|
|
||||||
var series = Builder<Series>.CreateNew()
|
|
||||||
.With(c => c.Title = "My Series Name")
|
|
||||||
.Build();
|
|
||||||
|
|
||||||
var fakeEpisodes = new List<Episode>();
|
|
||||||
|
|
||||||
foreach (var episode in episodes)
|
|
||||||
fakeEpisodes.Add(Builder<Episode>
|
|
||||||
.CreateNew()
|
|
||||||
.With(e => e.EpisodeNumber = episode)
|
|
||||||
.With(e => e.Title = title)
|
|
||||||
.Build());
|
|
||||||
|
|
||||||
var parsResult = new RemoteEpisode()
|
|
||||||
{
|
|
||||||
AirDate = DateTime.Now,
|
|
||||||
EpisodeNumbers = episodes.ToList(),
|
|
||||||
Quality = new QualityModel(quality, proper),
|
|
||||||
SeasonNumber = seasons,
|
|
||||||
Series = series,
|
|
||||||
EpisodeTitle = title,
|
|
||||||
Episodes = fakeEpisodes
|
|
||||||
};
|
|
||||||
|
|
||||||
parsResult.GetDownloadTitle().Should().Be(expected);
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestCase(true, Result = "My Series Name - Season 1 [Bluray720p] [Proper]")]
|
|
||||||
[TestCase(false, Result = "My Series Name - Season 1 [Bluray720p]")]
|
|
||||||
public string create_proper_sab_season_title(bool proper)
|
|
||||||
{
|
|
||||||
var series = Builder<Series>.CreateNew()
|
|
||||||
.With(c => c.Title = "My Series Name")
|
|
||||||
.Build();
|
|
||||||
|
|
||||||
var parsResult = new RemoteEpisode()
|
|
||||||
{
|
|
||||||
AirDate = DateTime.Now,
|
|
||||||
Quality = new QualityModel(Quality.Bluray720p, proper),
|
|
||||||
SeasonNumber = 1,
|
|
||||||
Series = series,
|
|
||||||
EpisodeTitle = "My Episode Title",
|
|
||||||
FullSeason = true
|
|
||||||
};
|
|
||||||
|
|
||||||
return parsResult.GetDownloadTitle();
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestCase(true, Result = "My Series Name - 2011-12-01 - My Episode Title [Bluray720p] [Proper]")]
|
|
||||||
[TestCase(false, Result = "My Series Name - 2011-12-01 - My Episode Title [Bluray720p]")]
|
|
||||||
public string create_proper_sab_daily_titles(bool proper)
|
|
||||||
{
|
|
||||||
var series = Builder<Series>.CreateNew()
|
|
||||||
.With(c => c.SeriesType = SeriesTypes.Daily)
|
|
||||||
.With(c => c.Title = "My Series Name")
|
|
||||||
.Build();
|
|
||||||
|
|
||||||
var episode = Builder<Episode>.CreateNew()
|
|
||||||
.With(e => e.Title = "My Episode Title")
|
|
||||||
.Build();
|
|
||||||
|
|
||||||
var parsResult = new RemoteEpisode
|
|
||||||
{
|
|
||||||
AirDate = new DateTime(2011, 12, 1),
|
|
||||||
Quality = new QualityModel(Quality.Bluray720p, proper),
|
|
||||||
Series = series,
|
|
||||||
EpisodeTitle = "My Episode Title",
|
|
||||||
Episodes = new List<Episode> { episode }
|
|
||||||
};
|
|
||||||
|
|
||||||
return parsResult.GetDownloadTitle();
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void should_not_repeat_the_same_episode_title()
|
|
||||||
{
|
|
||||||
var series = Builder<Series>.CreateNew()
|
|
||||||
.With(c => c.Title = "My Series Name")
|
|
||||||
.Build();
|
|
||||||
|
|
||||||
var fakeEpisodes = Builder<Episode>.CreateListOfSize(2)
|
|
||||||
.All()
|
|
||||||
.With(e => e.SeasonNumber = 5)
|
|
||||||
.TheFirst(1)
|
|
||||||
.With(e => e.Title = "My Episode Title (1)")
|
|
||||||
.TheLast(1)
|
|
||||||
.With(e => e.Title = "My Episode Title (2)")
|
|
||||||
.Build();
|
|
||||||
|
|
||||||
var parsResult = new RemoteEpisode
|
|
||||||
{
|
|
||||||
AirDate = DateTime.Now,
|
|
||||||
EpisodeNumbers = new List<int> { 10, 11 },
|
|
||||||
Quality = new QualityModel(Quality.HDTV720p, false),
|
|
||||||
SeasonNumber = 35,
|
|
||||||
Series = series,
|
|
||||||
Episodes = fakeEpisodes
|
|
||||||
};
|
|
||||||
|
|
||||||
parsResult.GetDownloadTitle().Should().Be("My Series Name - 5x01-5x02 - My Episode Title [HDTV-720p]");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
|
@ -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" />
|
||||||
|
@ -185,7 +186,6 @@
|
||||||
<Compile Include="Qualities\QualityProfileRepositoryFixture.cs" />
|
<Compile Include="Qualities\QualityProfileRepositoryFixture.cs" />
|
||||||
<Compile Include="RootFolderTests\FreeSpaceOnDrivesFixture.cs" />
|
<Compile Include="RootFolderTests\FreeSpaceOnDrivesFixture.cs" />
|
||||||
<Compile Include="Qualities\QualityFixture.cs" />
|
<Compile Include="Qualities\QualityFixture.cs" />
|
||||||
<Compile Include="EpisodeParseResultTest.cs" />
|
|
||||||
<Compile Include="ParserTests\QualityParserFixture.cs" />
|
<Compile Include="ParserTests\QualityParserFixture.cs" />
|
||||||
<Compile Include="Configuration\ConfigCachingFixture.cs" />
|
<Compile Include="Configuration\ConfigCachingFixture.cs" />
|
||||||
<Compile Include="ProviderTests\DiskScanProviderTests\GetVideoFilesFixture.cs" />
|
<Compile Include="ProviderTests\DiskScanProviderTests\GetVideoFilesFixture.cs" />
|
||||||
|
|
|
@ -353,5 +353,18 @@ namespace NzbDrone.Core.Test.OrganizerTests
|
||||||
Subject.BuildFilename(new List<Episode> { _episode1 }, _series, _episodeFile)
|
Subject.BuildFilename(new List<Episode> { _episode1 }, _series, _episodeFile)
|
||||||
.Should().Be(_episodeFile.ReleaseGroup);
|
.Should().Be(_episodeFile.ReleaseGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_be_able_to_use_orginal_title()
|
||||||
|
{
|
||||||
|
_series.Title = "30 Rock";
|
||||||
|
_namingConfig.StandardEpisodeFormat = "{Series Title} - {Original Title}";
|
||||||
|
|
||||||
|
_episodeFile.SceneName = "30.Rock.S01E01.xvid-LOL";
|
||||||
|
_episodeFile.Path = @"C:\Test\TV\30 Rock - S01E01 - Test";
|
||||||
|
|
||||||
|
Subject.BuildFilename(new List<Episode> { _episode1 }, _series, _episodeFile)
|
||||||
|
.Should().Be("30 Rock - 30.Rock.S01E01.xvid-LOL");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
|
@ -0,0 +1,14 @@
|
||||||
|
using FluentMigrator;
|
||||||
|
using NzbDrone.Core.Datastore.Migration.Framework;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Datastore.Migration
|
||||||
|
{
|
||||||
|
[Migration(34)]
|
||||||
|
public class remove_series_contraints : NzbDroneMigrationBase
|
||||||
|
{
|
||||||
|
protected override void MainDbUpgrade()
|
||||||
|
{
|
||||||
|
SqLiteAlter.Nullify("Series", new[] { "ImdbId", "TitleSlug" });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -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}'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,5 @@
|
||||||
using System.Collections.Generic;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Datastore.Migration.Framework
|
namespace NzbDrone.Core.Datastore.Migration.Framework
|
||||||
|
@ -7,6 +8,7 @@ namespace NzbDrone.Core.Datastore.Migration.Framework
|
||||||
{
|
{
|
||||||
void DropColumns(string tableName, IEnumerable<string> columns);
|
void DropColumns(string tableName, IEnumerable<string> columns);
|
||||||
void AddIndexes(string tableName, params SQLiteIndex[] indexes);
|
void AddIndexes(string tableName, params SQLiteIndex[] indexes);
|
||||||
|
void Nullify(string tableName, IEnumerable<string> columns);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SQLiteAlter : ISQLiteAlter
|
public class SQLiteAlter : ISQLiteAlter
|
||||||
|
@ -50,6 +52,44 @@ namespace NzbDrone.Core.Datastore.Migration.Framework
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Nullify(string tableName, IEnumerable<string> columns)
|
||||||
|
{
|
||||||
|
using (var transaction = _sqLiteMigrationHelper.BeginTransaction())
|
||||||
|
{
|
||||||
|
var originalColumns = _sqLiteMigrationHelper.GetColumns(tableName);
|
||||||
|
var originalIndexes = _sqLiteMigrationHelper.GetIndexes(tableName);
|
||||||
|
|
||||||
|
var newColumns = originalColumns.Select(c =>
|
||||||
|
{
|
||||||
|
if (!columns.Contains(c.Key))
|
||||||
|
{
|
||||||
|
return c.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!c.Value.Schema.Contains("NOT NULL") && c.Value.Schema.Contains("NULL"))
|
||||||
|
{
|
||||||
|
return c.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (c.Value.Schema.Contains("NOT NULL"))
|
||||||
|
{
|
||||||
|
c.Value.Schema = c.Value.Schema.Replace("NOT NULL", "NULL");
|
||||||
|
return c.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
c.Value.Schema += " NULL";
|
||||||
|
|
||||||
|
return c.Value;
|
||||||
|
}).ToList();
|
||||||
|
|
||||||
|
var newIndexes = originalIndexes;
|
||||||
|
|
||||||
|
CreateTable(tableName, newColumns, newIndexes);
|
||||||
|
|
||||||
|
transaction.Commit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void CreateTable(string tableName, List<SQLiteColumn> newColumns, IEnumerable<SQLiteIndex> newIndexes)
|
private void CreateTable(string tableName, List<SQLiteColumn> newColumns, IEnumerable<SQLiteIndex> newIndexes)
|
||||||
{
|
{
|
||||||
var tempTableName = tableName + "_temp";
|
var tempTableName = tableName + "_temp";
|
||||||
|
|
|
@ -41,6 +41,8 @@ namespace NzbDrone.Core.MediaFiles
|
||||||
var episodes = _episodeService.GetEpisodesByFileId(episodeFile.Id);
|
var episodes = _episodeService.GetEpisodesByFileId(episodeFile.Id);
|
||||||
var newFileName = _buildFileNames.BuildFilename(episodes, series, episodeFile);
|
var newFileName = _buildFileNames.BuildFilename(episodes, series, episodeFile);
|
||||||
var filePath = _buildFileNames.BuildFilePath(series, episodes.First().SeasonNumber, newFileName, Path.GetExtension(episodeFile.Path));
|
var filePath = _buildFileNames.BuildFilePath(series, episodes.First().SeasonNumber, newFileName, Path.GetExtension(episodeFile.Path));
|
||||||
|
|
||||||
|
_logger.Trace("Renaming episode file: {0} to {1}", episodeFile, filePath);
|
||||||
MoveFile(episodeFile, series, filePath);
|
MoveFile(episodeFile, series, filePath);
|
||||||
|
|
||||||
return filePath;
|
return filePath;
|
||||||
|
@ -50,6 +52,8 @@ namespace NzbDrone.Core.MediaFiles
|
||||||
{
|
{
|
||||||
var newFileName = _buildFileNames.BuildFilename(localEpisode.Episodes, localEpisode.Series, episodeFile);
|
var newFileName = _buildFileNames.BuildFilename(localEpisode.Episodes, localEpisode.Series, episodeFile);
|
||||||
var filePath = _buildFileNames.BuildFilePath(localEpisode.Series, localEpisode.SeasonNumber, newFileName, Path.GetExtension(episodeFile.Path));
|
var filePath = _buildFileNames.BuildFilePath(localEpisode.Series, localEpisode.SeasonNumber, newFileName, Path.GetExtension(episodeFile.Path));
|
||||||
|
|
||||||
|
_logger.Trace("Moving episode file: {0} to {1}", episodeFile, filePath);
|
||||||
MoveFile(episodeFile, localEpisode.Series, filePath);
|
MoveFile(episodeFile, localEpisode.Series, filePath);
|
||||||
|
|
||||||
return filePath;
|
return filePath;
|
||||||
|
|
|
@ -53,7 +53,6 @@ namespace NzbDrone.Core.MediaFiles
|
||||||
_mediaFileService.Delete(file, true);
|
_mediaFileService.Delete(file, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.Trace("Moving episode file: {0}", episodeFile);
|
|
||||||
moveFileResult.Path = _episodeFileMover.MoveEpisodeFile(episodeFile, localEpisode);
|
moveFileResult.Path = _episodeFileMover.MoveEpisodeFile(episodeFile, localEpisode);
|
||||||
|
|
||||||
return moveFileResult;
|
return moveFileResult;
|
||||||
|
|
|
@ -189,6 +189,8 @@
|
||||||
<Compile Include="Datastore\Migration\030_add_season_folder_format_to_naming_config.cs" />
|
<Compile Include="Datastore\Migration\030_add_season_folder_format_to_naming_config.cs" />
|
||||||
<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\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" />
|
||||||
|
|
|
@ -5,7 +5,6 @@ using System.Linq;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using NLog;
|
using NLog;
|
||||||
using NzbDrone.Common.Cache;
|
using NzbDrone.Common.Cache;
|
||||||
using NzbDrone.Core.Configuration;
|
|
||||||
using NzbDrone.Core.MediaFiles;
|
using NzbDrone.Core.MediaFiles;
|
||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Tv;
|
||||||
|
|
||||||
|
@ -17,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
|
||||||
|
@ -39,6 +39,9 @@ namespace NzbDrone.Core.Organizer
|
||||||
|
|
||||||
public static readonly Regex AirDateRegex = new Regex(@"\{Air(\s|\W|_)Date\}", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
public static readonly Regex AirDateRegex = new Regex(@"\{Air(\s|\W|_)Date\}", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||||
|
|
||||||
|
public static readonly Regex SeriesTitleRegex = new Regex(@"(?<token>\{(?:Series)(?<separator>\s|\.|-|_)Title\})",
|
||||||
|
RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||||
|
|
||||||
public FileNameBuilder(INamingConfigService namingConfigService,
|
public FileNameBuilder(INamingConfigService namingConfigService,
|
||||||
ICacheManger cacheManger,
|
ICacheManger cacheManger,
|
||||||
Logger logger)
|
Logger logger)
|
||||||
|
@ -86,7 +89,8 @@ namespace NzbDrone.Core.Organizer
|
||||||
|
|
||||||
var tokenValues = new Dictionary<string, string>(FilenameBuilderTokenEqualityComparer.Instance)
|
var tokenValues = new Dictionary<string, string>(FilenameBuilderTokenEqualityComparer.Instance)
|
||||||
{
|
{
|
||||||
{"{Series Title}", series.Title}
|
{"{Series Title}", series.Title},
|
||||||
|
{"Original Title", episodeFile.SceneName}
|
||||||
};
|
};
|
||||||
|
|
||||||
tokenValues.Add("{Release Group}", episodeFile.ReleaseGroup);
|
tokenValues.Add("{Release Group}", episodeFile.ReleaseGroup);
|
||||||
|
@ -151,6 +155,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 +227,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;
|
||||||
|
|
|
@ -17,6 +17,12 @@ namespace NzbDrone.Core.Organizer
|
||||||
ruleBuilder.SetValidator(new NotEmptyValidator(null));
|
ruleBuilder.SetValidator(new NotEmptyValidator(null));
|
||||||
return ruleBuilder.SetValidator(new ValidDailyEpisodeFormatValidator());
|
return ruleBuilder.SetValidator(new ValidDailyEpisodeFormatValidator());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static IRuleBuilderOptions<T, string> ValidSeriesFolderFormat<T>(this IRuleBuilder<T, string> ruleBuilder)
|
||||||
|
{
|
||||||
|
ruleBuilder.SetValidator(new NotEmptyValidator(null));
|
||||||
|
return ruleBuilder.SetValidator(new RegularExpressionValidator(FileNameBuilder.SeriesTitleRegex)).WithMessage("Must contain series title");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ValidDailyEpisodeFormatValidator : PropertyValidator
|
public class ValidDailyEpisodeFormatValidator : PropertyValidator
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -96,5 +96,16 @@ namespace NzbDrone.Integration.Test
|
||||||
var errors = NamingConfig.InvalidPut(config);
|
var errors = NamingConfig.InvalidPut(config);
|
||||||
errors.Should().NotBeEmpty();
|
errors.Should().NotBeEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_get_bad_request_if_series_folder_format_does_not_contain_series_title()
|
||||||
|
{
|
||||||
|
var config = NamingConfig.GetSingle();
|
||||||
|
config.RenameEpisodes = true;
|
||||||
|
config.SeriesFolderFormat = "This and That";
|
||||||
|
|
||||||
|
var errors = NamingConfig.InvalidPut(config);
|
||||||
|
errors.Should().NotBeEmpty();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -21,6 +21,12 @@
|
||||||
margin-bottom : 0;
|
margin-bottom : 0;
|
||||||
vertical-align : middle;
|
vertical-align : middle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.btn {
|
||||||
|
i {
|
||||||
|
margin-right: 0px;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
{{> EpisodeTitleNamingPartial}}
|
{{> EpisodeTitleNamingPartial}}
|
||||||
{{> QualityTitleNamingPartial}}
|
{{> QualityTitleNamingPartial}}
|
||||||
{{> ReleaseGroupNamingPartial}}
|
{{> ReleaseGroupNamingPartial}}
|
||||||
|
{{> OriginalTitleNamingPartial}}
|
||||||
{{> SeparatorNamingPartial}}
|
{{> SeparatorNamingPartial}}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
@ -71,6 +72,7 @@
|
||||||
{{> EpisodeTitleNamingPartial}}
|
{{> EpisodeTitleNamingPartial}}
|
||||||
{{> QualityTitleNamingPartial}}
|
{{> QualityTitleNamingPartial}}
|
||||||
{{> ReleaseGroupNamingPartial}}
|
{{> ReleaseGroupNamingPartial}}
|
||||||
|
{{> OriginalTitleNamingPartial}}
|
||||||
{{> SeparatorNamingPartial}}
|
{{> SeparatorNamingPartial}}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
@ -96,6 +98,27 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="control-group advanced-setting">
|
||||||
|
<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>
|
||||||
|
<span class="help-inline">
|
||||||
|
<i class="icon-nd-form-info" title="" data-original-title="All caps or all lower-case can also be used. Only used when adding a new series."></i>
|
||||||
|
</span>
|
||||||
|
</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>
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
<li><a href="#" data-token="Original Title">Original Title</a></li>
|
Loading…
Reference in New Issue