more file naming cleanup.

This commit is contained in:
kay.one 2013-03-06 14:20:34 -08:00
parent f21358fce5
commit 969dff5197
9 changed files with 161 additions and 231 deletions

View File

@ -51,7 +51,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
nameSpecification.IncludeSeriesName = true;
nameSpecification.IncludeEpisodeTitle = true;
nameSpecification.AppendQuality = true;
nameSpecification.SeparatorStyle = 0;
nameSpecification.Separator = " - ";
nameSpecification.NumberStyle = 2;
nameSpecification.ReplaceSpaces = false;
@ -78,7 +78,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
nameSpecification.IncludeSeriesName = false;
nameSpecification.IncludeEpisodeTitle = true;
nameSpecification.AppendQuality = true;
nameSpecification.SeparatorStyle = 0;
nameSpecification.Separator = " - ";
nameSpecification.NumberStyle = 0;
nameSpecification.ReplaceSpaces = false;
@ -105,7 +105,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
nameSpecification.IncludeSeriesName = true;
nameSpecification.IncludeEpisodeTitle = false;
nameSpecification.AppendQuality = true;
nameSpecification.SeparatorStyle = 1;
nameSpecification.Separator = " ";
nameSpecification.NumberStyle = 1;
nameSpecification.ReplaceSpaces = false;
@ -132,7 +132,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
nameSpecification.IncludeSeriesName = true;
nameSpecification.IncludeEpisodeTitle = false;
nameSpecification.AppendQuality = false;
nameSpecification.SeparatorStyle = 1;
nameSpecification.Separator = " ";
nameSpecification.NumberStyle = 3;
nameSpecification.ReplaceSpaces = false;
@ -160,7 +160,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
nameSpecification.IncludeSeriesName = true;
nameSpecification.IncludeEpisodeTitle = true;
nameSpecification.AppendQuality = false;
nameSpecification.SeparatorStyle = 1;
nameSpecification.Separator = " ";
nameSpecification.NumberStyle = 3;
nameSpecification.ReplaceSpaces = true;
@ -187,7 +187,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
nameSpecification.IncludeSeriesName = true;
nameSpecification.IncludeEpisodeTitle = true;
nameSpecification.AppendQuality = true;
nameSpecification.SeparatorStyle = 0;
nameSpecification.Separator = " - ";
nameSpecification.NumberStyle = 3;
nameSpecification.ReplaceSpaces = true;
@ -214,7 +214,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
nameSpecification.IncludeSeriesName = false;
nameSpecification.IncludeEpisodeTitle = false;
nameSpecification.AppendQuality = false;
nameSpecification.SeparatorStyle = 0;
nameSpecification.Separator = " - ";
nameSpecification.NumberStyle = 2;
nameSpecification.ReplaceSpaces = false;
@ -242,7 +242,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
nameSpecification.IncludeSeriesName = true;
nameSpecification.IncludeEpisodeTitle = true;
nameSpecification.AppendQuality = true;
nameSpecification.SeparatorStyle = 0;
nameSpecification.Separator = " - ";
nameSpecification.NumberStyle = 2;
nameSpecification.ReplaceSpaces = false;
nameSpecification.MultiEpisodeStyle = 3;
@ -276,7 +276,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
nameSpecification.IncludeSeriesName = false;
nameSpecification.IncludeEpisodeTitle = true;
nameSpecification.AppendQuality = true;
nameSpecification.SeparatorStyle = 0;
nameSpecification.Separator = " - ";
nameSpecification.NumberStyle = 0;
nameSpecification.ReplaceSpaces = false;
nameSpecification.MultiEpisodeStyle = 2;
@ -310,7 +310,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
nameSpecification.IncludeSeriesName = false;
nameSpecification.IncludeEpisodeTitle = true;
nameSpecification.AppendQuality = true;
nameSpecification.SeparatorStyle = 1;
nameSpecification.Separator = " ";
nameSpecification.NumberStyle = 0;
nameSpecification.ReplaceSpaces = false;
nameSpecification.MultiEpisodeStyle = 2;
@ -344,7 +344,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
nameSpecification.IncludeSeriesName = true;
nameSpecification.IncludeEpisodeTitle = true;
nameSpecification.AppendQuality = false;
nameSpecification.SeparatorStyle = 1;
nameSpecification.Separator = " ";
nameSpecification.NumberStyle = 3;
nameSpecification.ReplaceSpaces = true;
nameSpecification.MultiEpisodeStyle = 1;
@ -378,7 +378,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
nameSpecification.IncludeSeriesName = true;
nameSpecification.IncludeEpisodeTitle = false;
nameSpecification.AppendQuality = false;
nameSpecification.SeparatorStyle = 0;
nameSpecification.Separator = " - ";
nameSpecification.NumberStyle = 2;
nameSpecification.ReplaceSpaces = true;
nameSpecification.MultiEpisodeStyle = 0;
@ -412,7 +412,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
nameSpecification.IncludeSeriesName = false;
nameSpecification.IncludeEpisodeTitle = false;
nameSpecification.AppendQuality = false;
nameSpecification.SeparatorStyle = 0;
nameSpecification.Separator = " - ";
nameSpecification.NumberStyle = 0;
nameSpecification.ReplaceSpaces = true;
nameSpecification.MultiEpisodeStyle = 2;
@ -444,7 +444,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
nameSpecification.IncludeSeriesName = true;
nameSpecification.IncludeEpisodeTitle = true;
nameSpecification.AppendQuality = true;
nameSpecification.SeparatorStyle = 0;
nameSpecification.Separator = " - ";
nameSpecification.NumberStyle = 2;
nameSpecification.ReplaceSpaces = false;
@ -469,7 +469,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
nameSpecification.IncludeSeriesName = true;
nameSpecification.IncludeEpisodeTitle = true;
nameSpecification.AppendQuality = true;
nameSpecification.SeparatorStyle = 0;
nameSpecification.Separator = " - ";
nameSpecification.NumberStyle = 2;
nameSpecification.ReplaceSpaces = false;
@ -494,7 +494,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
nameSpecification.IncludeSeriesName = true;
nameSpecification.IncludeEpisodeTitle = true;
nameSpecification.AppendQuality = false;
nameSpecification.SeparatorStyle = 0;
nameSpecification.Separator = " - ";
nameSpecification.NumberStyle = 2;
nameSpecification.ReplaceSpaces = false;
@ -519,7 +519,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
nameSpecification.IncludeSeriesName = true;
nameSpecification.IncludeEpisodeTitle = true;
nameSpecification.AppendQuality = false;
nameSpecification.SeparatorStyle = 0;
nameSpecification.Separator = " - ";
nameSpecification.NumberStyle = 2;
nameSpecification.ReplaceSpaces = false;
nameSpecification.MultiEpisodeStyle = 3;
@ -553,7 +553,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
nameSpecification.IncludeSeriesName = true;
nameSpecification.IncludeEpisodeTitle = true;
nameSpecification.AppendQuality = true;
nameSpecification.SeparatorStyle = 2;
nameSpecification.Separator = ".";
nameSpecification.NumberStyle = 2;
nameSpecification.ReplaceSpaces = false;
@ -580,7 +580,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
nameSpecification.IncludeSeriesName = false;
nameSpecification.IncludeEpisodeTitle = true;
nameSpecification.AppendQuality = true;
nameSpecification.SeparatorStyle = 2;
nameSpecification.Separator = "."; ;
nameSpecification.NumberStyle = 0;
nameSpecification.ReplaceSpaces = false;
@ -605,7 +605,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
nameSpecification.IncludeSeriesName = false;
nameSpecification.IncludeEpisodeTitle = true;
nameSpecification.AppendQuality = true;
nameSpecification.SeparatorStyle = 2;
nameSpecification.Separator = "."; ;
nameSpecification.NumberStyle = 0;
nameSpecification.ReplaceSpaces = false;
nameSpecification.UseSceneName = true;
@ -636,7 +636,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
nameSpecification.IncludeSeriesName = false;
nameSpecification.IncludeEpisodeTitle = true;
nameSpecification.AppendQuality = true;
nameSpecification.SeparatorStyle = 2;
nameSpecification.Separator = ".";
nameSpecification.NumberStyle = 0;
nameSpecification.ReplaceSpaces = false;
nameSpecification.UseSceneName = true;
@ -667,7 +667,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
nameSpecification.IncludeSeriesName = true;
nameSpecification.IncludeEpisodeTitle = true;
nameSpecification.AppendQuality = false;
nameSpecification.SeparatorStyle = 0;
nameSpecification.Separator = " - ";
nameSpecification.NumberStyle = 2;
nameSpecification.ReplaceSpaces = false;
nameSpecification.MultiEpisodeStyle = 3;
@ -699,7 +699,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
nameSpecification.IncludeSeriesName = true;
nameSpecification.IncludeEpisodeTitle = true;
nameSpecification.AppendQuality = false;
nameSpecification.SeparatorStyle = 0;
nameSpecification.Separator = " - ";
nameSpecification.NumberStyle = 2;
nameSpecification.ReplaceSpaces = false;
nameSpecification.MultiEpisodeStyle = 3;
@ -731,7 +731,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
nameSpecification.IncludeSeriesName = true;
nameSpecification.IncludeEpisodeTitle = true;
nameSpecification.AppendQuality = false;
nameSpecification.SeparatorStyle = 0;
nameSpecification.Separator = " - ";
nameSpecification.NumberStyle = 2;
nameSpecification.ReplaceSpaces = false;
nameSpecification.MultiEpisodeStyle = 3;
@ -768,7 +768,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
nameSpecification.IncludeSeriesName = true;
nameSpecification.IncludeEpisodeTitle = true;
nameSpecification.AppendQuality = true;
nameSpecification.SeparatorStyle = 0;
nameSpecification.Separator = " - ";
nameSpecification.NumberStyle = 2;
nameSpecification.ReplaceSpaces = false;
@ -797,7 +797,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
nameSpecification.IncludeSeriesName = true;
nameSpecification.IncludeEpisodeTitle = false;
nameSpecification.AppendQuality = false;
nameSpecification.SeparatorStyle = 0;
nameSpecification.Separator = " - ";
nameSpecification.NumberStyle = 2;
nameSpecification.ReplaceSpaces = false;
@ -826,7 +826,7 @@ namespace NzbDrone.Core.Test.OrganizerTests
nameSpecification.IncludeSeriesName = true;
nameSpecification.IncludeEpisodeTitle = true;
nameSpecification.AppendQuality = false;
nameSpecification.SeparatorStyle = 0;
nameSpecification.Separator = " - ";
nameSpecification.NumberStyle = 2;
nameSpecification.ReplaceSpaces = false;

