Moved SeasonFolderFormat to NamingConfig

Moved UseSeasonFolder to UI only (add series)
pull/4/head
Mark McDowall 11 years ago
parent 9d94c4490f
commit 3db97e9d11

@ -9,5 +9,6 @@ namespace NzbDrone.Api.Config
public Int32 MultiEpisodeStyle { get; set; }
public string StandardEpisodeFormat { get; set; }
public string DailyEpisodeFormat { get; set; }
public string SeasonFolderFormat { get; set; }
}
}

@ -142,19 +142,6 @@ namespace NzbDrone.Core.Configuration
set { SetValue(ConfigKey.DownloadedEpisodesFolder.ToString(), value); }
}
public bool UseSeasonFolder
{
get { return GetValueBoolean("UseSeasonFolder", true); }
set { SetValue("UseSeasonFolder", value); }
}
public string SeasonFolderFormat
{
get { return GetValue("SeasonFolderFormat", "Season {season}"); }
set { SetValue("SeasonFolderFormat", value); }
}
public bool AutoUnmonitorPreviouslyDownloadedEpisodes
{
get { return GetValueBoolean("AutoUnmonitorPreviouslyDownloadedEpisodes"); }

@ -20,8 +20,6 @@ namespace NzbDrone.Core.Configuration
SabPriorityType SabOlderTvPriority { get; set; }
Boolean SabUseSsl { get; set; }
String DownloadedEpisodesFolder { get; set; }
bool UseSeasonFolder { get; set; }
string SeasonFolderFormat { get; set; }
bool AutoUnmonitorPreviouslyDownloadedEpisodes { get; set; }
int Retention { get; set; }
DownloadClientType DownloadClient { get; set; }

@ -0,0 +1,56 @@
using System;
using System.Data;
using FluentMigrator;
using NzbDrone.Core.Datastore.Migration.Framework;
namespace NzbDrone.Core.Datastore.Migration
{
[Migration(30)]
public class add_season_folder_format_to_naming_config : NzbDroneMigrationBase
{
protected override void MainDbUpgrade()
{
Alter.Table("NamingConfig").AddColumn("SeasonFolderFormat").AsString().Nullable();
Execute.WithConnection(ConvertConfig);
Execute.Sql("DELETE FROM Config WHERE [Key] = 'seasonfolderformat'");
Execute.Sql("DELETE FROM Config WHERE [Key] = 'useseasonfolder'");
}
private void ConvertConfig(IDbConnection conn, IDbTransaction tran)
{
using (IDbCommand namingConfigCmd = conn.CreateCommand())
{
namingConfigCmd.Transaction = tran;
namingConfigCmd.CommandText = @"SELECT [Value] FROM Config WHERE [Key] = 'seasonfolderformat'";
var seasonFormat = "Season {season}";
using (IDataReader namingConfigReader = namingConfigCmd.ExecuteReader())
{
while (namingConfigReader.Read())
{
//only getting one column, so its index is 0
seasonFormat = namingConfigReader.GetString(0);
seasonFormat = seasonFormat.Replace("%sn", "{Series Title}")
.Replace("%s.n", "{Series.Title}")
.Replace("%s", "{season}")
.Replace("%0s", "{season:00}")
.Replace("%e", "{episode}")
.Replace("%0e", "{episode:00}");
}
}
using (IDbCommand updateCmd = conn.CreateCommand())
{
var text = String.Format("UPDATE NamingConfig " +
"SET SeasonFolderFormat = '{0}'",
seasonFormat);
updateCmd.Transaction = tran;
updateCmd.CommandText = text;
updateCmd.ExecuteNonQuery();
}
}
}
}
}

@ -1,54 +0,0 @@
using System;
using System.Data;
using FluentMigrator;
using NzbDrone.Core.Datastore.Migration.Framework;
namespace NzbDrone.Core.Datastore.Migration
{
[Migration(30)]
public class update_series_folder_format : NzbDroneMigrationBase
{
protected override void MainDbUpgrade()
{
Execute.WithConnection(ConvertConfig);
}
private void ConvertConfig(IDbConnection conn, IDbTransaction tran)
{
using (IDbCommand namingConfigCmd = conn.CreateCommand())
{
namingConfigCmd.Transaction = tran;
namingConfigCmd.CommandText = @"SELECT * FROM Config WHERE [Key] = 'seasonfolderformat'";
using (IDataReader namingConfigReader = namingConfigCmd.ExecuteReader())
{
var valueIndex = namingConfigReader.GetOrdinal("[Value]");
while (namingConfigReader.Read())
{
var value = namingConfigReader.GetString(valueIndex);
value = value.Replace("%sn", "{Series Title}")
.Replace("%s.n", "{Series.Title}")
.Replace("%s", "{season}")
.Replace("%0s", "{season:00}")
.Replace("%e", "{episode}")
.Replace("%0e", "{episode:00}");
using (IDbCommand updateCmd = conn.CreateCommand())
{
var text = String.Format("UPDATE Config " +
"SET [VALUE] = '{0}'" +
"WHERE [Key] = 'seasonfolderformat'",
value);
updateCmd.Transaction = tran;
updateCmd.CommandText = text;
updateCmd.ExecuteNonQuery();
}
}
}
}
}
}
}

@ -186,8 +186,8 @@
</Compile>
<Compile Include="Datastore\Migration\028_add_blacklist_table.cs" />
<Compile Include="Datastore\Migration\029_add_formats_to_naming_config.cs" />
<Compile Include="Datastore\Migration\030_update_season_folder_format.cs" />
<Compile Include="Datastore\Migration\031_delete_old_naming_config_columns.cs" />
<Compile Include="Datastore\Migration\030_add_season_folder_format_to_naming_config.cs" />
<Compile Include="Datastore\Migration\Framework\MigrationContext.cs" />
<Compile Include="Datastore\Migration\Framework\MigrationController.cs" />
<Compile Include="Datastore\Migration\Framework\MigrationExtension.cs" />

@ -163,10 +163,11 @@ namespace NzbDrone.Core.Organizer
else
{
var nameSpec = _namingConfigService.GetConfig();
var tokenValues = new Dictionary<string, string>(FilenameBuilderTokenEqualityComparer.Instance);
tokenValues.Add("{Series Title}", series.Title);
seasonFolder = ReplaceSeasonTokens(_configService.SeasonFolderFormat, seasonNumber);
seasonFolder = ReplaceSeasonTokens(nameSpec.SeasonFolderFormat, seasonNumber);
seasonFolder = ReplaceTokens(seasonFolder, tokenValues);
}

@ -13,7 +13,8 @@ namespace NzbDrone.Core.Organizer
RenameEpisodes = false,
MultiEpisodeStyle = 0,
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}",
SeasonFolderFormat = "Season {season}"
};
}
}
@ -22,5 +23,6 @@ namespace NzbDrone.Core.Organizer
public int MultiEpisodeStyle { get; set; }
public string StandardEpisodeFormat { get; set; }
public string DailyEpisodeFormat { get; set; }
public string SeasonFolderFormat { get; set; }
}
}

