aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBond_009 <bond.009@outlook.com>2020-01-11 20:31:59 +0100
committerBond_009 <bond.009@outlook.com>2020-01-11 22:17:05 +0100
commitdd254eddac4b805f0020e5899fb903ef10714527 (patch)
tree641aac9b1ef82b62b691ec0a38db05c13411a9e1
parentb1dc595be1a7cf331702fd645b1441ac86afa464 (diff)
Simplify CleanDateTimeParser
-rw-r--r--Emby.Naming/Video/CleanDateTimeParser.cs44
1 files changed, 2 insertions, 42 deletions
diff --git a/Emby.Naming/Video/CleanDateTimeParser.cs b/Emby.Naming/Video/CleanDateTimeParser.cs
index 9edb14a07..9723fb71a 100644
--- a/Emby.Naming/Video/CleanDateTimeParser.cs
+++ b/Emby.Naming/Video/CleanDateTimeParser.cs
@@ -1,9 +1,7 @@
#pragma warning disable CS1591
#pragma warning disable SA1600
-using System;
using System.Globalization;
-using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using Emby.Naming.Common;
@@ -23,47 +21,9 @@ namespace Emby.Naming.Video
}
public CleanDateTimeResult Clean(string name)
- {
- var originalName = name;
-
- try
- {
- var extension = Path.GetExtension(name) ?? string.Empty;
- // Check supported extensions
- if (!_options.VideoFileExtensions.Contains(extension, StringComparer.OrdinalIgnoreCase)
- && !_options.AudioFileExtensions.Contains(extension, StringComparer.OrdinalIgnoreCase))
- {
- // Dummy up a file extension because the expressions will fail without one
- // This is tricky because we can't just check Path.GetExtension for empty
- // If the input is "St. Vincent (2014)", it will produce ". Vincent (2014)" as the extension
- name += ".mkv";
- }
- }
- catch (ArgumentException)
- {
- }
-
- var result = _options.CleanDateTimeRegexes.Select(i => Clean(name, i))
+ => _options.CleanDateTimeRegexes.Select(i => Clean(name, i))
.FirstOrDefault(i => i.HasChanged) ??
- new CleanDateTimeResult { Name = originalName };
-
- if (result.HasChanged)
- {
- return result;
- }
-
- // Make a second pass, running clean string first
- var cleanStringResult = CleanStringParser.Clean(name, _options.CleanStringRegexes);
-
- if (!cleanStringResult.HasChanged)
- {
- return result;
- }
-
- return _options.CleanDateTimeRegexes.Select(i => Clean(cleanStringResult.Name, i))
- .FirstOrDefault(i => i.HasChanged) ??
- result;
- }
+ new CleanDateTimeResult { Name = name };
private static CleanDateTimeResult Clean(string name, Regex expression)
{