View File

@ -111,7 +111,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests
.Returns(newFilename);
Mocker.GetMock<IBuildFileNames>().Setup(s => s.BuildFilePath(It.IsAny<Series>(), It.IsAny<int>(), It.IsAny<string>(), It.IsAny<string>()))
.Returns(new FileInfo(newFilePath));
.Returns(newFilePath);
Mocker.GetMock<DiskProvider>()
.Setup(s => s.FileExists(filename))

View File

@ -42,11 +42,11 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests
.Build().ToList();
const string filename = @"30 Rock - S01E01 - TBD";
var fi = new FileInfo(Path.Combine(@"C:\Test\TV\30 Rock\Season 01\", filename + ".avi"));
var fi = Path.Combine(@"C:\Test\TV\30 Rock\Season 01\", filename + ".avi");
var file = Builder<EpisodeFile>.CreateNew()
.With(f => f.SeriesId = fakeSeries.Id)
.With(f => f.Path = fi.FullName)
.With(f => f.Path = fi)
.Build();
Mocker.GetMock<ISeriesRepository>()
@ -88,7 +88,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests
.Build().ToList();
const string filename = @"30 Rock - S01E01 - TBD";
var fi = new FileInfo(Path.Combine(@"C:\Test\TV\30 Rock\Season 01\", filename + ".mkv"));
var fi = Path.Combine(@"C:\Test\TV\30 Rock\Season 01\", filename + ".mkv");
var currentFilename = Path.Combine(@"C:\Test\TV\30 Rock\Season 01\", "30.Rock.S01E01.Test.WED-DL.mkv");
const string message = "30 Rock - 1x01 - [WEBDL]";
@ -140,7 +140,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests
.Build().ToList();
const string filename = @"30 Rock - S01E01 - TBD";
var fi = new FileInfo(Path.Combine(@"C:\Test\TV\30 Rock\Season 01\", filename + ".mkv"));
var fi = Path.Combine(@"C:\Test\TV\30 Rock\Season 01\", filename + ".mkv");
var currentFilename = Path.Combine(@"C:\Test\TV\30 Rock\Season 01\", "30.Rock.S01E01.Test.WED-DL.mkv");
const string message = "30 Rock - 1x01 - [WEBDL]";

View File

@ -1,137 +0,0 @@
using System.Collections.Generic;
using System.Linq;
using NzbDrone.Core.Model;
namespace NzbDrone.Core.Helpers
{
public static class EpisodeSortingHelper
{
private static readonly List<EpisodeSortingType> SeparatorStyles = new List<EpisodeSortingType>
{
new EpisodeSortingType
{
Id = 0,
Name = "Dash",
Pattern = " - "
},
new EpisodeSortingType
{
Id = 1,
Name = "Space",
Pattern = " "
},
new EpisodeSortingType
{
Id = 2,
Name = "Period",
Pattern = "."
}
};
private static readonly List<EpisodeSortingType> NumberStyles = new List<EpisodeSortingType>
{
new EpisodeSortingType
{
Id = 0,
Name = "1x05",
Pattern = "%sx%0e",
EpisodeSeparator = "x"
},
new EpisodeSortingType
{
Id = 1,
Name = "01x05",
Pattern = "%0sx%0e",
EpisodeSeparator = "x"
},
new EpisodeSortingType
{
Id = 2,
Name = "S01E05",
Pattern = "S%0sE%0e",
EpisodeSeparator = "E"
},
new EpisodeSortingType
{
Id = 3,
Name = "s01e05",
Pattern = "s%0se%0e",
EpisodeSeparator = "e"
}
};
private static readonly List<EpisodeSortingType> MultiEpisodeStyles = new List<EpisodeSortingType>
{
new EpisodeSortingType
{
Id = 0,
Name = "Extend",
Pattern = "-%0e"
},
new EpisodeSortingType
{
Id = 1,
Name = "Duplicate",
Pattern = "%p%0s%x%0e"
},
new EpisodeSortingType
{
Id = 2,
Name = "Repeat",
Pattern = "%x%0e"
},
new EpisodeSortingType
{
Id = 3,
Name = "Scene",
Pattern = "-%x%0e"
}
};
public static List<EpisodeSortingType> GetSeparatorStyles()
{
return SeparatorStyles;
}
public static List<EpisodeSortingType> GetNumberStyles()
{
return NumberStyles;
}
public static List<EpisodeSortingType> GetMultiEpisodeStyles()
{
return MultiEpisodeStyles;
}
public static EpisodeSortingType GetSeparatorStyle(int id)
{
return SeparatorStyles.Single(s => s.Id == id);
}
public static EpisodeSortingType GetNumberStyle(int id)
{
return NumberStyles.Single(s => s.Id == id);
}
public static EpisodeSortingType GetMultiEpisodeStyle(int id)
{
return MultiEpisodeStyles.Single(s => s.Id == id);
}
public static EpisodeSortingType GetSeparatorStyle(string name)
{
return SeparatorStyles.Single(s => s.Name == name);
}
public static EpisodeSortingType GetNumberStyle(string name)
{
return NumberStyles.Single(s => s.Name == name);
}
public static EpisodeSortingType GetMultiEpisodeStyle(string name)
{
return MultiEpisodeStyles.Single(s => s.Name == name);
}
}
}

View File

@ -195,7 +195,6 @@
<Compile Include="Fluent.cs" />
<Compile Include="Helpers\Converters\EpochDateTimeConverter.cs" />
<Compile Include="Helpers\SabnzbdQueueTimeConverter.cs" />
<Compile Include="Helpers\EpisodeSortingHelper.cs" />
<Compile Include="Helpers\SortHelper.cs" />
<Compile Include="Helpers\SabnzbdPriorityTypeConverter.cs" />
<Compile Include="Helpers\XElementHelper.cs" />
@ -234,6 +233,7 @@
<Compile Include="Lifecycle\IInitializable.cs" />
<Compile Include="MediaCover\MediaCover.cs" />
<Compile Include="MediaFiles\MediaFileRepository.cs" />
<Compile Include="Organizer\EpisodeSortingType.cs" />
<Compile Include="Organizer\FileNameBuilder.cs" />
<Compile Include="Model\DownloadClientType.cs" />
<Compile Include="Instrumentation\LogService.cs" />
@ -256,6 +256,7 @@
<Compile Include="Model\PostDownloadStatusType.cs" />
<Compile Include="Model\LanguageType.cs" />
<Compile Include="Model\MisnamedEpisodeModel.cs" />
<Compile Include="Organizer\NameSpecification.cs" />
<Compile Include="Qualities\QualitySizeRepository.cs" />
<Compile Include="Qualities\QualityProfileRepository.cs" />
<Compile Include="ReferenceData\DailySeriesDataProxy.cs" />
@ -501,7 +502,6 @@
<Compile Include="ExternalNotification\ExternalNotificationDefinition.cs" />
<Compile Include="Indexers\Indexer.cs" />
<Compile Include="Model\EpisodeParseResult.cs" />
<Compile Include="Model\EpisodeSortingType.cs" />
<Compile Include="Model\EpisodeStatusType.cs" />
<Compile Include="Download\Clients\Sabnzbd\SabPriorityType.cs" />
<Compile Include="Model\SeasonParseResult.cs" />

View File

@ -1,4 +1,4 @@
namespace NzbDrone.Core.Model
namespace NzbDrone.Core.Organizer
{
public class EpisodeSortingType
{

View File

@ -4,45 +4,15 @@ using System.IO;
using System.Linq;
using NLog;
using NzbDrone.Core.Datastore;
using NzbDrone.Core.Helpers;
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Tv;
namespace NzbDrone.Core.Organizer
{
public class NameSpecification : ModelBase
{
public static NameSpecification Default
{
get { return new NameSpecification(); }
}
public bool UseSceneName { get; set; }
public int SeparatorStyle { get; set; }
public int NumberStyle { get; set; }
public bool IncludeSeriesName { get; set; }
public int MultiEpisodeStyle { get; set; }
public bool IncludeEpisodeTitle { get; set; }
public bool AppendQuality { get; set; }
public bool ReplaceSpaces { get; set; }
public string SeasonFolderFormat { get; set; }
}
public interface IBuildFileNames
{
string BuildFilename(IList<Episode> episodes, Series series, EpisodeFile episodeFile);
FileInfo BuildFilePath(Series series, int seasonNumber, string fileName, string extension);
string BuildFilePath(Series series, int seasonNumber, string fileName, string extension);
}
public class FileNameBuilder : IBuildFileNames
@ -69,13 +39,9 @@ namespace NzbDrone.Core.Organizer
if (nameSpec.UseSceneName)
{
_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 Path.GetFileNameWithoutExtension(episodeFile.Path);
}
return episodeFile.SceneName;
@ -83,18 +49,18 @@ namespace NzbDrone.Core.Organizer
var sortedEpisodes = episodes.OrderBy(e => e.EpisodeNumber);
var separatorStyle = EpisodeSortingHelper.GetSeparatorStyle(nameSpec.SeparatorStyle);
var numberStyle = EpisodeSortingHelper.GetNumberStyle(nameSpec.NumberStyle);
var numberStyle = GetNumberStyle(nameSpec.NumberStyle);
var episodeNames = new List<string>();
var episodeNames = new List<string>
{
Parser.CleanupEpisodeTitle(sortedEpisodes.First().Title)
};
episodeNames.Add(Parser.CleanupEpisodeTitle(sortedEpisodes.First().Title));
string result = String.Empty;
var result = String.Empty;
if (nameSpec.IncludeSeriesName)
{
result += series.Title + separatorStyle.Pattern;
result += series.Title + nameSpec.Separator;
}
if (series.SeriesTypes == SeriesTypes.Standard)
@ -105,13 +71,13 @@ namespace NzbDrone.Core.Organizer
if (episodes.Count > 1)
{
var multiEpisodeStyle =
EpisodeSortingHelper.GetMultiEpisodeStyle(nameSpec.MultiEpisodeStyle);
GetMultiEpisodeStyle(nameSpec.MultiEpisodeStyle);
foreach (var episode in sortedEpisodes.Skip(1))
{
if (multiEpisodeStyle.Name == "Duplicate")
{
result += separatorStyle.Pattern + numberStyle.Pattern;
result += nameSpec.Separator + numberStyle.Pattern;
}
else
{
@ -127,7 +93,7 @@ namespace NzbDrone.Core.Organizer
.Replace("%s", String.Format("{0}", episodes.First().SeasonNumber))
.Replace("%0s", String.Format("{0:00}", episodes.First().SeasonNumber))
.Replace("%x", numberStyle.EpisodeSeparator)
.Replace("%p", separatorStyle.Pattern);
.Replace("%p", nameSpec.Separator);
}
else
@ -142,10 +108,10 @@ namespace NzbDrone.Core.Organizer
if (nameSpec.IncludeEpisodeTitle)
{
if (episodeNames.Distinct().Count() == 1)
result += separatorStyle.Pattern + episodeNames.First();
result += nameSpec.Separator + episodeNames.First();
else
result += separatorStyle.Pattern + String.Join(" + ", episodeNames.Distinct());
result += nameSpec.Separator + String.Join(" + ", episodeNames.Distinct());
}
if (nameSpec.AppendQuality)
@ -163,7 +129,7 @@ namespace NzbDrone.Core.Organizer
return CleanFilename(result.Trim());
}
public FileInfo BuildFilePath(Series series, int seasonNumber, string fileName, string extension)
public string BuildFilePath(Series series, int seasonNumber, string fileName, string extension)
{
var nameSpec = GetSpecification();
@ -178,9 +144,7 @@ namespace NzbDrone.Core.Organizer
path = Path.Combine(path, seasonFolder);
}
path = Path.Combine(path, fileName + extension);
return new FileInfo(path);
return Path.Combine(path, fileName + extension);
}
@ -195,5 +159,78 @@ namespace NzbDrone.Core.Organizer
return result.Trim();
}
private static readonly List<EpisodeSortingType> NumberStyles = new List<EpisodeSortingType>
{
new EpisodeSortingType
{
Id = 0,
Name = "1x05",
Pattern = "%sx%0e",
EpisodeSeparator = "x"
},
new EpisodeSortingType
{
Id = 1,
Name = "01x05",
Pattern = "%0sx%0e",
EpisodeSeparator = "x"
},
new EpisodeSortingType
{
Id = 2,
Name = "S01E05",
Pattern = "S%0sE%0e",
EpisodeSeparator = "E"
},
new EpisodeSortingType
{
Id = 3,
Name = "s01e05",
Pattern = "s%0se%0e",
EpisodeSeparator = "e"
}
};
private static readonly List<EpisodeSortingType> MultiEpisodeStyles = new List<EpisodeSortingType>
{
new EpisodeSortingType
{
Id = 0,
Name = "Extend",
Pattern = "-%0e"
},
new EpisodeSortingType
{
Id = 1,
Name = "Duplicate",
Pattern = "%p%0s%x%0e"
},
new EpisodeSortingType
{
Id = 2,
Name = "Repeat",
Pattern = "%x%0e"
},
new EpisodeSortingType
{
Id = 3,
Name = "Scene",
Pattern = "-%x%0e"
}
};
private static EpisodeSortingType GetNumberStyle(int id)
{
return NumberStyles.Single(s => s.Id == id);
}
private static EpisodeSortingType GetMultiEpisodeStyle(int id)
{
return MultiEpisodeStyles.Single(s => s.Id == id);
}
}
}

View File

@ -0,0 +1,30 @@
using NzbDrone.Core.Datastore;
namespace NzbDrone.Core.Organizer
{
public class NameSpecification : ModelBase
{
public static NameSpecification Default
{
get { return new NameSpecification(); }
}
public bool UseSceneName { get; set; }
public string Separator { get; set; }
public int NumberStyle { get; set; }
public bool IncludeSeriesName { get; set; }
public int MultiEpisodeStyle { get; set; }
public bool IncludeEpisodeTitle { get; set; }
public bool AppendQuality { get; set; }
public bool ReplaceSpaces { get; set; }
public string SeasonFolderFormat { get; set; }
}
}

View File

@ -192,7 +192,7 @@ namespace NzbDrone.Core.Providers
var newFile = _buildFileNames.BuildFilePath(series, episodes.First().SeasonNumber, newFileName, Path.GetExtension(episodeFile.Path));
//Only rename if existing and new filenames don't match
if (DiskProvider.PathEquals(episodeFile.Path, newFile.FullName))
if (DiskProvider.PathEquals(episodeFile.Path, newFile))
{
Logger.Debug("Skipping file rename, source and destination are the same: {0}", episodeFile.Path);
return null;
@ -204,23 +204,23 @@ namespace NzbDrone.Core.Providers
return null;
}
_diskProvider.CreateDirectory(newFile.DirectoryName);
_diskProvider.CreateDirectory(new FileInfo(newFile).DirectoryName);
Logger.Debug("Moving [{0}] > [{1}]", episodeFile.Path, newFile.FullName);
_diskProvider.MoveFile(episodeFile.Path, newFile.FullName);
Logger.Debug("Moving [{0}] > [{1}]", episodeFile.Path, newFile);
_diskProvider.MoveFile(episodeFile.Path, newFile);
//Wrapped in Try/Catch to prevent this from causing issues with remote NAS boxes, the move worked, which is more important.
try
{
_diskProvider.InheritFolderPermissions(newFile.FullName);
_diskProvider.InheritFolderPermissions(newFile);
}
catch (UnauthorizedAccessException ex)
{
Logger.Debug("Unable to apply folder permissions to: ", newFile.FullName);
Logger.Debug("Unable to apply folder permissions to: ", newFile);
Logger.TraceException(ex.Message, ex);
}
episodeFile.Path = newFile.FullName;
episodeFile.Path = newFile;
_mediaFileService.Update(episodeFile);
var parseResult = Parser.ParsePath(episodeFile.Path);