Update naming management

Still need to write BuildFileName() and BuildFilePath()
pull/38/head
Tim Turner 8 years ago
parent 49c7c033d9
commit 721767331b

@ -39,6 +39,8 @@ namespace NzbDrone.Api.Config
SharedValidator.RuleFor(c => c.AnimeEpisodeFormat).ValidAnimeEpisodeFormat();
SharedValidator.RuleFor(c => c.SeriesFolderFormat).ValidSeriesFolderFormat();
SharedValidator.RuleFor(c => c.SeasonFolderFormat).ValidSeasonFolderFormat();
SharedValidator.RuleFor(c => c.StandardMovieFormat).ValidMovieFormat();
SharedValidator.RuleFor(c => c.MovieFolderFormat).ValidMovieFolderFormat();
}
private void UpdateNamingConfig(NamingConfigResource resource)
@ -54,7 +56,13 @@ namespace NzbDrone.Api.Config
var nameSpec = _namingConfigService.GetConfig();
var resource = nameSpec.ToResource();
if (resource.StandardEpisodeFormat.IsNotNullOrWhiteSpace())
//if (resource.StandardEpisodeFormat.IsNotNullOrWhiteSpace())
//{
// var basicConfig = _filenameBuilder.GetBasicNamingConfig(nameSpec);
// basicConfig.AddToResource(resource);
//}
if (resource.StandardMovieFormat.IsNotNullOrWhiteSpace())
{
var basicConfig = _filenameBuilder.GetBasicNamingConfig(nameSpec);
basicConfig.AddToResource(resource);
@ -118,12 +126,16 @@ namespace NzbDrone.Api.Config
var animeEpisodeSampleResult = _filenameSampleService.GetAnimeSample(nameSpec);
var animeMultiEpisodeSampleResult = _filenameSampleService.GetAnimeMultiEpisodeSample(nameSpec);
//var movieSampleResult = _filenameSampleService.GetMovieSample(nameSpec);
var singleEpisodeValidationResult = _filenameValidationService.ValidateStandardFilename(singleEpisodeSampleResult);
var multiEpisodeValidationResult = _filenameValidationService.ValidateStandardFilename(multiEpisodeSampleResult);
var dailyEpisodeValidationResult = _filenameValidationService.ValidateDailyFilename(dailyEpisodeSampleResult);
var animeEpisodeValidationResult = _filenameValidationService.ValidateAnimeFilename(animeEpisodeSampleResult);
var animeMultiEpisodeValidationResult = _filenameValidationService.ValidateAnimeFilename(animeMultiEpisodeSampleResult);
//var standardMovieValidationResult = _filenameValidationService.ValidateStandardMovieFilename(movieSampleResult);
var validationFailures = new List<ValidationFailure>();
validationFailures.AddIfNotNull(singleEpisodeValidationResult);
@ -132,6 +144,8 @@ namespace NzbDrone.Api.Config
validationFailures.AddIfNotNull(animeEpisodeValidationResult);
validationFailures.AddIfNotNull(animeMultiEpisodeValidationResult);
//validationFailures.AddIfNotNull(standardMovieValidationResult);
if (validationFailures.Any())
{
throw new ValidationException(validationFailures.DistinctBy(v => v.PropertyName).ToArray());

@ -7,6 +7,8 @@ namespace NzbDrone.Api.Config
{
public bool RenameEpisodes { get; set; }
public bool ReplaceIllegalCharacters { get; set; }
public string StandardMovieFormat { get; set; }
public string MovieFolderFormat { get; set; }
public int MultiEpisodeStyle { get; set; }
public string StandardEpisodeFormat { get; set; }
public string DailyEpisodeFormat { get; set; }
@ -36,7 +38,9 @@ namespace NzbDrone.Api.Config
DailyEpisodeFormat = model.DailyEpisodeFormat,
AnimeEpisodeFormat = model.AnimeEpisodeFormat,
SeriesFolderFormat = model.SeriesFolderFormat,
SeasonFolderFormat = model.SeasonFolderFormat
SeasonFolderFormat = model.SeasonFolderFormat,
StandardMovieFormat = model.StandardMovieFormat,
MovieFolderFormat = model.MovieFolderFormat
//IncludeSeriesTitle
//IncludeEpisodeTitle
//IncludeQuality
@ -69,7 +73,9 @@ namespace NzbDrone.Api.Config
DailyEpisodeFormat = resource.DailyEpisodeFormat,
AnimeEpisodeFormat = resource.AnimeEpisodeFormat,
SeriesFolderFormat = resource.SeriesFolderFormat,
SeasonFolderFormat = resource.SeasonFolderFormat
SeasonFolderFormat = resource.SeasonFolderFormat,
StandardMovieFormat = resource.StandardMovieFormat,
MovieFolderFormat = resource.MovieFolderFormat
};
}
}

