summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrakeWPF/Helpers/AutoNameHelper.cs
diff options
context:
space:
mode:
authorsr55 <[email protected]>2016-06-09 20:46:33 +0100
committersr55 <[email protected]>2016-06-09 20:46:33 +0100
commit2002aa9754292c08ae831051d4c6aa9268753593 (patch)
tree0ce6b6b5103ace7ce3becf5b45fb05ec65ff3ebc /win/CS/HandBrakeWPF/Helpers/AutoNameHelper.cs
parentcea9d238dbc4c09788604a15672145bde5fad29e (diff)
WinGui: Add {preset} to autoname options. This is a non-live option meaning it only changes when the title changes. (Same as {date} {time} {quality} {bitrate}). Implements #156
Diffstat (limited to 'win/CS/HandBrakeWPF/Helpers/AutoNameHelper.cs')
-rw-r--r--win/CS/HandBrakeWPF/Helpers/AutoNameHelper.cs17
1 files changed, 11 insertions, 6 deletions
diff --git a/win/CS/HandBrakeWPF/Helpers/AutoNameHelper.cs b/win/CS/HandBrakeWPF/Helpers/AutoNameHelper.cs
index a0fdbb0dc..ec158e751 100644
--- a/win/CS/HandBrakeWPF/Helpers/AutoNameHelper.cs
+++ b/win/CS/HandBrakeWPF/Helpers/AutoNameHelper.cs
@@ -19,6 +19,7 @@ namespace HandBrakeWPF.Helpers
using HandBrakeWPF.Extensions;
using HandBrakeWPF.Services.Interfaces;
+ using HandBrakeWPF.Services.Presets.Model;
using EncodeTask = HandBrakeWPF.Services.Encode.Model.EncodeTask;
using OutputFormat = HandBrakeWPF.Services.Encode.Model.Models.OutputFormat;
@@ -41,7 +42,7 @@ namespace HandBrakeWPF.Helpers
/// <returns>
/// The Generated FileName
/// </returns>
- public static string AutoName(EncodeTask task, string sourceOrLabelName)
+ public static string AutoName(EncodeTask task, string sourceOrLabelName, Preset presetName)
{
IUserSettingService userSettingService = IoC.Get<IUserSettingService>();
if (task.Destination == null)
@@ -54,6 +55,7 @@ namespace HandBrakeWPF.Helpers
{
// Get the Source Name and remove any invalid characters
string sourceName = Path.GetInvalidFileNameChars().Aggregate(sourceOrLabelName, (current, character) => current.Replace(character.ToString(), string.Empty));
+ string sanitisedPresetName = presetName != null ? Path.GetInvalidFileNameChars().Aggregate(presetName.Name, (current, character) => current.Replace(character.ToString(), string.Empty)) : string.Empty;
// Remove Underscores
if (userSettingService.GetUserSetting<bool>(UserSettingConstants.AutoNameRemoveUnderscore))
@@ -88,11 +90,14 @@ namespace HandBrakeWPF.Helpers
if (userSettingService.GetUserSetting<string>(UserSettingConstants.AutoNameFormat) != string.Empty)
{
destinationFilename = userSettingService.GetUserSetting<string>(UserSettingConstants.AutoNameFormat);
- destinationFilename = destinationFilename.Replace("{source}", sourceName)
- .Replace(Constants.Title, dvdTitle)
- .Replace(Constants.Chapters, combinedChapterTag)
- .Replace(Constants.Date, DateTime.Now.Date.ToShortDateString().Replace('/', '-'))
- .Replace(Constants.Time, DateTime.Now.ToString("HH:mm"));
+ destinationFilename =
+ destinationFilename
+ .Replace("{source}", sourceName)
+ .Replace(Constants.Title, dvdTitle)
+ .Replace(Constants.Chapters, combinedChapterTag)
+ .Replace(Constants.Date, DateTime.Now.Date.ToShortDateString().Replace('/', '-'))
+ .Replace(Constants.Time,DateTime.Now.ToString("HH:mm"))
+ .Replace(Constants.Preset, sanitisedPresetName);
if (task.VideoEncodeRateType == VideoEncodeRateType.ConstantQuality)
{