1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-14 11:23:42 +02:00

Allow scene name to be used for renaming

New: Added option to use scene name for episodefiles
This commit is contained in:
Mark McDowall 2012-08-03 00:01:34 -07:00
parent 38eeda8c37
commit bee6914062
15 changed files with 647 additions and 511 deletions

View File

@ -185,7 +185,6 @@ public void parsing_our_own_quality_enum()
{
var qualityEnums = Enum.GetValues(typeof(QualityTypes));
foreach (var qualityEnum in qualityEnums)
{
var fileName = String.Format("My series S01E01 [{0}]", qualityEnum);
@ -276,8 +275,6 @@ public void series_name_normalize(string parsedSeriesName, string seriesName)
result.Should().Be(seriesName);
}
[TestCase("CaPitAl", "capital")]
[TestCase("peri.od", "period")]
[TestCase("this.^&%^**$%@#$!That", "thisthat")]
@ -290,7 +287,6 @@ public void Normalize_Title(string dirty, string clean)
result.Should().Be(clean);
}
[TestCase("the")]
[TestCase("and")]
[TestCase("or")]
@ -360,7 +356,6 @@ public void parse_series_name(string postTitle, string title)
result.Should().Be(Parser.NormalizeTitle(title));
}
[TestCase("Castle.2009.S01E14.English.HDTV.XviD-LOL", LanguageType.English)]
[TestCase("Castle.2009.S01E14.French.HDTV.XviD-LOL", LanguageType.French)]
[TestCase("Castle.2009.S01E14.Spanish.HDTV.XviD-LOL", LanguageType.Spanish)]
@ -445,5 +440,16 @@ public void unparsable_should_log_error_but_not_throw(string title)
ExceptionVerification.IgnoreWarns();
ExceptionVerification.ExpectedErrors(1);
}
[TestCase("Castle.2009.S01E14.English.HDTV.XviD-LOL", "LOL")]
[TestCase("Castle 2009 S01E14 English HDTV XviD LOL", "LOL")]
[TestCase("Acropolis Now S05 EXTRAS DVDRip XviD RUNNER", "RUNNER")]
[TestCase("Punky.Brewster.S01.EXTRAS.DVDRip.XviD-RUNNER", "RUNNER")]
[TestCase("2020.NZ.2011.12.02.PDTV.XviD-C4TV", "C4TV")]
[TestCase("The.Office.S03E115.DVDRip.XviD-OSiTV", "OSiTV")]
public void parse_releaseGroup(string title, string expected)
{
Parser.ParseReleaseGroup(title).Should().Be(expected);
}
}
}

View File

@ -201,7 +201,7 @@ public void move_should_not_move_file_if_source_and_destination_are_the_same_pat
.Returns(fakeEpisode);
Mocker.GetMock<MediaFileProvider>()
.Setup(e => e.GetNewFilename(fakeEpisode, fakeSeries.Title, It.IsAny<QualityTypes>(), It.IsAny<bool>()))
.Setup(e => e.GetNewFilename(fakeEpisode, fakeSeries.Title, It.IsAny<QualityTypes>(), It.IsAny<bool>(), It.IsAny<EpisodeFile>()))
.Returns(filename);
Mocker.GetMock<MediaFileProvider>()
@ -298,7 +298,7 @@ public void CleanUpDropFolder_should_move_file_if_a_conflict_is_found()
Mocker.GetMock<EpisodeProvider>().Setup(s => s.GetEpisodesByFileId(episodeFile.EpisodeFileId))
.Returns(episode);
Mocker.GetMock<MediaFileProvider>().Setup(s => s.GetNewFilename(It.IsAny<IList<Episode>>(), series.Title, QualityTypes.Unknown, false))
Mocker.GetMock<MediaFileProvider>().Setup(s => s.GetNewFilename(It.IsAny<IList<Episode>>(), series.Title, QualityTypes.Unknown, false, It.IsAny<EpisodeFile>()))
.Returns(newFilename);
Mocker.GetMock<MediaFileProvider>().Setup(s => s.CalculateFilePath(It.IsAny<Series>(), It.IsAny<int>(), It.IsAny<string>(), It.IsAny<string>()))
@ -350,7 +350,7 @@ public void MoveEpisodeFile_should_use_EpisodeFiles_quality()
.Returns(fakeEpisode);
Mocker.GetMock<MediaFileProvider>()
.Setup(e => e.GetNewFilename(fakeEpisode, fakeSeries.Title, It.IsAny<QualityTypes>(), It.IsAny<bool>()))
.Setup(e => e.GetNewFilename(fakeEpisode, fakeSeries.Title, It.IsAny<QualityTypes>(), It.IsAny<bool>(), It.IsAny<EpisodeFile>()))
.Returns(filename);
Mocker.GetMock<MediaFileProvider>()