@ -9,5 +9,8 @@
public string AnimeMultiEpisodeExample { get; set; }
public string SeriesFolderExample { get; set; }
public string SeasonFolderExample { get; set; }
public string MovieExample { get; set; }
public string MovieFolderExample { get; set; }
}
}

@ -0,0 +1,92 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FluentMigrator;
using NzbDrone.Core.Datastore.Migration.Framework;
using System.Data;
namespace NzbDrone.Core.Datastore.Migration
{
[Migration(109)]
public class add_movie_formats_to_naming_config : NzbDroneMigrationBase
{
protected override void MainDbUpgrade()
{
Alter.Table("NamingConfig").AddColumn("StandardMovieFormat").AsString().Nullable();
Alter.Table("NamingConfig").AddColumn("MovieFolderFormat").AsString().Nullable();
Execute.WithConnection(ConvertConfig);
}
private void ConvertConfig(IDbConnection conn, IDbTransaction tran)
{
using (IDbCommand namingConfigCmd = conn.CreateCommand())
{
namingConfigCmd.Transaction = tran;
namingConfigCmd.CommandText = @"SELECT * FROM NamingConfig LIMIT 1";
using (IDataReader namingConfigReader = namingConfigCmd.ExecuteReader())
{
var separatorIndex = namingConfigReader.GetOrdinal("Separator");
var includeQualityIndex = namingConfigReader.GetOrdinal("IncludeQuality");
var replaceSpacesIndex = namingConfigReader.GetOrdinal("ReplaceSpaces");
while (namingConfigReader.Read())
{
var separator = namingConfigReader.GetString(separatorIndex);
var includeQuality = namingConfigReader.GetBoolean(includeQualityIndex);
var replaceSpaces = namingConfigReader.GetBoolean(replaceSpacesIndex);
// Output Settings
var movieTitlePattern = "";
var movieYearPattern = "({Release Year})";
var qualityFormat = " [{Quality Title}]";
if (replaceSpaces)
{
movieTitlePattern = "{Movie.Title}";
}
else
{
movieTitlePattern = "{Movie Title}";
}
movieTitlePattern += separator;
var standardMovieFormat = string.Format("{0}{1}{2}", movieTitlePattern,
movieYearPattern,
qualityFormat);
var movieFolderFormat = string.Format("{0}{1}", movieTitlePattern, movieYearPattern);
if (includeQuality)
{
if (replaceSpaces)
{
qualityFormat = ".[{Quality.Title}]";
}
movieFolderFormat += qualityFormat;
standardMovieFormat += qualityFormat;
}
using (IDbCommand updateCmd = conn.CreateCommand())
{
var text = string.Format("UPDATE NamingConfig " +
"SET StandardMovieFormat = '{0}', " +
"MovieFolderFormat = '{1}'",
standardMovieFormat,
movieFolderFormat);
updateCmd.Transaction = tran;
updateCmd.CommandText = text;
updateCmd.ExecuteNonQuery();
}
}
}
}
}
}
}

@ -286,6 +286,7 @@
<Compile Include="Datastore\Migration\098_remove_titans_of_tv.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Datastore\Migration\109_add_movie_formats_to_naming_config.cs" />
<Compile Include="Datastore\Migration\Framework\MigrationContext.cs" />
<Compile Include="Datastore\Migration\Framework\MigrationController.cs" />
<Compile Include="Datastore\Migration\Framework\MigrationDbFactory.cs" />

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
@ -58,6 +58,9 @@ namespace NzbDrone.Core.Organizer
public static readonly Regex SeriesTitleRegex = new Regex(@"(?<token>\{(?:Series)(?<separator>[- ._])(Clean)?Title\})",
RegexOptions.Compiled | RegexOptions.IgnoreCase);
public static readonly Regex MovieTitleRegex = new Regex(@"(?<token>\{(?:Movie)(?<separator>[- ._])(Clean)?Title\})",
RegexOptions.Compiled | RegexOptions.IgnoreCase);
private static readonly Regex FileNameCleanupRegex = new Regex(@"([- ._])(\1)+", RegexOptions.Compiled);
private static readonly Regex TrimSeparatorsRegex = new Regex(@"[- ._]$", RegexOptions.Compiled);

