From 165beda55bf0eac35682bf295ffec1d4686506be Mon Sep 17 00:00:00 2001 From: markus101 Date: Thu, 24 Feb 2011 23:20:24 -0800 Subject: [PATCH] Use Season Folder is set in config (also set per Series), default is true. --- NzbDrone.Core/Providers/RenameProvider.cs | 27 +++++++++++++++++++---- NzbDrone.Core/Providers/SeriesProvider.cs | 5 +++++ NzbDrone.Core/Repository/Series.cs | 2 ++ 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/NzbDrone.Core/Providers/RenameProvider.cs b/NzbDrone.Core/Providers/RenameProvider.cs index d85ec4bc5..57b80c219 100644 --- a/NzbDrone.Core/Providers/RenameProvider.cs +++ b/NzbDrone.Core/Providers/RenameProvider.cs @@ -45,7 +45,11 @@ public void RenameAll() var series = _seriesProvider.GetSeries(episodeFile.SeriesId); var erm = new EpisodeRenameModel(); erm.SeriesName = series.Title; - erm.Folder = series.Path + Path.DirectorySeparatorChar + GetSeasonFolder(episodeFile.Episodes[0].SeasonNumber); + erm.Folder = series.Path; + + if (series.SeasonFolder) + erm.Folder += Path.DirectorySeparatorChar + GetSeasonFolder(episodeFile.Episodes[0].SeasonNumber); + erm.EpisodeFile = episodeFile; _epsToRename.Add(erm); StartRename(); @@ -62,7 +66,12 @@ public void RenameSeries(int seriesId) { var erm = new EpisodeRenameModel(); erm.SeriesName = series.Title; - erm.Folder = series.Path + Path.DirectorySeparatorChar + GetSeasonFolder(episodeFile.Episodes[0].SeasonNumber); + + erm.Folder = series.Path; + + if (series.SeasonFolder) + erm.Folder += Path.DirectorySeparatorChar + GetSeasonFolder(episodeFile.Episodes[0].SeasonNumber); + erm.EpisodeFile = episodeFile; _epsToRename.Add(erm); StartRename(); @@ -79,7 +88,12 @@ public void RenameSeason(int seasonId) { var erm = new EpisodeRenameModel(); erm.SeriesName = series.Title; - erm.Folder = series.Path + Path.DirectorySeparatorChar + GetSeasonFolder(episodeFile.Episodes[0].SeasonNumber); + + erm.Folder = series.Path; + + if (series.SeasonFolder) + erm.Folder += Path.DirectorySeparatorChar + GetSeasonFolder(episodeFile.Episodes[0].SeasonNumber); + erm.EpisodeFile = episodeFile; _epsToRename.Add(erm); StartRename(); @@ -96,7 +110,12 @@ public void RenameEpisode(int episodeId) var erm = new EpisodeRenameModel(); erm.SeriesName = series.Title; - erm.Folder = series.Path + Path.DirectorySeparatorChar + GetSeasonFolder(episodeFile.Episodes[0].SeasonNumber); + + erm.Folder = series.Path; + + if (series.SeasonFolder) + erm.Folder += Path.DirectorySeparatorChar + GetSeasonFolder(episodeFile.Episodes[0].SeasonNumber); + erm.EpisodeFile = episodeFile; _epsToRename.Add(erm); StartRename(); diff --git a/NzbDrone.Core/Providers/SeriesProvider.cs b/NzbDrone.Core/Providers/SeriesProvider.cs index b09a38fa7..a5f4269ae 100644 --- a/NzbDrone.Core/Providers/SeriesProvider.cs +++ b/NzbDrone.Core/Providers/SeriesProvider.cs @@ -111,6 +111,11 @@ public void AddSeries(string path, TvdbSeries series) repoSeries.CleanTitle = Parser.NormalizeTitle(series.SeriesName); repoSeries.Monitored = true; //New shows should be monitored repoSeries.QualityProfileId = Convert.ToInt32(_config.GetValue("DefaultQualityProfile", "1", true)); + repoSeries.SeasonFolder = true; + + if (!Convert.ToBoolean(_config.GetValue("SeasonFolder", true, true))) + repoSeries.SeasonFolder = false; + _sonioRepo.Add(repoSeries); } diff --git a/NzbDrone.Core/Repository/Series.cs b/NzbDrone.Core/Repository/Series.cs index de411c8ca..feb5cef3e 100644 --- a/NzbDrone.Core/Repository/Series.cs +++ b/NzbDrone.Core/Repository/Series.cs @@ -32,6 +32,8 @@ public class Series public int QualityProfileId { get; set; } + public bool SeasonFolder { get; set; } + [SubSonicToOneRelation(ThisClassContainsJoinKey = true)] public virtual QualityProfile QualityProfile { get; private set; }