View File

@ -1,7 +1,7 @@
// ReSharper disable RedundantUsingDirective
using System.Collections.Generic;
using System.IO;
using FizzWare.NBuilder;
using FluentAssertions;
using NUnit.Framework;
@ -39,7 +39,7 @@ public void GetNewFilename_Series_Episode_Quality_S01E05_Dash()
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, "South Park", QualityTypes.HDTV, false);
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, "South Park", QualityTypes.HDTV, false, new EpisodeFile());
//Assert
Assert.AreEqual("South Park - S15E06 - City Sushi [HDTV]", result);
@ -66,7 +66,7 @@ public void GetNewFilename_Episode_Quality_1x05_Dash()
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, "South Park", QualityTypes.HDTV, false);
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, "South Park", QualityTypes.HDTV, false, new EpisodeFile());
//Assert
Assert.AreEqual("15x06 - City Sushi [HDTV]", result);
@ -93,7 +93,7 @@ public void GetNewFilename_Series_Quality_01x05_Space()
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, "South Park", QualityTypes.HDTV, false);
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, "South Park", QualityTypes.HDTV, false, new EpisodeFile());
//Assert
Assert.AreEqual("South Park 05x06 [HDTV]", result);
@ -121,7 +121,7 @@ public void GetNewFilename_Series_s01e05_Space()
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, "South Park", QualityTypes.HDTV, false);
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, "South Park", QualityTypes.HDTV, false, new EpisodeFile());
//Assert
Assert.AreEqual("South Park s05e06", result);
@ -148,7 +148,7 @@ public void GetNewFilename_Series_Episode_s01e05_Periods()
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, "South Park", QualityTypes.HDTV, false);
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, "South Park", QualityTypes.HDTV, false, new EpisodeFile());
//Assert
Assert.AreEqual("South.Park.s05e06.City.Sushi", result);
@ -175,7 +175,7 @@ public void GetNewFilename_Series_Episode_s01e05_Dash_Periods_Quality()
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, "South Park", QualityTypes.HDTV, false);
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, "South Park", QualityTypes.HDTV, false, new EpisodeFile());
//Assert
Assert.AreEqual("South.Park.-.s05e06.-.City.Sushi.[HDTV]", result);
@ -203,7 +203,7 @@ public void GetNewFilename_S01E05_Dash()
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, "South Park", QualityTypes.HDTV, false);
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, "South Park", QualityTypes.HDTV, false, new EpisodeFile());
//Assert
Assert.AreEqual("S15E06", result);
@ -237,7 +237,7 @@ public void GetNewFilename_multi_Series_Episode_Quality_S01E05_Scene_Dash()
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, "The Mentalist", QualityTypes.HDTV, false);
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, "The Mentalist", QualityTypes.HDTV, false, new EpisodeFile());
//Assert
Assert.AreEqual("The Mentalist - S03E23-E24 - Strawberries and Cream (1) + Strawberries and Cream (2) [HDTV]", result);
@ -271,7 +271,7 @@ public void GetNewFilename_multi_Episode_Quality_1x05_Repeat_Dash()
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, "The Mentalist", QualityTypes.HDTV, false);
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, "The Mentalist", QualityTypes.HDTV, false, new EpisodeFile());
//Assert
Assert.AreEqual("3x23x24 - Strawberries and Cream (1) + Strawberries and Cream (2) [HDTV]", result);
@ -305,7 +305,7 @@ public void GetNewFilename_multi_Episode_Quality_01x05_Repeat_Space()
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, "The Mentalist", QualityTypes.HDTV, false);
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, "The Mentalist", QualityTypes.HDTV, false, new EpisodeFile());
//Assert
Assert.AreEqual("3x23x24 Strawberries and Cream (1) + Strawberries and Cream (2) [HDTV]", result);
@ -339,7 +339,7 @@ public void GetNewFilename_multi_Series_Episode_s01e05_Duplicate_Period()
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, "The Mentalist", QualityTypes.HDTV, false);
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, "The Mentalist", QualityTypes.HDTV, false, new EpisodeFile());
//Assert
Assert.AreEqual("The.Mentalist.s03e23.s03e24.Strawberries.and.Cream.(1).+.Strawberries.and.Cream.(2)", result);
@ -373,7 +373,7 @@ public void GetNewFilename_multi_Series_S01E05_Extend_Dash_Period()
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, "The Mentalist", QualityTypes.HDTV, false);
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, "The Mentalist", QualityTypes.HDTV, false, new EpisodeFile());
//Assert
Assert.AreEqual("The.Mentalist.-.S03E23-24", result);
@ -407,7 +407,7 @@ public void GetNewFilename_multi_1x05_Repeat_Dash_Period()
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, "The Mentalist", QualityTypes.HDTV, false);
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episodeOne, episodeTwo }, "The Mentalist", QualityTypes.HDTV, false, new EpisodeFile());
//Assert
Assert.AreEqual("3x23x24", result);
@ -432,7 +432,7 @@ public void GetNewFilename_should_append_proper_when_proper_and_append_quality_i
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, "South Park", QualityTypes.HDTV, true);
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, "South Park", QualityTypes.HDTV, true, new EpisodeFile());
//Assert
result.Should().Be("South Park - S15E06 - City Sushi [HDTV] [Proper]");
@ -457,7 +457,7 @@ public void GetNewFilename_should_not_append_proper_when_not_proper_and_append_q
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, "South Park", QualityTypes.HDTV, false);
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, "South Park", QualityTypes.HDTV, false, new EpisodeFile());
//Assert
result.Should().Be("South Park - S15E06 - City Sushi [HDTV]");
@ -482,7 +482,7 @@ public void GetNewFilename_should_not_append_proper_when_proper_and_append_quali
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, "South Park", QualityTypes.HDTV, true);
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, "South Park", QualityTypes.HDTV, true, new EpisodeFile());
//Assert
result.Should().Be("South Park - S15E06 - City Sushi");
@ -514,7 +514,7 @@ public void GetNewFilename_should_order_multiple_episode_files_in_numerical_orde
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode2, episode }, "30 Rock", QualityTypes.HDTV, false);
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode2, episode }, "30 Rock", QualityTypes.HDTV, false, new EpisodeFile());
//Assert
result.Should().Be("30 Rock - S06E06-E07 - Hey, Baby, What's Wrong! (1) + Hey, Baby, What's Wrong! (2)");
@ -541,7 +541,7 @@ public void GetNewFilename_Series_Episode_Quality_S01E05_Period()
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, "South Park", QualityTypes.HDTV, false);
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, "South Park", QualityTypes.HDTV, false, new EpisodeFile());
//Assert
Assert.AreEqual("South Park.S15E06.City Sushi [HDTV]", result);
@ -568,10 +568,72 @@ public void GetNewFilename_Episode_Quality_1x05_Period()
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, "South Park", QualityTypes.HDTV, false);
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, "South Park", QualityTypes.HDTV, false, new EpisodeFile());
//Assert
Assert.AreEqual("15x06.City Sushi [HDTV]", result);
}
[Test]
public void GetNewFilename_UseSceneName_when_sceneName_isNull()
{
//Setup
var fakeConfig = Mocker.GetMock<ConfigProvider>();
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(false);
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(true);
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(true);
fakeConfig.SetupGet(c => c.SortingSeparatorStyle).Returns(2);
fakeConfig.SetupGet(c => c.SortingNumberStyle).Returns(0);
fakeConfig.SetupGet(c => c.SortingReplaceSpaces).Returns(false);
fakeConfig.SetupGet(c => c.SortingUseSceneName).Returns(true);
var episode = Builder<Episode>.CreateNew()
.With(e => e.Title = "City Sushi")
.With(e => e.SeasonNumber = 15)
.With(e => e.EpisodeNumber = 6)
.Build();
var episodeFile = Builder<EpisodeFile>.CreateNew()
.With(e => e.SceneName = null)
.With(e => e.Path = @"C:\Test\TV\30 Rock - S01E01 - Test")
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, "South Park", QualityTypes.HDTV, false, episodeFile);
//Assert
result.Should().Be(Path.GetFileNameWithoutExtension(episodeFile.Path));
}
[Test]
public void GetNewFilename_UseSceneName_when_sceneName_isNotNull()
{
//Setup
var fakeConfig = Mocker.GetMock<ConfigProvider>();
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(false);
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(true);
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(true);
fakeConfig.SetupGet(c => c.SortingSeparatorStyle).Returns(2);
fakeConfig.SetupGet(c => c.SortingNumberStyle).Returns(0);
fakeConfig.SetupGet(c => c.SortingReplaceSpaces).Returns(false);
fakeConfig.SetupGet(c => c.SortingUseSceneName).Returns(true);
var episode = Builder<Episode>.CreateNew()
.With(e => e.Title = "City Sushi")
.With(e => e.SeasonNumber = 15)
.With(e => e.EpisodeNumber = 6)
.Build();
var episodeFile = Builder<EpisodeFile>.CreateNew()
.With(e => e.SceneName = "30.Rock.S01E01.xvid-LOL")
.With(e => e.Path = @"C:\Test\TV\30 Rock - S01E01 - Test")
.Build();
//Act
string result = Mocker.Resolve<MediaFileProvider>().GetNewFilename(new List<Episode> { episode }, "South Park", QualityTypes.HDTV, false, episodeFile);
//Assert
result.Should().Be(episodeFile.SceneName);
}
}
}