@ -71,8 +71,6 @@ namespace NzbDrone.Core.Tv
newSeries.Monitored = true;
newSeries.CleanTitle = Parser.Parser.CleanSeriesTitle(newSeries.Title);
newSeries.SeasonFolder = _configService.UseSeasonFolder;
_seriesRepository.Insert(newSeries);
_eventAggregator.PublishEvent(new SeriesAddedEvent(newSeries));

@ -1,4 +1,4 @@
<select class="span2 x-starting-season">
<select class="starting-season x-starting-season">
{{#each this}}
{{#if_eq seasonNumber compare="0"}}
<option value="{{seasonNumber}}">Specials</option>

@ -22,6 +22,7 @@ define(
ui: {
qualityProfile: '.x-quality-profile',
rootFolder : '.x-root-folder',
seasonFolder : '.x-season-folder',
addButton : '.x-add',
overview : '.x-overview',
startingSeason: '.x-starting-season'
@ -30,7 +31,8 @@ define(
events: {
'click .x-add' : '_addSeries',
'change .x-quality-profile': '_qualityProfileChanged',
'change .x-root-folder' : '_rootFolderChanged'
'change .x-root-folder' : '_rootFolderChanged',
'change .x-season-folder' : '_seasonFolderChanged'
},
initialize: function () {
@ -51,6 +53,7 @@ define(
var defaultQuality = Config.getValue(Config.Keys.DefaultQualityProfileId);
var defaultRoot = Config.getValue(Config.Keys.DefaultRootFolderId);
var useSeasonFolder = Config.getValueBoolean(Config.Keys.UseSeasonFolder, true);
if (QualityProfiles.get(defaultQuality)) {
this.ui.qualityProfile.val(defaultQuality);
@ -60,6 +63,8 @@ define(
this.ui.rootFolder.val(defaultRoot);
}
this.ui.seasonFolder.prop('checked', useSeasonFolder);
var minSeasonNotZero = _.min(_.reject(this.model.get('seasons'), { seasonNumber: 0 }), 'seasonNumber');
if (minSeasonNotZero) {
@ -91,15 +96,24 @@ define(
if (options.key === Config.Keys.DefaultQualityProfileId) {
this.ui.qualityProfile.val(options.value);
}
else if (options.key === Config.Keys.DefaultRootFolderId) {
this.ui.rootFolder.val(options.value);
}
else if (options.key === Config.Keys.UseSeasonFolder) {
this.ui.seasonFolder.prop('checked', options.value);
}
},
_qualityProfileChanged: function () {
Config.setValue(Config.Keys.DefaultQualityProfileId, this.ui.qualityProfile.val());
},
_seasonFolderChanged: function () {
Config.setValue(Config.Keys.UseSeasonFolder, this.ui.seasonFolder.prop('checked'));
},
_rootFolderChanged: function () {
var rootFolderValue = this.ui.rootFolder.val();
if (rootFolderValue === 'addNew') {
@ -125,16 +139,17 @@ define(
var quality = this.ui.qualityProfile.val();
var rootFolderPath = this.ui.rootFolder.children(':selected').text();
var startingSeason = this.ui.startingSeason.val();
var seasonFolder = this.ui.seasonFolder.prop('checked');
this.model.set('qualityProfileId', quality);
this.model.set('rootFolderPath', rootFolderPath);
this.model.setSeasonPass(startingSeason);
this.model.set('seasonFolder', seasonFolder);
var self = this;
SeriesCollection.add(this.model);
var promise = this.model.save();
promise.done(function () {
@ -159,7 +174,6 @@ define(
}
});
AsValidatedView.apply(view);
return view;

@ -32,6 +32,14 @@
{{> StartingSeasonSelectionPartial seasons}}
{{> QualityProfileSelectionPartial qualityProfiles}}
<label class="checkbox-button" title="Use season folders">
<input type="checkbox" class="x-season-folder"/>
<div class="btn btn-primary btn-icon-only">
<i class="icon-folder-close"></i>
</div>
</label>
<span class="btn btn-success x-add add-series pull-right"> Add
<i class="icon-plus"></i>
</span>

@ -91,6 +91,18 @@
.add-series {
margin-left : 20px;
}
.checkbox {
width : 100px;
margin-left : 0px;
display : inline-block;
padding-top : 0px;
margin-bottom : 0px;
}
.starting-season {
width: 140px;
}
}
}
@ -129,4 +141,4 @@ li.add-new:hover {
overflow: auto;
max-height: 300px;
}
}
}

@ -9,7 +9,8 @@ define(
},
Keys : {
DefaultQualityProfileId: 'DefaultQualityProfileId',
DefaultRootFolderId: 'DefaultRootFolderId'
DefaultRootFolderId: 'DefaultRootFolderId',
UseSeasonFolder: 'UseSeasonFolder'
},
getValueBoolean: function (key, defaultValue) {

@ -0,0 +1,28 @@
@import "Bootstrap/variables";
@import "Bootstrap/mixins";
.checkbox-button div {
display: none;
}
@media only screen {
.checkbox-button {
input {
position: absolute;
opacity: 0;
z-index: 5;
}
div {
display: block;
}
.btn {
.buttonBackground(@btnDangerBackground, @btnDangerBackgroundHighlight);
}
input:first-of-type:checked ~ .btn {
.buttonBackground(@btnPrimaryBackground, @btnPrimaryBackgroundHighlight);
}
}
}

@ -7,6 +7,7 @@
@import "Backgrid/backgrid";
@import "prefixer";
@import "icons";
@import "checkbox-button";
@import "spinner";
@import "legend";
@import "../Shared/Styles/clickable";

@ -104,6 +104,17 @@
</div>
</div>
<div class="control-group">
<label class="control-label">Season Folder Format</label>
<div class="controls">
<input type="text" placeholder="Season {season}" name="seasonFolderFormat"/>
<span class="help-inline">
<i class="icon-question-sign" title="How should season folders be named? Please see the wiki for customization options"/>
</span>
</div>
</div>
<div class="control-group">
<label class="control-label">Single Episode Example</label>

@ -1,7 +1,7 @@
<fieldset>
<fieldset class="advanced-setting">
<legend>Folders</legend>
<div class="control-group advanced-setting">
<div class="control-group">
<label class="control-label">Create empty series folders</label>
<div class="controls">
@ -21,33 +21,4 @@
</span>
</div>
</div>
<!--TODO: Remove this and move it to Add Series-->
<div class="control-group">
<label class="control-label">Use Season Folder</label>
<div class="controls">
<label class="checkbox toggle well">
<input type="checkbox" name="useSeasonFolder"/>
<p>
<span>Yes</span>
<span>No</span>
</p>
<div class="btn btn-primary slide-button"/>
</label>
</div>
</div>
<div class="control-group">
<label class="control-label">Season Folder Format</label>
<div class="controls">
<input type="text" placeholder="Season {season}" name="seasonFolderFormat"/>
<span class="help-inline">
<i class="icon-question-sign" title="How should season folders be named? Please see the wiki for customization options"/>
</span>
</div>
</div>
</fieldset>

Loading…
Cancel
Save