aboutsummaryrefslogtreecommitdiff
path: root/Emby.Naming/Video
diff options
context:
space:
mode:
authorLogicalPhallacy <44458166+LogicalPhallacy@users.noreply.github.com>2019-01-23 00:31:35 -0800
committerGitHub <noreply@github.com>2019-01-23 00:31:35 -0800
commit404bd04cbc17dc8c8bf4a5c9aa3ca9c5cd85aa68 (patch)
tree3d267c6ceef9439a034c113095e10e4d619e7c70 /Emby.Naming/Video
parent8ff89fdc0c30f595a171ffc550f907ef22b6212a (diff)
parente05e002b8bb4d13eb2b80b56a0aad8903ddb701e (diff)
Merge pull request #8 from jellyfin/master
rebase to latest master
Diffstat (limited to 'Emby.Naming/Video')
-rw-r--r--Emby.Naming/Video/CleanDateTimeParser.cs11
-rw-r--r--Emby.Naming/Video/CleanDateTimeResult.cs1
-rw-r--r--Emby.Naming/Video/CleanStringParser.cs4
-rw-r--r--Emby.Naming/Video/CleanStringResult.cs1
-rw-r--r--Emby.Naming/Video/ExtraResolver.cs4
-rw-r--r--Emby.Naming/Video/ExtraResult.cs2
-rw-r--r--Emby.Naming/Video/ExtraRule.cs2
-rw-r--r--Emby.Naming/Video/ExtraRuleType.cs1
-rw-r--r--Emby.Naming/Video/FileStack.cs2
-rw-r--r--Emby.Naming/Video/FlagParser.cs4
-rw-r--r--Emby.Naming/Video/Format3DParser.cs4
-rw-r--r--Emby.Naming/Video/Format3DResult.cs2
-rw-r--r--Emby.Naming/Video/Format3DRule.cs1
-rw-r--r--Emby.Naming/Video/StackResolver.cs4
-rw-r--r--Emby.Naming/Video/StackResult.cs2
-rw-r--r--Emby.Naming/Video/StubResolver.cs20
-rw-r--r--Emby.Naming/Video/StubResult.cs14
-rw-r--r--Emby.Naming/Video/StubTypeRule.cs1
-rw-r--r--Emby.Naming/Video/VideoFileInfo.cs9
-rw-r--r--Emby.Naming/Video/VideoInfo.cs4
-rw-r--r--Emby.Naming/Video/VideoListResolver.cs10
-rw-r--r--Emby.Naming/Video/VideoResolver.cs21
22 files changed, 46 insertions, 78 deletions
diff --git a/Emby.Naming/Video/CleanDateTimeParser.cs b/Emby.Naming/Video/CleanDateTimeParser.cs
index 572dd1c60..74807ef53 100644
--- a/Emby.Naming/Video/CleanDateTimeParser.cs
+++ b/Emby.Naming/Video/CleanDateTimeParser.cs
@@ -1,9 +1,9 @@
-using System;
-using Emby.Naming.Common;
+using System;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
+using Emby.Naming.Common;
namespace Emby.Naming.Video
{
@@ -38,7 +38,7 @@ namespace Emby.Naming.Video
}
catch (ArgumentException)
{
-
+
}
var result = _options.CleanDateTimeRegexes.Select(i => Clean(name, i))
@@ -63,7 +63,7 @@ namespace Emby.Naming.Video
result;
}
- private CleanDateTimeResult Clean(string name, Regex expression)
+ private static CleanDateTimeResult Clean(string name, Regex expression)
{
var result = new CleanDateTimeResult();
@@ -71,8 +71,7 @@ namespace Emby.Naming.Video
if (match.Success && match.Groups.Count == 4)
{
- int year;
- if (match.Groups[1].Success && match.Groups[2].Success && int.TryParse(match.Groups[2].Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out year))
+ if (match.Groups[1].Success && match.Groups[2].Success && int.TryParse(match.Groups[2].Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out var year))
{
name = match.Groups[1].Value;
result.Year = year;
diff --git a/Emby.Naming/Video/CleanDateTimeResult.cs b/Emby.Naming/Video/CleanDateTimeResult.cs
index 946fd953c..6bf24e4d8 100644
--- a/Emby.Naming/Video/CleanDateTimeResult.cs
+++ b/Emby.Naming/Video/CleanDateTimeResult.cs
@@ -1,4 +1,3 @@
-
namespace Emby.Naming.Video
{
public class CleanDateTimeResult
diff --git a/Emby.Naming/Video/CleanStringParser.cs b/Emby.Naming/Video/CleanStringParser.cs
index bddf9589b..02b90310d 100644
--- a/Emby.Naming/Video/CleanStringParser.cs
+++ b/Emby.Naming/Video/CleanStringParser.cs
@@ -1,4 +1,4 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.Text.RegularExpressions;
namespace Emby.Naming.Video
@@ -30,7 +30,7 @@ namespace Emby.Naming.Video
};
}
- private CleanStringResult Clean(string name, Regex expression)
+ private static CleanStringResult Clean(string name, Regex expression)
{
var result = new CleanStringResult();
diff --git a/Emby.Naming/Video/CleanStringResult.cs b/Emby.Naming/Video/CleanStringResult.cs
index 0282863e0..b3bc59712 100644
--- a/Emby.Naming/Video/CleanStringResult.cs
+++ b/Emby.Naming/Video/CleanStringResult.cs
@@ -1,4 +1,3 @@
-
namespace Emby.Naming.Video
{
public class CleanStringResult
diff --git a/Emby.Naming/Video/ExtraResolver.cs b/Emby.Naming/Video/ExtraResolver.cs
index bde1a4765..3459b689a 100644
--- a/Emby.Naming/Video/ExtraResolver.cs
+++ b/Emby.Naming/Video/ExtraResolver.cs
@@ -1,9 +1,9 @@
-using Emby.Naming.Audio;
-using Emby.Naming.Common;
using System;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
+using Emby.Naming.Audio;
+using Emby.Naming.Common;
namespace Emby.Naming.Video
{
diff --git a/Emby.Naming/Video/ExtraResult.cs b/Emby.Naming/Video/ExtraResult.cs
index ca79af9da..ff6f20c47 100644
--- a/Emby.Naming/Video/ExtraResult.cs
+++ b/Emby.Naming/Video/ExtraResult.cs
@@ -1,5 +1,3 @@
-using System.Collections.Generic;
-
namespace Emby.Naming.Video
{
public class ExtraResult
diff --git a/Emby.Naming/Video/ExtraRule.cs b/Emby.Naming/Video/ExtraRule.cs
index ef83b3cd6..b8eb8427e 100644
--- a/Emby.Naming/Video/ExtraRule.cs
+++ b/Emby.Naming/Video/ExtraRule.cs
@@ -1,4 +1,4 @@
-using Emby.Naming.Common;
+using Emby.Naming.Common;
namespace Emby.Naming.Video
{
diff --git a/Emby.Naming/Video/ExtraRuleType.cs b/Emby.Naming/Video/ExtraRuleType.cs
index 323c7cef6..565239ff9 100644
--- a/Emby.Naming/Video/ExtraRuleType.cs
+++ b/Emby.Naming/Video/ExtraRuleType.cs
@@ -1,4 +1,3 @@
-
namespace Emby.Naming.Video
{
public enum ExtraRuleType
diff --git a/Emby.Naming/Video/FileStack.cs b/Emby.Naming/Video/FileStack.cs
index 2feea4cb3..2df1e9aed 100644
--- a/Emby.Naming/Video/FileStack.cs
+++ b/Emby.Naming/Video/FileStack.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Linq;
diff --git a/Emby.Naming/Video/FlagParser.cs b/Emby.Naming/Video/FlagParser.cs
index a2c541eeb..bb129499b 100644
--- a/Emby.Naming/Video/FlagParser.cs
+++ b/Emby.Naming/Video/FlagParser.cs
@@ -1,6 +1,6 @@
-using Emby.Naming.Common;
using System;
using System.IO;
+using Emby.Naming.Common;
namespace Emby.Naming.Video
{
@@ -22,7 +22,7 @@ namespace Emby.Naming.Video
{
if (string.IsNullOrEmpty(path))
{
- throw new ArgumentNullException("path");
+ throw new ArgumentNullException(nameof(path));
}
// Note: the tags need be be surrounded be either a space ( ), hyphen -, dot . or underscore _.
diff --git a/Emby.Naming/Video/Format3DParser.cs b/Emby.Naming/Video/Format3DParser.cs
index 42737b483..e6f830c58 100644
--- a/Emby.Naming/Video/Format3DParser.cs
+++ b/Emby.Naming/Video/Format3DParser.cs
@@ -1,6 +1,6 @@
-using Emby.Naming.Common;
using System;
using System.Linq;
+using Emby.Naming.Common;
namespace Emby.Naming.Video
{
@@ -36,7 +36,7 @@ namespace Emby.Naming.Video
return new Format3DResult();
}
- private Format3DResult Parse(string[] videoFlags, Format3DRule rule)
+ private static Format3DResult Parse(string[] videoFlags, Format3DRule rule)
{
var result = new Format3DResult();
diff --git a/Emby.Naming/Video/Format3DResult.cs b/Emby.Naming/Video/Format3DResult.cs
index 147ccfc05..e12494079 100644
--- a/Emby.Naming/Video/Format3DResult.cs
+++ b/Emby.Naming/Video/Format3DResult.cs
@@ -1,4 +1,4 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
namespace Emby.Naming.Video
{
diff --git a/Emby.Naming/Video/Format3DRule.cs b/Emby.Naming/Video/Format3DRule.cs
index 3c173efbc..dc260175a 100644
--- a/Emby.Naming/Video/Format3DRule.cs
+++ b/Emby.Naming/Video/Format3DRule.cs
@@ -1,4 +1,3 @@
-
namespace Emby.Naming.Video
{
public class Format3DRule
diff --git a/Emby.Naming/Video/StackResolver.cs b/Emby.Naming/Video/StackResolver.cs
index 2a7125536..4893002c1 100644
--- a/Emby.Naming/Video/StackResolver.cs
+++ b/Emby.Naming/Video/StackResolver.cs
@@ -1,9 +1,9 @@
-using Emby.Naming.Common;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
+using Emby.Naming.Common;
using MediaBrowser.Model.IO;
namespace Emby.Naming.Video
@@ -126,7 +126,7 @@ namespace Emby.Naming.Video
}
stack.Files.Add(file2.FullName);
}
- else
+ else
{
// Sequel
offset = 0;
diff --git a/Emby.Naming/Video/StackResult.cs b/Emby.Naming/Video/StackResult.cs
index 920a7dea7..de35d2825 100644
--- a/Emby.Naming/Video/StackResult.cs
+++ b/Emby.Naming/Video/StackResult.cs
@@ -1,4 +1,4 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
namespace Emby.Naming.Video
{
diff --git a/Emby.Naming/Video/StubResolver.cs b/Emby.Naming/Video/StubResolver.cs
index 69f1f50fa..f86bcbdf0 100644
--- a/Emby.Naming/Video/StubResolver.cs
+++ b/Emby.Naming/Video/StubResolver.cs
@@ -1,25 +1,18 @@
-using Emby.Naming.Common;
using System;
using System.IO;
using System.Linq;
+using Emby.Naming.Common;
namespace Emby.Naming.Video
{
- public class StubResolver
+ public static class StubResolver
{
- private readonly NamingOptions _options;
-
- public StubResolver(NamingOptions options)
- {
- _options = options;
- }
-
- public StubResult ResolveFile(string path)
+ public static StubResult ResolveFile(string path, NamingOptions options)
{
var result = new StubResult();
var extension = Path.GetExtension(path) ?? string.Empty;
-
- if (_options.StubFileExtensions.Contains(extension, StringComparer.OrdinalIgnoreCase))
+
+ if (options.StubFileExtensions.Contains(extension, StringComparer.OrdinalIgnoreCase))
{
result.IsStub = true;
@@ -27,12 +20,11 @@ namespace Emby.Naming.Video
var token = (Path.GetExtension(path) ?? string.Empty).TrimStart('.');
- foreach (var rule in _options.StubTypes)
+ foreach (var rule in options.StubTypes)
{
if (string.Equals(rule.Token, token, StringComparison.OrdinalIgnoreCase))
{
result.StubType = rule.StubType;
- result.Tokens.Add(token);
break;
}
}
diff --git a/Emby.Naming/Video/StubResult.cs b/Emby.Naming/Video/StubResult.cs
index c9d06c9a7..7f9509ca5 100644
--- a/Emby.Naming/Video/StubResult.cs
+++ b/Emby.Naming/Video/StubResult.cs
@@ -1,8 +1,6 @@
-using System.Collections.Generic;
-
namespace Emby.Naming.Video
{
- public class StubResult
+ public struct StubResult
{
/// <summary>
/// Gets or sets a value indicating whether this instance is stub.
@@ -14,15 +12,5 @@ namespace Emby.Naming.Video
/// </summary>
/// <value>The type of the stub.</value>
public string StubType { get; set; }
- /// <summary>
- /// Gets or sets the tokens.
- /// </summary>
- /// <value>The tokens.</value>
- public List<string> Tokens { get; set; }
-
- public StubResult()
- {
- Tokens = new List<string>();
- }
}
}
diff --git a/Emby.Naming/Video/StubTypeRule.cs b/Emby.Naming/Video/StubTypeRule.cs
index 66ebfc3a2..b46050085 100644
--- a/Emby.Naming/Video/StubTypeRule.cs
+++ b/Emby.Naming/Video/StubTypeRule.cs
@@ -1,4 +1,3 @@
-
namespace Emby.Naming.Video
{
public class StubTypeRule
diff --git a/Emby.Naming/Video/VideoFileInfo.cs b/Emby.Naming/Video/VideoFileInfo.cs
index 96839c31e..6a29ada7e 100644
--- a/Emby.Naming/Video/VideoFileInfo.cs
+++ b/Emby.Naming/Video/VideoFileInfo.cs
@@ -1,4 +1,4 @@
-
+
namespace Emby.Naming.Video
{
/// <summary>
@@ -55,7 +55,7 @@ namespace Emby.Naming.Video
/// Gets or sets the type of the stub.
/// </summary>
/// <value>The type of the stub.</value>
- public string StubType { get; set; }
+ public string StubType { get; set; }
/// <summary>
/// Gets or sets the type.
/// </summary>
@@ -65,10 +65,7 @@ namespace Emby.Naming.Video
/// Gets the file name without extension.
/// </summary>
/// <value>The file name without extension.</value>
- public string FileNameWithoutExtension
- {
- get { return !IsDirectory ? System.IO.Path.GetFileNameWithoutExtension(Path) : System.IO.Path.GetFileName(Path); }
- }
+ public string FileNameWithoutExtension => !IsDirectory ? System.IO.Path.GetFileNameWithoutExtension(Path) : System.IO.Path.GetFileName(Path);
public override string ToString()
{
diff --git a/Emby.Naming/Video/VideoInfo.cs b/Emby.Naming/Video/VideoInfo.cs
index f4d311b97..d96d0e757 100644
--- a/Emby.Naming/Video/VideoInfo.cs
+++ b/Emby.Naming/Video/VideoInfo.cs
@@ -1,4 +1,4 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
namespace Emby.Naming.Video
{
@@ -32,7 +32,7 @@ namespace Emby.Naming.Video
/// </summary>
/// <value>The alternate versions.</value>
public List<VideoFileInfo> AlternateVersions { get; set; }
-
+
public VideoInfo()
{
Files = new List<VideoFileInfo>();
diff --git a/Emby.Naming/Video/VideoListResolver.cs b/Emby.Naming/Video/VideoListResolver.cs
index 47be28104..0506d0734 100644
--- a/Emby.Naming/Video/VideoListResolver.cs
+++ b/Emby.Naming/Video/VideoListResolver.cs
@@ -1,10 +1,10 @@
-using Emby.Naming.Common;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
-using MediaBrowser.Model.IO;
using System.Text.RegularExpressions;
+using Emby.Naming.Common;
+using MediaBrowser.Model.IO;
namespace Emby.Naming.Video
{
@@ -55,9 +55,9 @@ namespace Emby.Naming.Video
info.Year = info.Files.First().Year;
- var extraBaseNames = new List<string>
+ var extraBaseNames = new List<string>
{
- stack.Name,
+ stack.Name,
Path.GetFileNameWithoutExtension(stack.Files[0])
};
@@ -236,7 +236,7 @@ namespace Emby.Naming.Video
if (testFilename.StartsWith(folderName, StringComparison.OrdinalIgnoreCase))
{
testFilename = testFilename.Substring(folderName.Length).Trim();
- return testFilename.StartsWith("-", StringComparison.OrdinalIgnoreCase)||Regex.Replace(testFilename, @"\[([^]]*)\]", "").Trim() == String.Empty;
+ return testFilename.StartsWith("-", StringComparison.OrdinalIgnoreCase) || Regex.Replace(testFilename, @"\[([^]]*)\]", "").Trim() == string.Empty;
}
return false;
diff --git a/Emby.Naming/Video/VideoResolver.cs b/Emby.Naming/Video/VideoResolver.cs
index c4951c728..a67315651 100644
--- a/Emby.Naming/Video/VideoResolver.cs
+++ b/Emby.Naming/Video/VideoResolver.cs
@@ -1,7 +1,7 @@
-using Emby.Naming.Common;
using System;
using System.IO;
using System.Linq;
+using Emby.Naming.Common;
namespace Emby.Naming.Video
{
@@ -40,25 +40,25 @@ namespace Emby.Naming.Video
/// <param name="path">The path.</param>
/// <param name="IsDirectory">if set to <c>true</c> [is folder].</param>
/// <returns>VideoFileInfo.</returns>
- /// <exception cref="System.ArgumentNullException">path</exception>
+ /// <exception cref="ArgumentNullException">path</exception>
public VideoFileInfo Resolve(string path, bool IsDirectory, bool parseName = true)
{
if (string.IsNullOrEmpty(path))
{
- throw new ArgumentNullException("path");
+ throw new ArgumentNullException(nameof(path));
}
- var isStub = false;
+ bool isStub = false;
string container = null;
string stubType = null;
if (!IsDirectory)
{
- var extension = Path.GetExtension(path) ?? string.Empty;
+ var extension = Path.GetExtension(path);
// Check supported extensions
if (!_options.VideoFileExtensions.Contains(extension, StringComparer.OrdinalIgnoreCase))
{
- var stubResult = new StubResolver(_options).ResolveFile(path);
+ var stubResult = StubResolver.ResolveFile(path, _options);
isStub = stubResult.IsStub;
@@ -79,9 +79,9 @@ namespace Emby.Naming.Video
var extraResult = new ExtraResolver(_options).GetExtraInfo(path);
- var name = !IsDirectory
- ? Path.GetFileNameWithoutExtension(path)
- : Path.GetFileName(path);
+ var name = IsDirectory
+ ? Path.GetFileName(path)
+ : Path.GetFileNameWithoutExtension(path);
int? year = null;
@@ -91,8 +91,7 @@ namespace Emby.Naming.Video
if (string.IsNullOrEmpty(extraResult.ExtraType))
{
- name = cleanDateTimeResult.Name;
- name = CleanString(name).Name;
+ name = CleanString(cleanDateTimeResult.Name).Name;
}
year = cleanDateTimeResult.Year;