View File

@ -49,11 +49,11 @@ public void no_misnamed_files()
.Setup(c => c.EpisodesWithFiles()).Returns(episodes);
Mocker.GetMock<MediaFileProvider>()
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[0] }, "SeriesTitle", It.IsAny<QualityTypes>(), It.IsAny<bool>()))
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[0] }, "SeriesTitle", It.IsAny<QualityTypes>(), It.IsAny<bool>(), episodeFiles[0]))
.Returns("Title1");
Mocker.GetMock<MediaFileProvider>()
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[1] }, "SeriesTitle", It.IsAny<QualityTypes>(), It.IsAny<bool>()))
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[1] }, "SeriesTitle", It.IsAny<QualityTypes>(), It.IsAny<bool>(), episodeFiles[1]))
.Returns("Title2");
//Act
@ -98,11 +98,11 @@ public void all_misnamed_files()
.Setup(c => c.EpisodesWithFiles()).Returns(episodes);
Mocker.GetMock<MediaFileProvider>()
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[0] }, "SeriesTitle", It.IsAny<QualityTypes>(), It.IsAny<bool>()))
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[0] }, "SeriesTitle", It.IsAny<QualityTypes>(), It.IsAny<bool>(), episodeFiles[0]))
.Returns("New Title 1");
Mocker.GetMock<MediaFileProvider>()
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[1] }, "SeriesTitle", It.IsAny<QualityTypes>(), It.IsAny<bool>()))
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[1] }, "SeriesTitle", It.IsAny<QualityTypes>(), It.IsAny<bool>(), episodeFiles[1]))
.Returns("New Title 2");
//Act
@ -147,11 +147,11 @@ public void one_misnamed_file()
.Setup(c => c.EpisodesWithFiles()).Returns(episodes);
Mocker.GetMock<MediaFileProvider>()
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[0] }, "SeriesTitle", It.IsAny<QualityTypes>(), It.IsAny<bool>()))
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[0] }, "SeriesTitle", It.IsAny<QualityTypes>(), It.IsAny<bool>(), episodeFiles[0]))
.Returns("New Title 1");
Mocker.GetMock<MediaFileProvider>()
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[1] }, "SeriesTitle", It.IsAny<QualityTypes>(), It.IsAny<bool>()))
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[1] }, "SeriesTitle", It.IsAny<QualityTypes>(), It.IsAny<bool>(), episodeFiles[1]))
.Returns("Title2");
//Act
@ -198,11 +198,11 @@ public void misnamed_multi_episode_file()
.Setup(c => c.EpisodesWithFiles()).Returns(episodes);
Mocker.GetMock<MediaFileProvider>()
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[0], episodes[1] }, "SeriesTitle", It.IsAny<QualityTypes>(), It.IsAny<bool>()))
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[0], episodes[1] }, "SeriesTitle", It.IsAny<QualityTypes>(), It.IsAny<bool>(), episodeFiles[0]))
.Returns("New Title 1");
Mocker.GetMock<MediaFileProvider>()
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[2] }, "SeriesTitle", It.IsAny<QualityTypes>(), It.IsAny<bool>()))
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[2] }, "SeriesTitle", It.IsAny<QualityTypes>(), It.IsAny<bool>(), episodeFiles[1]))
.Returns("Title2");
//Act
@ -249,11 +249,11 @@ public void no_misnamed_multi_episode_file()
.Setup(c => c.EpisodesWithFiles()).Returns(episodes);
Mocker.GetMock<MediaFileProvider>()
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[0], episodes[1] }, "SeriesTitle", It.IsAny<QualityTypes>(), It.IsAny<bool>()))
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[0], episodes[1] }, "SeriesTitle", It.IsAny<QualityTypes>(), It.IsAny<bool>(), episodeFiles[0]))
.Returns("Title1");
Mocker.GetMock<MediaFileProvider>()
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[2] }, "SeriesTitle", It.IsAny<QualityTypes>(), It.IsAny<bool>()))
.Setup(c => c.GetNewFilename(new List<Episode> { episodes[2] }, "SeriesTitle", It.IsAny<QualityTypes>(), It.IsAny<bool>(), episodeFiles[1]))
.Returns("Title2");
//Act

