diff options
author | sr55 <[email protected]> | 2018-11-10 14:18:12 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2018-11-10 14:20:09 +0000 |
commit | 942f28023d46fab037058a22fcf305a533bb5373 (patch) | |
tree | adea56bec29961ff3728d543d92508849a8808ce | |
parent | aa03552c64ac34fbc3a79396a72df3cd37b6a6f2 (diff) |
WinGui: Make the Autoname macros case-insensitive. Fixes #1670
-rw-r--r-- | win/CS/HandBrakeWPF/Constants.cs | 68 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Extensions/StringExtensions.cs | 9 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Helpers/AutoNameHelper.cs | 21 |
3 files changed, 24 insertions, 74 deletions
diff --git a/win/CS/HandBrakeWPF/Constants.cs b/win/CS/HandBrakeWPF/Constants.cs index f13d8cb0f..20133278d 100644 --- a/win/CS/HandBrakeWPF/Constants.cs +++ b/win/CS/HandBrakeWPF/Constants.cs @@ -14,84 +14,32 @@ namespace HandBrakeWPF /// </summary>
public class Constants
{
- /// <summary>
- /// The appcast 64.
- /// </summary>
+ /* Appcast URLs */
public const string Appcast64 = "https://handbrake.fr/appcast.x86_64.xml";
-
- /// <summary>
- /// The appcast 32.
- /// </summary>
public const string AppcastUnstable64 = "https://handbrake.fr/appcast_unstable.x86_64.xml";
- /// <summary>
- /// The any.
- /// </summary>
+ /* Languages */
public const string Any = "(Any)";
-
- /// <summary>
- /// Undefined Language
- /// </summary>
public const string Undefined = "und";
- /// <summary>
- /// The chapters.
- /// </summary>
+ /* Autoname Contanstants */
public const string Chapters = "{chapters}";
-
- /// <summary>
- /// The title.
- /// </summary>
public const string Title = "{title}";
-
- /// <summary>
- /// The quality.
- /// </summary>
public const string Quality = "{quality}";
-
- /// <summary>
- /// The creation date of the new output file.
- /// </summary>
public const string Date = "{date}";
-
- /// <summary>
- /// The creation time of the new output file.
- /// </summary>
public const string Time = "{time}";
-
- /// <summary>
- /// The source creation date.
- /// </summary>
public const string CretaionDate = "{creation-date}";
-
- /// <summary>
- /// The source creation time.
- /// </summary>
public const string CreationTime = "{creation-time}";
-
- /// <summary>
- /// The bitrate.
- /// </summary>
public const string Bitrate = "{bitrate}";
-
- /// <summary>
- /// The preset.
- /// </summary>
public const string Preset = "{preset}";
+ public const string Source = "{source}";
- /// <summary>
- /// Preset Major Version
- /// </summary>
- public const string PresetVersionMajor = "11";
+ public const string SourcePath = "{source_path}";
+ public const string SourceFolderName = "{source_folder_name}";
- /// <summary>
- /// Preset Minor Version
- /// </summary>
+ /* Preset Versions */
+ public const string PresetVersionMajor = "11";
public const string PresetVersionMinor = "0";
-
- /// <summary>
- /// Preset Micro Version
- /// </summary>
public const string PresetVersionMicro = "0";
public const string FileScanMru = "FileScanMru";
diff --git a/win/CS/HandBrakeWPF/Extensions/StringExtensions.cs b/win/CS/HandBrakeWPF/Extensions/StringExtensions.cs index cf7e507aa..220d6f14d 100644 --- a/win/CS/HandBrakeWPF/Extensions/StringExtensions.cs +++ b/win/CS/HandBrakeWPF/Extensions/StringExtensions.cs @@ -10,10 +10,8 @@ namespace HandBrakeWPF.Extensions
{
using System.Globalization;
+ using System.Text.RegularExpressions;
- /// <summary>
- /// String Extensions
- /// </summary>
public static class StringExtensions
{
/// <summary>
@@ -36,5 +34,10 @@ namespace HandBrakeWPF.Extensions return 0;
}
+
+ public static string RegexReplace(this string input, string pattern, string repacelement)
+ {
+ return Regex.Replace(input, pattern, repacelement, RegexOptions.IgnoreCase);
+ }
}
}
diff --git a/win/CS/HandBrakeWPF/Helpers/AutoNameHelper.cs b/win/CS/HandBrakeWPF/Helpers/AutoNameHelper.cs index 4fd7ec1fc..0b000eff7 100644 --- a/win/CS/HandBrakeWPF/Helpers/AutoNameHelper.cs +++ b/win/CS/HandBrakeWPF/Helpers/AutoNameHelper.cs @@ -59,7 +59,6 @@ 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))
@@ -124,14 +123,14 @@ namespace HandBrakeWPF.Helpers {
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"))
- .Replace(Constants.CretaionDate, createDate)
- .Replace(Constants.CreationTime, createTime);
- // .Replace(Constants.Preset, sanitisedPresetName);
+ destinationFilename
+ .RegexReplace(Constants.Source, sourceName)
+ .RegexReplace(Constants.Title, dvdTitle)
+ .RegexReplace(Constants.Chapters, combinedChapterTag)
+ .RegexReplace(Constants.Date, DateTime.Now.Date.ToShortDateString().Replace('/', '-'))
+ .RegexReplace(Constants.Time, DateTime.Now.ToString("HH-mm"))
+ .RegexReplace(Constants.CretaionDate, createDate)
+ .RegexReplace(Constants.CreationTime, createTime);
if (task.VideoEncodeRateType == VideoEncodeRateType.ConstantQuality)
{
@@ -248,8 +247,8 @@ namespace HandBrakeWPF.Helpers }
// If there is an auto name path, use it...
- return userSettingService.GetUserSetting<string>(UserSettingConstants.AutoNamePath).Trim().StartsWith("{source_path}") ||
- (userSettingService.GetUserSetting<string>(UserSettingConstants.AutoNamePath).Contains("{source_folder_name}") ||
+ return userSettingService.GetUserSetting<string>(UserSettingConstants.AutoNamePath).Trim().StartsWith(Constants.SourcePath) ||
+ (userSettingService.GetUserSetting<string>(UserSettingConstants.AutoNamePath).Contains(Constants.SourceFolderName) ||
Directory.Exists(userSettingService.GetUserSetting<string>(UserSettingConstants.AutoNamePath).Trim()));
}
}
|