aboutsummaryrefslogtreecommitdiff
path: root/Emby.Naming/Video
diff options
context:
space:
mode:
Diffstat (limited to 'Emby.Naming/Video')
-rw-r--r--Emby.Naming/Video/CleanDateTimeParser.cs1
-rw-r--r--Emby.Naming/Video/CleanDateTimeResult.cs1
-rw-r--r--Emby.Naming/Video/CleanStringParser.cs1
-rw-r--r--Emby.Naming/Video/ExtraResolver.cs10
-rw-r--r--Emby.Naming/Video/ExtraResult.cs1
-rw-r--r--Emby.Naming/Video/ExtraRule.cs14
-rw-r--r--Emby.Naming/Video/ExtraRuleType.cs14
-rw-r--r--Emby.Naming/Video/FileStack.cs1
-rw-r--r--Emby.Naming/Video/FlagParser.cs1
-rw-r--r--Emby.Naming/Video/Format3DParser.cs1
-rw-r--r--Emby.Naming/Video/Format3DResult.cs1
-rw-r--r--Emby.Naming/Video/Format3DRule.cs1
-rw-r--r--Emby.Naming/Video/StackResolver.cs26
-rw-r--r--Emby.Naming/Video/StubResolver.cs1
-rw-r--r--Emby.Naming/Video/StubResult.cs1
-rw-r--r--Emby.Naming/Video/StubTypeRule.cs1
-rw-r--r--Emby.Naming/Video/VideoFileInfo.cs4
-rw-r--r--Emby.Naming/Video/VideoListResolver.cs25
-rw-r--r--Emby.Naming/Video/VideoResolver.cs7
19 files changed, 46 insertions, 66 deletions
diff --git a/Emby.Naming/Video/CleanDateTimeParser.cs b/Emby.Naming/Video/CleanDateTimeParser.cs
index 6c74c07d55..579c9e91e1 100644
--- a/Emby.Naming/Video/CleanDateTimeParser.cs
+++ b/Emby.Naming/Video/CleanDateTimeParser.cs
@@ -1,5 +1,4 @@
#pragma warning disable CS1591
-#pragma warning disable SA1600
#nullable enable
using System.Collections.Generic;
diff --git a/Emby.Naming/Video/CleanDateTimeResult.cs b/Emby.Naming/Video/CleanDateTimeResult.cs
index 73a445612b..57eeaa7e32 100644
--- a/Emby.Naming/Video/CleanDateTimeResult.cs
+++ b/Emby.Naming/Video/CleanDateTimeResult.cs
@@ -1,5 +1,4 @@
#pragma warning disable CS1591
-#pragma warning disable SA1600
#nullable enable
namespace Emby.Naming.Video
diff --git a/Emby.Naming/Video/CleanStringParser.cs b/Emby.Naming/Video/CleanStringParser.cs
index b7b65d8228..3f584d5847 100644
--- a/Emby.Naming/Video/CleanStringParser.cs
+++ b/Emby.Naming/Video/CleanStringParser.cs
@@ -1,5 +1,4 @@
#pragma warning disable CS1591
-#pragma warning disable SA1600
#nullable enable
using System;
diff --git a/Emby.Naming/Video/ExtraResolver.cs b/Emby.Naming/Video/ExtraResolver.cs
index 3e5d473ecc..fc0424faab 100644
--- a/Emby.Naming/Video/ExtraResolver.cs
+++ b/Emby.Naming/Video/ExtraResolver.cs
@@ -1,5 +1,4 @@
#pragma warning disable CS1591
-#pragma warning disable SA1600
using System;
using System.IO;
@@ -81,6 +80,15 @@ namespace Emby.Naming.Video
result.Rule = rule;
}
}
+ else if (rule.RuleType == ExtraRuleType.DirectoryName)
+ {
+ var directoryName = Path.GetFileName(Path.GetDirectoryName(path));
+ if (string.Equals(directoryName, rule.Token, StringComparison.OrdinalIgnoreCase))
+ {
+ result.ExtraType = rule.ExtraType;
+ result.Rule = rule;
+ }
+ }
return result;
}
diff --git a/Emby.Naming/Video/ExtraResult.cs b/Emby.Naming/Video/ExtraResult.cs
index 4e991d685d..15db32e876 100644
--- a/Emby.Naming/Video/ExtraResult.cs
+++ b/Emby.Naming/Video/ExtraResult.cs
@@ -1,5 +1,4 @@
#pragma warning disable CS1591
-#pragma warning disable SA1600
using MediaBrowser.Model.Entities;
diff --git a/Emby.Naming/Video/ExtraRule.cs b/Emby.Naming/Video/ExtraRule.cs
index cfaa84ed6b..7c9702e244 100644
--- a/Emby.Naming/Video/ExtraRule.cs
+++ b/Emby.Naming/Video/ExtraRule.cs
@@ -1,35 +1,33 @@
#pragma warning disable CS1591
-#pragma warning disable SA1600
using MediaBrowser.Model.Entities;
using MediaType = Emby.Naming.Common.MediaType;
namespace Emby.Naming.Video
{
+ /// <summary>
+ /// A rule used to match a file path with an <see cref="MediaBrowser.Model.Entities.ExtraType"/>.
+ /// </summary>
public class ExtraRule
{
/// <summary>
- /// Gets or sets the token.
+ /// Gets or sets the token to use for matching against the file path.
/// </summary>
- /// <value>The token.</value>
public string Token { get; set; }
/// <summary>
- /// Gets or sets the type of the extra.
+ /// Gets or sets the type of the extra to return when matched.
/// </summary>
- /// <value>The type of the extra.</value>
public ExtraType ExtraType { get; set; }
/// <summary>
/// Gets or sets the type of the rule.
/// </summary>
- /// <value>The type of the rule.</value>
public ExtraRuleType RuleType { get; set; }
/// <summary>
- /// Gets or sets the type of the media.
+ /// Gets or sets the type of the media to return when matched.
/// </summary>
- /// <value>The type of the media.</value>
public MediaType MediaType { get; set; }
}
}
diff --git a/Emby.Naming/Video/ExtraRuleType.cs b/Emby.Naming/Video/ExtraRuleType.cs
index 2bf2799ff7..e89876f4ae 100644
--- a/Emby.Naming/Video/ExtraRuleType.cs
+++ b/Emby.Naming/Video/ExtraRuleType.cs
@@ -1,23 +1,27 @@
#pragma warning disable CS1591
-#pragma warning disable SA1600
namespace Emby.Naming.Video
{
public enum ExtraRuleType
{
/// <summary>
- /// The suffix
+ /// Match <see cref="ExtraRule.Token"/> against a suffix in the file name.
/// </summary>
Suffix = 0,
/// <summary>
- /// The filename
+ /// Match <see cref="ExtraRule.Token"/> against the file name, excluding the file extension.
/// </summary>
Filename = 1,
/// <summary>
- /// The regex
+ /// Match <see cref="ExtraRule.Token"/> against the file name, including the file extension.
/// </summary>
- Regex = 2
+ Regex = 2,
+
+ /// <summary>
+ /// Match <see cref="ExtraRule.Token"/> against the name of the directory containing the file.
+ /// </summary>
+ DirectoryName = 3,
}
}
diff --git a/Emby.Naming/Video/FileStack.cs b/Emby.Naming/Video/FileStack.cs
index 56adf6add0..3ef190b865 100644
--- a/Emby.Naming/Video/FileStack.cs
+++ b/Emby.Naming/Video/FileStack.cs
@@ -1,5 +1,4 @@
#pragma warning disable CS1591
-#pragma warning disable SA1600
using System;
using System.Collections.Generic;
diff --git a/Emby.Naming/Video/FlagParser.cs b/Emby.Naming/Video/FlagParser.cs
index acf3438c22..a8bd9d5c5d 100644
--- a/Emby.Naming/Video/FlagParser.cs
+++ b/Emby.Naming/Video/FlagParser.cs
@@ -1,5 +1,4 @@
#pragma warning disable CS1591
-#pragma warning disable SA1600
using System;
using System.IO;
diff --git a/Emby.Naming/Video/Format3DParser.cs b/Emby.Naming/Video/Format3DParser.cs
index 25905f33c1..51c26af863 100644
--- a/Emby.Naming/Video/Format3DParser.cs
+++ b/Emby.Naming/Video/Format3DParser.cs
@@ -1,5 +1,4 @@
#pragma warning disable CS1591
-#pragma warning disable SA1600
using System;
using System.Linq;
diff --git a/Emby.Naming/Video/Format3DResult.cs b/Emby.Naming/Video/Format3DResult.cs
index 6ebd72f6ba..fa0e9d3b80 100644
--- a/Emby.Naming/Video/Format3DResult.cs
+++ b/Emby.Naming/Video/Format3DResult.cs
@@ -1,5 +1,4 @@
#pragma warning disable CS1591
-#pragma warning disable SA1600
using System.Collections.Generic;
diff --git a/Emby.Naming/Video/Format3DRule.cs b/Emby.Naming/Video/Format3DRule.cs
index ae9fb5b19f..310ec84e8f 100644
--- a/Emby.Naming/Video/Format3DRule.cs
+++ b/Emby.Naming/Video/Format3DRule.cs
@@ -1,5 +1,4 @@
#pragma warning disable CS1591
-#pragma warning disable SA1600
namespace Emby.Naming.Video
{
diff --git a/Emby.Naming/Video/StackResolver.cs b/Emby.Naming/Video/StackResolver.cs
index b9afe998b7..f733cd2620 100644
--- a/Emby.Naming/Video/StackResolver.cs
+++ b/Emby.Naming/Video/StackResolver.cs
@@ -1,5 +1,4 @@
#pragma warning disable CS1591
-#pragma warning disable SA1600
using System;
using System.Collections.Generic;
@@ -22,31 +21,24 @@ namespace Emby.Naming.Video
public IEnumerable<FileStack> ResolveDirectories(IEnumerable<string> files)
{
- return Resolve(files.Select(i => new FileSystemMetadata
- {
- FullName = i,
- IsDirectory = true
- }));
+ return Resolve(files.Select(i => new FileSystemMetadata { FullName = i, IsDirectory = true }));
}
public IEnumerable<FileStack> ResolveFiles(IEnumerable<string> files)
{
- return Resolve(files.Select(i => new FileSystemMetadata
- {
- FullName = i,
- IsDirectory = false
- }));
+ return Resolve(files.Select(i => new FileSystemMetadata { FullName = i, IsDirectory = false }));
}
public IEnumerable<FileStack> ResolveAudioBooks(IEnumerable<FileSystemMetadata> files)
{
- foreach (var directory in files.GroupBy(file => file.IsDirectory ? file.FullName : Path.GetDirectoryName(file.FullName)))
+ var groupedDirectoryFiles = files.GroupBy(file =>
+ file.IsDirectory
+ ? file.FullName
+ : Path.GetDirectoryName(file.FullName));
+
+ foreach (var directory in groupedDirectoryFiles)
{
- var stack = new FileStack()
- {
- Name = Path.GetFileName(directory.Key),
- IsDirectoryStack = false
- };
+ var stack = new FileStack { Name = Path.GetFileName(directory.Key), IsDirectoryStack = false };
foreach (var file in directory)
{
if (file.IsDirectory)
diff --git a/Emby.Naming/Video/StubResolver.cs b/Emby.Naming/Video/StubResolver.cs
index 4024d6d593..f1b5d7bcca 100644
--- a/Emby.Naming/Video/StubResolver.cs
+++ b/Emby.Naming/Video/StubResolver.cs
@@ -1,5 +1,4 @@
#pragma warning disable CS1591
-#pragma warning disable SA1600
#nullable enable
using System;
diff --git a/Emby.Naming/Video/StubResult.cs b/Emby.Naming/Video/StubResult.cs
index 5ac85528f5..1b8e99b0dc 100644
--- a/Emby.Naming/Video/StubResult.cs
+++ b/Emby.Naming/Video/StubResult.cs
@@ -1,5 +1,4 @@
#pragma warning disable CS1591
-#pragma warning disable SA1600
namespace Emby.Naming.Video
{
diff --git a/Emby.Naming/Video/StubTypeRule.cs b/Emby.Naming/Video/StubTypeRule.cs
index 17c3ef8c5e..8285cb51a3 100644
--- a/Emby.Naming/Video/StubTypeRule.cs
+++ b/Emby.Naming/Video/StubTypeRule.cs
@@ -1,5 +1,4 @@
#pragma warning disable CS1591
-#pragma warning disable SA1600
namespace Emby.Naming.Video
{
diff --git a/Emby.Naming/Video/VideoFileInfo.cs b/Emby.Naming/Video/VideoFileInfo.cs
index aa4f3a35c3..11e789b663 100644
--- a/Emby.Naming/Video/VideoFileInfo.cs
+++ b/Emby.Naming/Video/VideoFileInfo.cs
@@ -77,7 +77,9 @@ namespace Emby.Naming.Video
/// Gets the file name without extension.
/// </summary>
/// <value>The file name without extension.</value>
- public string FileNameWithoutExtension => !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);
/// <inheritdoc />
public override string ToString()
diff --git a/Emby.Naming/Video/VideoListResolver.cs b/Emby.Naming/Video/VideoListResolver.cs
index 1366583534..7f755fd25e 100644
--- a/Emby.Naming/Video/VideoListResolver.cs
+++ b/Emby.Naming/Video/VideoListResolver.cs
@@ -1,5 +1,4 @@
#pragma warning disable CS1591
-#pragma warning disable SA1600
using System;
using System.Collections.Generic;
@@ -34,11 +33,7 @@ namespace Emby.Naming.Video
// See the unit test TestStackedWithTrailer
var nonExtras = videoInfos
.Where(i => i.ExtraType == null)
- .Select(i => new FileSystemMetadata
- {
- FullName = i.Path,
- IsDirectory = i.IsDirectory
- });
+ .Select(i => new FileSystemMetadata { FullName = i.Path, IsDirectory = i.IsDirectory });
var stackResult = new StackResolver(_options)
.Resolve(nonExtras).ToList();
@@ -58,11 +53,7 @@ namespace Emby.Naming.Video
info.Year = info.Files[0].Year;
- var extraBaseNames = new List<string>
- {
- stack.Name,
- Path.GetFileNameWithoutExtension(stack.Files[0])
- };
+ var extraBaseNames = new List<string> { stack.Name, Path.GetFileNameWithoutExtension(stack.Files[0]) };
var extras = GetExtras(remainingFiles, extraBaseNames);
@@ -84,10 +75,7 @@ namespace Emby.Naming.Video
foreach (var media in standaloneMedia)
{
- var info = new VideoInfo(media.Name)
- {
- Files = new List<VideoFileInfo> { media }
- };
+ var info = new VideoInfo(media.Name) { Files = new List<VideoFileInfo> { media } };
info.Year = info.Files[0].Year;
@@ -223,8 +211,8 @@ namespace Emby.Naming.Video
{
testFilename = testFilename.Substring(folderName.Length).Trim();
return string.IsNullOrEmpty(testFilename)
- || testFilename[0] == '-'
- || string.IsNullOrWhiteSpace(Regex.Replace(testFilename, @"\[([^]]*)\]", string.Empty));
+ || testFilename[0] == '-'
+ || string.IsNullOrWhiteSpace(Regex.Replace(testFilename, @"\[([^]]*)\]", string.Empty));
}
return false;
@@ -240,7 +228,8 @@ namespace Emby.Naming.Video
return remainingFiles
.Where(i => i.ExtraType == null)
- .Where(i => baseNames.Any(b => i.FileNameWithoutExtension.StartsWith(b, StringComparison.OrdinalIgnoreCase)))
+ .Where(i => baseNames.Any(b =>
+ i.FileNameWithoutExtension.StartsWith(b, StringComparison.OrdinalIgnoreCase)))
.ToList();
}
}
diff --git a/Emby.Naming/Video/VideoResolver.cs b/Emby.Naming/Video/VideoResolver.cs
index 699bbe40a1..b4aee614b0 100644
--- a/Emby.Naming/Video/VideoResolver.cs
+++ b/Emby.Naming/Video/VideoResolver.cs
@@ -1,5 +1,4 @@
#pragma warning disable CS1591
-#pragma warning disable SA1600
#nullable enable
using System;
@@ -90,14 +89,14 @@ namespace Emby.Naming.Video
if (parseName)
{
var cleanDateTimeResult = CleanDateTime(name);
+ name = cleanDateTimeResult.Name;
+ year = cleanDateTimeResult.Year;
if (extraResult.ExtraType == null
- && TryCleanString(cleanDateTimeResult.Name, out ReadOnlySpan<char> newName))
+ && TryCleanString(name, out ReadOnlySpan<char> newName))
{
name = newName.ToString();
}
-
- year = cleanDateTimeResult.Year;
}
return new VideoFileInfo