From d3ef917ee2a5da84679fbb55b890257933e35cb7 Mon Sep 17 00:00:00 2001 From: Matt McManis Date: Fri, 22 Feb 2019 19:31:59 -0800 Subject: [PATCH] v0.5.9.8-alpha Fixed Remove Words Filter Fixed Replace Words Filter --- .version | 2 +- source/Tanto/Tanto/Filter.cs | 64 +++++++------------ source/Tanto/Tanto/Properties/AssemblyInfo.cs | 4 +- 3 files changed, 26 insertions(+), 44 deletions(-) diff --git a/.version b/.version index cfbf098..414b492 100644 --- a/.version +++ b/.version @@ -1 +1 @@ -0.5.9.6-alpha \ No newline at end of file +0.5.9.8-alpha \ No newline at end of file diff --git a/source/Tanto/Tanto/Filter.cs b/source/Tanto/Tanto/Filter.cs index 4bc0dd8..6eaadb8 100644 --- a/source/Tanto/Tanto/Filter.cs +++ b/source/Tanto/Tanto/Filter.cs @@ -117,7 +117,6 @@ public static String FilterFileName(MainWindow mainwindow, string filename) && mainwindow.cbxFilterHyphens.IsChecked == true) { // remove dash, preserve hyphens - //filename = Regex.Replace(filename, @"((?<=[\s\.])\-+)|(\-+(?=[\s\.]))", "").Trim(); filename = Regex.Replace(filename, @"\b(-+)\b|-", "$1").Trim(); // multiple dashes to single dash filename = Regex.Replace(filename, "[-]{2,}", "").Trim(); @@ -131,20 +130,6 @@ public static String FilterFileName(MainWindow mainwindow, string filename) filename = Regex.Replace(filename, @"(\((1|2)\d?\d?\d?\))", ""); } - //// ------------------------- - //// Remove Episode Numbering - //// ------------------------- - //if (mainwindow.cbxFilterRemoveEpisodeNumbering.IsChecked == true) - //{ - // //S000E000, EP000, E000, 000x000, 000v000, 000, 000v0-9 - // filename = Regex.Replace( - // filename - // , @"(?i)\b(S\d\d\d?E\d\d\d?|(EP|EP((\s*)|-))\d\d\d?|E\d\d\d?|(? removeChars = new List(mainwindow.tbxRemoveChars.Text.Split(',')); List removeCharsEscaped = new List(); @@ -264,8 +244,10 @@ public static String FilterRemove(MainWindow mainwindow, string filename) // ------------------------- // Remove Between Characters // ------------------------- - if (mainwindow.tbxRemoveRangeStart.Text != string.Empty - && mainwindow.tbxRemoveRangeEnd.Text != string.Empty) + //if (mainwindow.tbxRemoveRangeStart.Text != string.Empty + // && mainwindow.tbxRemoveRangeEnd.Text != string.Empty) + if (!string.IsNullOrWhiteSpace(mainwindow.tbxRemoveRangeStart.Text) && + !string.IsNullOrWhiteSpace(mainwindow.tbxRemoveRangeEnd.Text)) { try { @@ -292,7 +274,7 @@ public static String FilterRemove(MainWindow mainwindow, string filename) { filename = Regex.Replace( filename - , @"(?i)(\[).*?(\])|(\(*)(480p|576p|720p|1080p|2k|4k|8k|60fps|DVD|BD|BRD|Bluray|Blu-Ray|WebDL|Web-DL|WebRip|Web-Rip|RAW|HEVC|(h|x)(265|264)|AV1|VP8|VP9|Theora|AAC|AC3|Vorbis|Opus|FLAC|MP3|(DTS\s?|DD\s?)(5\.1|7\.1)(\s?CH)?|(2|6|5\.1|7\.1)\s?CH|Dual-Audio|Multi-Sub|English Dub)(\)*)(\,*)" + , @"(?i)(\[).*?(\])|(\(*)(480p|576p|720p|1080p|2k|4k|8k|60fps|DVD|BD|BRD|Bluray|Blu-Ray|BrRip|WebDL|Web-DL|WebRip|Web-Rip|RAW|HEVC|(h|x)(265|264)|AV1|VP8|VP9|Theora|AAC|AC3|Vorbis|Opus|FLAC|MP3|(DTS\s?|DD\s?)(5\.1|7\.1)(\s?CH)?|(2|6|5\.1|7\.1)\s?CH|Dual-Audio|Multi-Sub|English Dub)(\)*)(\,*)" , "" , RegexOptions.IgnoreCase ); @@ -322,42 +304,42 @@ public static String FilterRemove(MainWindow mainwindow, string filename) /// public static String FilterReplace(MainWindow mainwindow, string filename) { - // Replace These Words With - if (mainwindow.tbxReplaceWords.Text != string.Empty) + // Replace These Characters With + if (!string.IsNullOrWhiteSpace(mainwindow.tbxReplaceChars.Text)) { try { - string words = mainwindow.tbxReplaceWords.Text.Replace(",", "|"); - string replacement = mainwindow.tbxReplaceWordsWith.Text; + string characters = mainwindow.tbxReplaceChars.Text.Replace(",", "|"); + string replacement = mainwindow.tbxReplaceCharsWith.Text; - string regex = @"\b(" + words + @")\b"; + string regex = characters; filename = Regex.Replace(filename, Regex.Escape(regex), Regex.Escape(replacement)); } catch { - MessageBox.Show("Could not replace words.", + MessageBox.Show("Could not replace characters.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } - // Replace These Characters With - if (mainwindow.tbxReplaceChars.Text != string.Empty) + // Replace These Words With + if (!string.IsNullOrWhiteSpace(mainwindow.tbxReplaceWords.Text)) { try { - string characters = mainwindow.tbxReplaceChars.Text.Replace(",", "|"); - string replacement = mainwindow.tbxReplaceCharsWith.Text; + string words = mainwindow.tbxReplaceWords.Text.Replace(",", "|"); + string replacement = mainwindow.tbxReplaceWordsWith.Text; - string regex = characters; + string regex = @"\b(" + words + @")\b"; - filename = Regex.Replace(filename, Regex.Escape(regex), Regex.Escape(replacement)); + filename = Regex.Replace(filename, regex, replacement); } catch { - MessageBox.Show("Could not replace characters.", + MessageBox.Show("Could not replace words.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); @@ -365,7 +347,7 @@ public static String FilterReplace(MainWindow mainwindow, string filename) } // Replace Spaces With - if (mainwindow.tbxReplaceSpacesWith.Text != string.Empty) + if (!string.IsNullOrWhiteSpace(mainwindow.tbxReplaceSpacesWith.Text)) { try { diff --git a/source/Tanto/Tanto/Properties/AssemblyInfo.cs b/source/Tanto/Tanto/Properties/AssemblyInfo.cs index d9bfab3..c06b903 100644 --- a/source/Tanto/Tanto/Properties/AssemblyInfo.cs +++ b/source/Tanto/Tanto/Properties/AssemblyInfo.cs @@ -51,5 +51,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.5.9.7")] -[assembly: AssemblyFileVersion("0.5.9.7")] +[assembly: AssemblyVersion("0.5.9.8")] +[assembly: AssemblyFileVersion("0.5.9.8")]