@ -41,6 +41,18 @@ namespace NzbDrone.Core.Organizer
ruleBuilder.SetValidator(new NotEmptyValidator(null));
return ruleBuilder.SetValidator(new RegularExpressionValidator(SeasonFolderRegex)).WithMessage("Must contain season number");
}
public static IRuleBuilderOptions<T, string> ValidMovieFolderFormat<T>(this IRuleBuilder<T, string> ruleBuilder)
{
ruleBuilder.SetValidator(new NotEmptyValidator(null));
return ruleBuilder.SetValidator(new RegularExpressionValidator(FileNameBuilder.MovieTitleRegex)).WithMessage("Must contain movie title");
}
public static IRuleBuilderOptions<T, string> ValidMovieFormat<T>(this IRuleBuilder<T, string> ruleBuilder)
{
ruleBuilder.SetValidator(new NotEmptyValidator(null));
return ruleBuilder.SetValidator(new RegularExpressionValidator(FileNameBuilder.MovieTitleRegex)).WithMessage("Must contain movie title");
}
}
public class ValidStandardEpisodeFormatValidator : PropertyValidator

@ -1,4 +1,4 @@
using NzbDrone.Core.Datastore;
using NzbDrone.Core.Datastore;
namespace NzbDrone.Core.Organizer
{
@ -13,7 +13,9 @@ namespace NzbDrone.Core.Organizer
DailyEpisodeFormat = "{Series Title} - {Air-Date} - {Episode Title} {Quality Full}",
AnimeEpisodeFormat = "{Series Title} - S{season:00}E{episode:00} - {Episode Title} {Quality Full}",
SeriesFolderFormat = "{Series Title}",
SeasonFolderFormat = "Season {season}"
SeasonFolderFormat = "Season {season}",
MovieFolderFormat = "{Movie Title}",
StandardMovieFormat = "{Movie Title} {Quality Full}",
};
public bool RenameEpisodes { get; set; }
@ -24,5 +26,7 @@ namespace NzbDrone.Core.Organizer
public string AnimeEpisodeFormat { get; set; }
public string SeriesFolderFormat { get; set; }
public string SeasonFolderFormat { get; set; }
public string StandardMovieFormat { get; set; }
public string MovieFolderFormat { get; set; }
}
}

