mirror of
https://github.com/Radarr/Radarr.git
synced 2024-09-11 03:52:33 +02:00
Added examples to naming settings
This commit is contained in:
parent
a5e8452840
commit
fded4cf7f3
71
NzbDrone.Api/Naming/NamingModule.cs
Normal file
71
NzbDrone.Api/Naming/NamingModule.cs
Normal file
@ -0,0 +1,71 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using NzbDrone.Api.Commands;
|
||||
using NzbDrone.Api.Extensions;
|
||||
using NzbDrone.Common.Messaging;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Organizer;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Tv;
|
||||
using Omu.ValueInjecter;
|
||||
|
||||
namespace NzbDrone.Api.Naming
|
||||
{
|
||||
public class NamingModule : NzbDroneRestModule<NamingResource>
|
||||
{
|
||||
private readonly IBuildFileNames _buildFileNames;
|
||||
|
||||
public NamingModule(IBuildFileNames buildFileNames)
|
||||
:base("naming")
|
||||
{
|
||||
_buildFileNames = buildFileNames;
|
||||
CreateResource = GetExamples;
|
||||
}
|
||||
|
||||
private NamingResource GetExamples(NamingResource resource)
|
||||
{
|
||||
var nameSpec = new NamingConfig();
|
||||
nameSpec.InjectFrom(resource);
|
||||
|
||||
var series = new Core.Tv.Series
|
||||
{
|
||||
SeriesType = SeriesTypes.Standard,
|
||||
Title = "Series Title"
|
||||
};
|
||||
|
||||
var episode1 = new Episode
|
||||
{
|
||||
SeasonNumber = 1,
|
||||
EpisodeNumber = 1,
|
||||
Title = "Episode Title (1)"
|
||||
};
|
||||
|
||||
var episode2 = new Episode
|
||||
{
|
||||
SeasonNumber = 1,
|
||||
EpisodeNumber = 2,
|
||||
Title = "Episode Title (2)"
|
||||
};
|
||||
|
||||
var episodeFile = new EpisodeFile
|
||||
{
|
||||
Quality = new QualityModel(Quality.HDTV720p),
|
||||
Path = @"C:\Test\Series.Title.S01E01.hdtv.avi"
|
||||
};
|
||||
|
||||
resource.SingleEpisodeExample = _buildFileNames.BuildFilename(new List<Episode> { episode1 },
|
||||
series,
|
||||
episodeFile,
|
||||
nameSpec);
|
||||
|
||||
episodeFile.Path = @"C:\Test\Series.Title.S01E01-E02.hdtv.avi";
|
||||
|
||||
resource.MultiEpisodeExample = _buildFileNames.BuildFilename(new List<Episode> { episode1, episode2 },
|
||||
series,
|
||||
episodeFile,
|
||||
nameSpec);
|
||||
|
||||
return resource;
|
||||
}
|
||||
}
|
||||
}
|
19
NzbDrone.Api/Naming/NamingResource.cs
Normal file
19
NzbDrone.Api/Naming/NamingResource.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using NzbDrone.Api.REST;
|
||||
|
||||
namespace NzbDrone.Api.Naming
|
||||
{
|
||||
public class NamingResource : RestResource
|
||||
{
|
||||
public bool RenameEpisodes { get; set; }
|
||||
public string Separator { get; set; }
|
||||
public int NumberStyle { get; set; }
|
||||
public bool IncludeSeriesTitle { get; set; }
|
||||
public bool IncludeEpisodeTitle { get; set; }
|
||||
public bool IncludeQuality { get; set; }
|
||||
public int MultiEpisodeStyle { get; set; }
|
||||
public bool ReplaceSpaces { get; set; }
|
||||
|
||||
public string SingleEpisodeExample { get; set; }
|
||||
public string MultiEpisodeExample { get; set; }
|
||||
}
|
||||
}
|
@ -117,6 +117,8 @@
|
||||
<Compile Include="Mapping\ResourceMappingException.cs" />
|
||||
<Compile Include="Mapping\ValueInjectorExtensions.cs" />
|
||||
<Compile Include="Missing\MissingModule.cs" />
|
||||
<Compile Include="Naming\NamingResource.cs" />
|
||||
<Compile Include="Naming\NamingModule.cs" />
|
||||
<Compile Include="Notifications\NotificationSchemaModule.cs" />
|
||||
<Compile Include="Notifications\NotificationModule.cs" />
|
||||
<Compile Include="Notifications\NotificationResource.cs" />
|
||||
|
@ -13,6 +13,7 @@ namespace NzbDrone.Core.Organizer
|
||||
public interface IBuildFileNames
|
||||
{
|
||||
string BuildFilename(IList<Episode> episodes, Series series, EpisodeFile episodeFile);
|
||||
string BuildFilename(IList<Episode> episodes, Series series, EpisodeFile episodeFile, NamingConfig namingConfig);
|
||||
string BuildFilePath(Series series, int seasonNumber, string fileName, string extension);
|
||||
}
|
||||
|
||||
@ -67,6 +68,11 @@ public string BuildFilename(IList<Episode> episodes, Series series, EpisodeFile
|
||||
{
|
||||
var nameSpec = _namingConfigService.GetConfig();
|
||||
|
||||
return BuildFilename(episodes, series, episodeFile, nameSpec);
|
||||
}
|
||||
|
||||
public string BuildFilename(IList<Episode> episodes, Series series, EpisodeFile episodeFile, NamingConfig nameSpec)
|
||||
{
|
||||
if (!nameSpec.RenameEpisodes)
|
||||
{
|
||||
if (String.IsNullOrWhiteSpace(episodeFile.SceneName))
|
||||
|
@ -10,7 +10,9 @@ define(
|
||||
|
||||
ui: {
|
||||
namingOptions : '.x-naming-options',
|
||||
renameEpisodesCheckbox: '.x-rename-episodes'
|
||||
renameEpisodesCheckbox: '.x-rename-episodes',
|
||||
singleEpisodeExample : '.x-single-episode-example',
|
||||
multiEpisodeExample : '.x-multi-episode-example'
|
||||
},
|
||||
|
||||
events: {
|
||||
@ -21,6 +23,9 @@ define(
|
||||
if(!this.model.get('renameEpisodes')){
|
||||
this.ui.namingOptions.hide();
|
||||
}
|
||||
|
||||
this.listenTo(this.model, 'change', this._buildExamples);
|
||||
this._buildExamples();
|
||||
},
|
||||
|
||||
_setNamingOptionsVisibility: function () {
|
||||
@ -32,6 +37,24 @@ define(
|
||||
else {
|
||||
this.ui.namingOptions.slideUp();
|
||||
}
|
||||
},
|
||||
|
||||
_buildExamples: function () {
|
||||
var self = this;
|
||||
|
||||
var data = this.model.toJSON();
|
||||
data.id = 0;
|
||||
|
||||
var promise = $.ajax({
|
||||
type: 'POST',
|
||||
url : window.ApiRoot + '/naming',
|
||||
data: JSON.stringify(data)
|
||||
});
|
||||
|
||||
promise.done(function (result) {
|
||||
self.ui.singleEpisodeExample.html(result.singleEpisodeExample);
|
||||
self.ui.multiEpisodeExample.html(result.multiEpisodeExample);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -129,4 +129,20 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<label class="control-label">Single Episode Example</label>
|
||||
|
||||
<div class="controls">
|
||||
<span class="x-single-episode-example naming-example"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<label class="control-label">Multi-Episode Example</label>
|
||||
|
||||
<div class="controls">
|
||||
<span class="x-multi-episode-example naming-example"></span>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
@ -24,9 +24,9 @@
|
||||
|
||||
<div class="controls">
|
||||
<input type="text" placeholder="Season %s" name="seasonFolderFormat"/>
|
||||
<span class="help-inline">
|
||||
<i class="icon-question-sign" title="How should season folders be named? (Use %0s to pad to two digits, %sn for Series Name)"/>
|
||||
</span>
|
||||
<span class="help-inline">
|
||||
<i class="icon-question-sign" title="How should season folders be named? (Use %0s to pad to two digits, %sn for Series Name)"/>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
@ -38,4 +38,9 @@ li.save-and-add:hover {
|
||||
i {
|
||||
.clickable;
|
||||
}
|
||||
}
|
||||
|
||||
.naming-example {
|
||||
display: inline-block;
|
||||
margin-top: 5px;
|
||||
}
|
Loading…
Reference in New Issue
Block a user