View File

@ -0,0 +1,17 @@
using System;
using System.Data;
using Migrator.Framework;
using NzbDrone.Common;
namespace NzbDrone.Core.Datastore.Migrations
{
[Migration(20120802)]
public class Migration20120802 : NzbDroneMigration
{
protected override void MainDbUpgrade()
{
Database.AddColumn("EpisodeFiles", new Column("SceneName", DbType.String, ColumnProperty.Null));
}
}
}

View File

@ -227,6 +227,7 @@
<Compile Include="Datastore\MigrationLogger.cs" />
<Compile Include="Datastore\MigrationsHelper.cs" />
<Compile Include="Datastore\CustomeMapper.cs" />
<Compile Include="Datastore\Migrations\Migration20120802.cs" />
<Compile Include="Datastore\Migrations\Migration20120727.cs" />
<Compile Include="Datastore\Migrations\Migration20120504.cs" />
<Compile Include="Datastore\Migrations\Migration20120430.cs" />

File diff suppressed because one or more lines are too long

View File

@ -214,6 +214,12 @@ public virtual int SortingMultiEpisodeStyle
set { SetValue("Sorting_MultiEpisodeStyle", value); }
}
public virtual bool SortingUseSceneName
{
get { return GetValueBoolean("Sorting_UseSceneName", false); }
set { SetValue("Sorting_UseSceneName", value); }
}
public virtual int DefaultQualityProfile
{
get { return GetValueInt("DefaultQualityProfile", 1); }

View File

@ -153,6 +153,7 @@ public virtual EpisodeFile ImportFile(Series series, string filePath)
episodeFile.Quality = parseResult.Quality.QualityType;
episodeFile.Proper = parseResult.Quality.Proper;
episodeFile.SeasonNumber = parseResult.SeasonNumber;
episodeFile.SceneName = Path.GetFileNameWithoutExtension(filePath.NormalizePath());
var fileId = _mediaFileProvider.Add(episodeFile);
//Link file to all episodes
@ -175,7 +176,7 @@ public virtual EpisodeFile MoveEpisodeFile(EpisodeFile episodeFile, bool newDown
var series = _seriesProvider.GetSeries(episodeFile.SeriesId);
var episodes = _episodeProvider.GetEpisodesByFileId(episodeFile.EpisodeFileId);
string newFileName = _mediaFileProvider.GetNewFilename(episodes, series.Title, episodeFile.Quality, episodeFile.Proper);
string newFileName = _mediaFileProvider.GetNewFilename(episodes, series.Title, episodeFile.Quality, episodeFile.Proper, episodeFile);
var newFile = _mediaFileProvider.CalculateFilePath(series, episodes.First().SeasonNumber, newFileName, Path.GetExtension(episodeFile.Path));
//Only rename if existing and new filenames don't match

View File

@ -142,8 +142,22 @@ LEFT OUTER JOIN Episodes
}
}
public virtual string GetNewFilename(IList<Episode> episodes, string seriesTitle, QualityTypes quality, bool proper)
public virtual string GetNewFilename(IList<Episode> episodes, string seriesTitle, QualityTypes quality, bool proper, EpisodeFile episodeFile)
{
if (_configProvider.SortingUseSceneName)
{
Logger.Trace("Attempting to use scene name");
if (String.IsNullOrWhiteSpace(episodeFile.SceneName))
{
var name = Path.GetFileNameWithoutExtension(episodeFile.Path);
Logger.Trace("Unable to use scene name, because it is null, sticking with current name: {0}", name);
return name;
}
return episodeFile.SceneName;
}
var sortedEpisodes = episodes.OrderBy(e => e.EpisodeNumber);
var separatorStyle = EpisodeSortingHelper.GetSeparatorStyle(_configProvider.SortingSeparatorStyle);

View File

@ -29,7 +29,6 @@ public virtual List<MisnamedEpisodeModel> MisnamedFiles(int pageNumber, int page
var episodesWithFiles = _episodeProvider.EpisodesWithFiles().GroupBy(e => e.EpisodeFileId).ToList();
totalItems = episodesWithFiles.Count();
var stopwatch = new Stopwatch();
stopwatch.Start();
@ -37,7 +36,7 @@ public virtual List<MisnamedEpisodeModel> MisnamedFiles(int pageNumber, int page
w =>
w.First().EpisodeFile.Path !=
_mediaFileProvider.GetNewFilename(w.Select(e => e).ToList(), w.First().Series.Title,
w.First().EpisodeFile.Quality, w.First().EpisodeFile.Proper)).Skip(Math.Max(pageSize * (pageNumber - 1), 0)).Take(pageSize);
w.First().EpisodeFile.Quality, w.First().EpisodeFile.Proper, w.First().EpisodeFile)).Skip(Math.Max(pageSize * (pageNumber - 1), 0)).Take(pageSize);
//Process the episodes
misnamedFilesSelect.AsParallel().ForAll(f =>
@ -46,7 +45,7 @@ public virtual List<MisnamedEpisodeModel> MisnamedFiles(int pageNumber, int page
var firstEpisode = episodes[0];
var properName = _mediaFileProvider.GetNewFilename(episodes,
firstEpisode.Series.Title,
firstEpisode.EpisodeFile.Quality, firstEpisode.EpisodeFile.Proper);
firstEpisode.EpisodeFile.Quality, firstEpisode.EpisodeFile.Proper, firstEpisode.EpisodeFile);
var currentName = Path.GetFileNameWithoutExtension(firstEpisode.EpisodeFile.Path);

View File

@ -34,6 +34,7 @@ public EpisodeFile(EpisodeFile source)
public bool Proper { get; set; }
public long Size { get; set; }
public DateTime DateAdded { get; set; }
public string SceneName { get; set; }
[Ignore]
public Model.Quality QualityWrapper

View File

@ -205,6 +205,7 @@ public ActionResult Naming()
model.SeparatorStyle = _configProvider.SortingSeparatorStyle;
model.NumberStyle = _configProvider.SortingNumberStyle;
model.MultiEpisodeStyle = _configProvider.SortingMultiEpisodeStyle;
model.SceneName = _configProvider.SortingUseSceneName;
model.SeparatorStyles = new SelectList(EpisodeSortingHelper.GetSeparatorStyles(), "Id", "Name");
model.NumberStyles = new SelectList(EpisodeSortingHelper.GetNumberStyles(), "Id", "Name");
@ -594,6 +595,7 @@ public JsonResult SaveNaming(EpisodeNamingModel data)
_configProvider.SortingSeparatorStyle = data.SeparatorStyle;
_configProvider.SortingNumberStyle = data.NumberStyle;
_configProvider.SortingMultiEpisodeStyle = data.MultiEpisodeStyle;
_configProvider.SortingUseSceneName = data.SceneName;
//Metadata
_configProvider.MetadataUseBanners = data.MetadataUseBanners;

View File

@ -43,6 +43,10 @@ public class EpisodeNamingModel
[Description("How will multi-episode files be named?")]
public int MultiEpisodeStyle { get; set; }
[DisplayName("Use Scene Name")]
[Description("Use the scene name, ignoring all other naming settings?")]
public bool SceneName { get; set; }
[DisplayName("XBMC")]
[Description("Enable creating metadata for XBMC")]
public bool MetadataXbmcEnabled { get; set; }

View File

@ -42,6 +42,10 @@
<span class="small">@Html.DescriptionFor(m => m.MultiEpisodeStyle)</span>
</label>
@Html.DropDownListFor(m => m.MultiEpisodeStyle, Model.MultiEpisodeStyles, new { @class = "inputClass selectClass" })
<label class="labelClass">@Html.LabelFor(m => m.SceneName)
<span class="small">@Html.DescriptionFor(m => m.SceneName)</span>
</label>
@Html.CheckBoxFor(m => m.SceneName, new { @class = "inputClass checkClass" })
</div>
<div id="examples">
<div id="singleEpisodeExample">