@ -26,7 +26,7 @@ module.exports = Marionette.Layout.extend({
},
initialize : function(options) {
console.log(options)
console.log(options);
this.isExisting = options.isExisting;
this.collection = new AddMoviesCollection();
@ -125,7 +125,7 @@ module.exports = Marionette.Layout.extend({
}
else if (!this.isExisting) {
this.resultCollectionView.setExisting(options.movie.get('tmdbId'))
this.resultCollectionView.setExisting(options.movie.get('tmdbId'));
/*this.collection.term = '';
this.collection.reset();
this._clearResults();

@ -23,7 +23,7 @@ module.exports = Marionette.CollectionView.extend({
setExisting : function(tmdbid) {
var movies = this.collection.where({ tmdbId : tmdbid });
console.warn(movies)
console.warn(movies);
//debugger;
if (movies.length > 0) {
this.children.findByModel(movies[0])._configureTemplateHelpers();

@ -92,14 +92,14 @@ var view = Marionette.ItemView.extend({
_configureTemplateHelpers : function() {
var existingMovies = MoviesCollection.where({ tmdbId : this.model.get('tmdbId') });
console.log(existingMovies)
console.log(existingMovies);
if (existingMovies.length > 0) {
this.templateHelpers.existing = existingMovies[0].toJSON();
}
this.templateHelpers.profiles = Profiles.toJSON();
console.log(this.model)
console.log(this.templateHelpers.existing)
console.log(this.model);
console.log(this.templateHelpers.existing);
if (!this.model.get('isExisting')) {
this.templateHelpers.rootFolders = RootFolders.toJSON();
}
@ -245,14 +245,14 @@ var view = Marionette.ItemView.extend({
options.ignoreEpisodesWithoutFiles = true;
}
else if (monitor === 'latest') {
this.model.setSeasonPass(lastSeason.seasonNumber);
}
// else if (monitor === 'latest') {
// this.model.setSeasonPass(lastSeason.seasonNumber);
// }
else if (monitor === 'first') {
this.model.setSeasonPass(lastSeason.seasonNumber + 1);
this.model.setSeasonMonitored(firstSeason.seasonNumber);
}
// else if (monitor === 'first') {
// this.model.setSeasonPass(lastSeason.seasonNumber + 1);
// this.model.setSeasonMonitored(firstSeason.seasonNumber);
// }
else if (monitor === 'missing') {
options.ignoreEpisodesWithFiles = true;
@ -262,9 +262,9 @@ var view = Marionette.ItemView.extend({
options.ignoreEpisodesWithoutFiles = true;
}
else if (monitor === 'none') {
this.model.setSeasonPass(lastSeason.seasonNumber + 1);
}
// else if (monitor === 'none') {
// this.model.setSeasonPass(lastSeason.seasonNumber + 1);
// }
return options;
}

@ -17,7 +17,7 @@
</label>
<span class="help-inline-checkbox">
<i class="icon-sonarr-form-info" title="Episodes deleted from disk are automatically unmonitored in Sonarr"/>
<i class="icon-sonarr-form-info" title="Episodes deleted from disk are automatically unmonitored in Radarr"/>
</span>
</div>
</div>
@ -39,7 +39,7 @@
</label>
<span class="help-inline-checkbox">
<i class="icon-sonarr-form-info" title="Should Sonarr automatically upgrade to propers when available?"/>
<i class="icon-sonarr-form-info" title="Should Radarr automatically upgrade to propers when available?"/>
</span>
</div>
</div>

@ -1,8 +1,8 @@
<fieldset>
<legend>Episode Naming</legend>
<legend>Movie Naming</legend>
<div class="form-group">
<label class="col-sm-3 control-label">Rename Episodes</label>
<label class="col-sm-3 control-label">Rename Movies</label>
<div class="col-sm-8">
<div class="input-group">
@ -18,7 +18,7 @@
</label>
<span class="help-inline-checkbox">
<i class="icon-sonarr-form-warning" title="Sonarr will use the existing file name if set to no"/>
<i class="icon-sonarr-form-warning" title="Radarr will use the existing file name if set to no"/>
</span>
</div>
</div>
@ -51,25 +51,23 @@
<div class="basic-setting x-basic-naming"></div>
<div class="form-group advanced-setting">
<label class="col-sm-3 control-label">Standard Episode Format</label>
<label class="col-sm-3 control-label">Standard Movie Format</label>
<div class="col-sm-1 col-sm-push-8 help-inline">
<i class="icon-sonarr-form-info" title="" data-original-title="All caps or all lower-case can also be used"></i>
<a href="https://github.com/NzbDrone/NzbDrone/wiki/Sorting-and-Renaming" class="help-link" title="More information"><i class="icon-sonarr-form-info-link"/></a>
<a href="https://github.com/NzbDrone/NzbDrone/wiki/Sorting-and-Renaming" class="help-link" title="More information"><i class="icon-sonarr-form-info-link"/></a> <!-- TODO: Update wiki link -->
</div>
<div class="col-sm-8 col-sm-pull-1">
<div class="input-group x-helper-input">
<input type="text" class="form-control naming-format" name="standardEpisodeFormat" data-onkeyup="true" />
<input type="text" class="form-control naming-format" name="standardMovieFormat" data-onkeyup="true" />
<div class="input-group-btn btn-group x-naming-token-helper">
<button class="btn btn-icon-only dropdown-toggle" data-toggle="dropdown">
<i class="icon-sonarr-add"></i>
</button>
<ul class="dropdown-menu">
{{> SeriesTitleNamingPartial}}
{{> SeasonNamingPartial}}
{{> EpisodeNamingPartial}}
{{> EpisodeTitleNamingPartial}}
{{> MovieTitleNamingPartial}}
{{> ReleaseYearNamingPartial}}
{{> QualityNamingPartial}}
{{> MediaInfoNamingPartial}}
{{> ReleaseGroupNamingPartial}}
@ -81,7 +79,7 @@
</div>
</div>
<div class="form-group advanced-setting">
{{!--<div class="form-group advanced-setting">
<label class="col-sm-3 control-label">Daily Episode Format</label>
<div class="col-sm-1 col-sm-push-8 help-inline">
@ -111,9 +109,9 @@
</div>
</div>
</div>
</div>
</div>--}}
<div class="form-group advanced-setting">
{{!--<div class="form-group advanced-setting">
<label class="col-sm-3 control-label">Anime Episode Format</label>
<div class="col-sm-1 col-sm-push-8 help-inline">
@ -144,31 +142,32 @@
</div>
</div>
</div>
</div>
</div>--}}
<div class="form-group advanced-setting">
<label class="col-sm-3 control-label">Series Folder Format</label>
<label class="col-sm-3 control-label">Movie Folder Format</label>
<div class="col-sm-1 col-sm-push-8 help-inline">
<i class="icon-sonarr-form-info" title="" data-original-title="All caps or all lower-case can also be used. Only used when adding a new series."></i>
<i class="icon-sonarr-form-info" title="" data-original-title="All caps or all lower-case can also be used. Only used when adding a new movie."></i>
</div>
<div class="col-sm-8 col-sm-pull-1">
<div class="input-group x-helper-input">
<input type="text" class="form-control naming-format" name="seriesFolderFormat" data-onkeyup="true"/>
<input type="text" class="form-control naming-format" name="movieFolderFormat" data-onkeyup="true"/>
<div class="input-group-btn btn-group x-naming-token-helper">
<button class="btn btn-icon-only dropdown-toggle" data-toggle="dropdown">
<i class="icon-sonarr-add"></i>
</button>
<ul class="dropdown-menu">
{{> SeriesTitleNamingPartial}}
{{> MovieTitleNamingPartial}}
{{> ReleaseYearNamingPartial}}
</ul>
</div>
</div>
</div>
</div>
<div class="form-group">
{{!--<div class="form-group">
<label class="col-sm-3 control-label">Season Folder Format</label>
<div class="col-sm-8">
@ -186,9 +185,9 @@
</div>
</div>
</div>
</div>
</div>--}}
<div class="x-naming-options">
{{!--<div class="x-naming-options">
<div class="form-group">
<label class="col-sm-3 control-label">Multi-Episode Style</label>
@ -203,17 +202,17 @@
</select>
</div>
</div>
</div>
</div>--}}
<div class="form-group">
<label class="col-sm-3 control-label">Single Episode Example</label>
<label class="col-sm-3 control-label">Movie Example</label>
<div class="col-sm-8">
<p class="form-control-static x-single-episode-example naming-example"></p>
</div>
</div>
<div class="form-group">
{{!--<div class="form-group">
<label class="col-sm-3 control-label">Multi-Episode Example</label>
<div class="col-sm-8">
@ -242,21 +241,21 @@
<div class="col-sm-8">
<p class="form-control-static x-anime-multi-episode-example naming-example"></p>
</div>
</div>
</div>--}}
<div class="form-group">
<label class="col-sm-3 control-label">Series Folder Example</label>
<label class="col-sm-3 control-label">Movie Folder Example</label>
<div class="col-sm-8">
<p class="form-control-static x-series-folder-example naming-example"></p>
</div>
</div>
<div class="form-group">
{{!--<div class="form-group">
<label class="col-sm-3 control-label">Season Folder Example</label>
<div class="col-sm-8">
<p class="form-control-static x-season-folder-example naming-example"></p>
</div>
</div>
</div>--}}
</fieldset>

@ -0,0 +1,11 @@
<li class="dropdown-submenu">
<a href="#" tabindex="-1" data-token="Movie Title">Movie Title</a>
<ul class="dropdown-menu">
<li><a href="#" data-token="Movie Title">Movie Title</a></li>
<li><a href="#" data-token="Movie.Title">Movie.Title</a></li>
<li><a href="#" data-token="Movie_Title">Movie_Title</a></li>
<li><a href="#" data-token="Movie CleanTitle">Movie CleanTitle</a></li>
<li><a href="#" data-token="Movie.CleanTitle">Movie.CleanTitle</a></li>
<li><a href="#" data-token="Movie_CleanTitle">Movie_CleanTitle</a></li>
</ul>
</li>

@ -0,0 +1 @@
<li><a href="#" data-token="Release Year">Release Year</a></li>

@ -2,7 +2,7 @@
<legend>Folders</legend>
<div class="form-group">
<label class="col-sm-3 control-label">Create empty series folders</label>
<label class="col-sm-3 control-label">Create empty movie folders</label>
<div class="col-sm-9">
<div class="input-group">
@ -18,7 +18,7 @@
</label>
<span class="help-inline-checkbox">
<i class="icon-sonarr-form-info" title="Create missing series folders during disk scan"/>
<i class="icon-sonarr-form-info" title="Create missing movie folders during disk scan"/>
</span>
</div>
</div>
@ -46,7 +46,7 @@
</label>
<span class="help-inline-checkbox">
<i class="icon-sonarr-form-info" title="Use when drone is unable to detect free space from your series root folder"/>
<i class="icon-sonarr-form-info" title="Use when drone is unable to detect free space from your movies root folder"/>
</span>
</div>
</div>
@ -71,7 +71,7 @@
<span class="help-inline-checkbox">
<i class="icon-sonarr-form-info" title="Use Hardlinks when trying to copy files from torrents that are still being seeded"/>
<i class="icon-sonarr-form-warning" title="Occasionally, file locks may prevent renaming files that are being seeded. You may temporarily disable seeding and use Sonarr's rename function as a work around."/>
<i class="icon-sonarr-form-warning" title="Occasionally, file locks may prevent renaming files that are being seeded. You may temporarily disable seeding and use Radarr's rename function as a work around."/>
</span>
</div>
</div>

Loading…
Cancel
Save