From 59619b6ea74ab555977fd213f6ee5737897b0fbd Mon Sep 17 00:00:00 2001 From: Stepan Date: Sun, 1 Nov 2020 10:47:31 +0100 Subject: Enable nullable in Emby.Naming --- Emby.Naming/Video/Format3DParser.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Emby.Naming/Video/Format3DParser.cs') diff --git a/Emby.Naming/Video/Format3DParser.cs b/Emby.Naming/Video/Format3DParser.cs index 51c26af86..3a9eaa1a1 100644 --- a/Emby.Naming/Video/Format3DParser.cs +++ b/Emby.Naming/Video/Format3DParser.cs @@ -57,7 +57,7 @@ namespace Emby.Naming.Video else { var foundPrefix = false; - string format = null; + string? format = null; foreach (var flag in videoFlags) { -- cgit v1.2.3 From 60b49e67eafd356d1276f43de1a3f1f2fe52fe3f Mon Sep 17 00:00:00 2001 From: Stepan Date: Sun, 1 Nov 2020 11:19:22 +0100 Subject: Re-Sharper inspection issues --- Emby.Naming/AudioBook/AudioBookListResolver.cs | 1 - Emby.Naming/AudioBook/AudioBookResolver.cs | 2 +- Emby.Naming/Common/NamingOptions.cs | 12 +++++++----- Emby.Naming/Emby.Naming.csproj | 2 +- Emby.Naming/TV/EpisodeInfo.cs | 2 +- Emby.Naming/TV/EpisodePathParser.cs | 8 ++++---- Emby.Naming/TV/EpisodePathParserResult.cs | 2 +- Emby.Naming/TV/EpisodeResolver.cs | 2 +- Emby.Naming/TV/SeasonPathParser.cs | 12 ++++++------ Emby.Naming/Video/ExtraRuleType.cs | 2 +- Emby.Naming/Video/FlagParser.cs | 4 ++-- Emby.Naming/Video/Format3DParser.cs | 14 +++++++------- Emby.Naming/Video/Format3DRule.cs | 10 +++++----- Emby.Naming/Video/StubResult.cs | 19 ------------------- Emby.Naming/Video/VideoListResolver.cs | 2 +- Emby.Server.Implementations/Library/LibraryManager.cs | 4 ++-- tests/Jellyfin.Naming.Tests/TV/MultiEpisodeTests.cs | 2 +- 17 files changed, 41 insertions(+), 59 deletions(-) delete mode 100644 Emby.Naming/Video/StubResult.cs (limited to 'Emby.Naming/Video/Format3DParser.cs') diff --git a/Emby.Naming/AudioBook/AudioBookListResolver.cs b/Emby.Naming/AudioBook/AudioBookListResolver.cs index f350e5a4a..179a3bc07 100644 --- a/Emby.Naming/AudioBook/AudioBookListResolver.cs +++ b/Emby.Naming/AudioBook/AudioBookListResolver.cs @@ -1,6 +1,5 @@ #pragma warning disable CS1591 -using System; using System.Collections.Generic; using System.Linq; using Emby.Naming.Common; diff --git a/Emby.Naming/AudioBook/AudioBookResolver.cs b/Emby.Naming/AudioBook/AudioBookResolver.cs index e76cfd744..56442fc4e 100644 --- a/Emby.Naming/AudioBook/AudioBookResolver.cs +++ b/Emby.Naming/AudioBook/AudioBookResolver.cs @@ -47,7 +47,7 @@ namespace Emby.Naming.AudioBook container, chapterNumber: parsingResult.ChapterNumber, partNumber: parsingResult.PartNumber, - isDirectory: isDirectory ); + isDirectory: isDirectory); } } } diff --git a/Emby.Naming/Common/NamingOptions.cs b/Emby.Naming/Common/NamingOptions.cs index 78bb6242d..537de63d5 100644 --- a/Emby.Naming/Common/NamingOptions.cs +++ b/Emby.Naming/Common/NamingOptions.cs @@ -6,6 +6,8 @@ using System.Text.RegularExpressions; using Emby.Naming.Video; using MediaBrowser.Model.Entities; +// ReSharper disable StringLiteralTypo + namespace Emby.Naming.Common { public class NamingOptions @@ -531,19 +533,19 @@ namespace Emby.Naming.Common { // Kodi rules: new Format3DRule( - preceedingToken: "3d", + precedingToken: "3d", token: "hsbs"), new Format3DRule( - preceedingToken: "3d", + precedingToken: "3d", token: "sbs"), new Format3DRule( - preceedingToken: "3d", + precedingToken: "3d", token: "htab"), new Format3DRule( - preceedingToken: "3d", + precedingToken: "3d", token: "tab"), // Media Browser rules: @@ -608,7 +610,7 @@ namespace Emby.Naming.Common ".mxf" }); - MultipleEpisodeExpressions = new string[] + MultipleEpisodeExpressions = new[] { @".*(\\|\/)[sS]?(?[0-9]{1,4})[xX](?[0-9]{1,3})((-| - )[0-9]{1,4}[eExX](?[0-9]{1,3}))+[^\\\/]*$", @".*(\\|\/)[sS]?(?[0-9]{1,4})[xX](?[0-9]{1,3})((-| - )[0-9]{1,4}[xX][eE](?[0-9]{1,3}))+[^\\\/]*$", diff --git a/Emby.Naming/Emby.Naming.csproj b/Emby.Naming/Emby.Naming.csproj index 93770b156..b7fd0c545 100644 --- a/Emby.Naming/Emby.Naming.csproj +++ b/Emby.Naming/Emby.Naming.csproj @@ -39,7 +39,7 @@ - + diff --git a/Emby.Naming/TV/EpisodeInfo.cs b/Emby.Naming/TV/EpisodeInfo.cs index a9ee82da3..e01c81062 100644 --- a/Emby.Naming/TV/EpisodeInfo.cs +++ b/Emby.Naming/TV/EpisodeInfo.cs @@ -55,7 +55,7 @@ namespace Emby.Naming.TV public int? EpisodeNumber { get; set; } - public int? EndingEpsiodeNumber { get; set; } + public int? EndingEpisodeNumber { get; set; } public int? Year { get; set; } diff --git a/Emby.Naming/TV/EpisodePathParser.cs b/Emby.Naming/TV/EpisodePathParser.cs index a6af689c7..866d8adc0 100644 --- a/Emby.Naming/TV/EpisodePathParser.cs +++ b/Emby.Naming/TV/EpisodePathParser.cs @@ -146,7 +146,7 @@ namespace Emby.Naming.TV { if (int.TryParse(endingNumberGroup.Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out num)) { - result.EndingEpsiodeNumber = num; + result.EndingEpisodeNumber = num; } } } @@ -217,13 +217,13 @@ namespace Emby.Naming.TV info.SeriesName = result.SeriesName; } - if (!info.EndingEpsiodeNumber.HasValue && info.EpisodeNumber.HasValue) + if (!info.EndingEpisodeNumber.HasValue && info.EpisodeNumber.HasValue) { - info.EndingEpsiodeNumber = result.EndingEpsiodeNumber; + info.EndingEpisodeNumber = result.EndingEpisodeNumber; } if (!string.IsNullOrEmpty(info.SeriesName) - && (!info.EpisodeNumber.HasValue || info.EndingEpsiodeNumber.HasValue)) + && (!info.EpisodeNumber.HasValue || info.EndingEpisodeNumber.HasValue)) { break; } diff --git a/Emby.Naming/TV/EpisodePathParserResult.cs b/Emby.Naming/TV/EpisodePathParserResult.cs index 9c48d07a3..5fa0b6f0b 100644 --- a/Emby.Naming/TV/EpisodePathParserResult.cs +++ b/Emby.Naming/TV/EpisodePathParserResult.cs @@ -8,7 +8,7 @@ namespace Emby.Naming.TV public int? EpisodeNumber { get; set; } - public int? EndingEpsiodeNumber { get; set; } + public int? EndingEpisodeNumber { get; set; } public string? SeriesName { get; set; } diff --git a/Emby.Naming/TV/EpisodeResolver.cs b/Emby.Naming/TV/EpisodeResolver.cs index 002de2117..5f02c553d 100644 --- a/Emby.Naming/TV/EpisodeResolver.cs +++ b/Emby.Naming/TV/EpisodeResolver.cs @@ -58,7 +58,7 @@ namespace Emby.Naming.TV { Container = container, IsStub = isStub, - EndingEpsiodeNumber = parsingResult.EndingEpsiodeNumber, + EndingEpisodeNumber = parsingResult.EndingEpisodeNumber, EpisodeNumber = parsingResult.EpisodeNumber, SeasonNumber = parsingResult.SeasonNumber, SeriesName = parsingResult.SeriesName, diff --git a/Emby.Naming/TV/SeasonPathParser.cs b/Emby.Naming/TV/SeasonPathParser.cs index d2e324dda..142680f0c 100644 --- a/Emby.Naming/TV/SeasonPathParser.cs +++ b/Emby.Naming/TV/SeasonPathParser.cs @@ -101,9 +101,9 @@ namespace Emby.Naming.TV } var parts = filename.Split(new[] { '.', '_', ' ', '-' }, StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < parts.Length; i++) + foreach (var part in parts) { - if (TryGetSeasonNumberFromPart(parts[i], out int seasonNumber)) + if (TryGetSeasonNumberFromPart(part, out int seasonNumber)) { return (seasonNumber, true); } @@ -139,7 +139,7 @@ namespace Emby.Naming.TV var numericStart = -1; var length = 0; - var hasOpenParenth = false; + var hasOpenParenthesis = false; var isSeasonFolder = true; // Find out where the numbers start, and then keep going until they end @@ -147,7 +147,7 @@ namespace Emby.Naming.TV { if (char.IsNumber(path[i])) { - if (!hasOpenParenth) + if (!hasOpenParenthesis) { if (numericStart == -1) { @@ -167,11 +167,11 @@ namespace Emby.Naming.TV var currentChar = path[i]; if (currentChar == '(') { - hasOpenParenth = true; + hasOpenParenthesis = true; } else if (currentChar == ')') { - hasOpenParenth = false; + hasOpenParenthesis = false; } } diff --git a/Emby.Naming/Video/ExtraRuleType.cs b/Emby.Naming/Video/ExtraRuleType.cs index e89876f4a..98114c7e8 100644 --- a/Emby.Naming/Video/ExtraRuleType.cs +++ b/Emby.Naming/Video/ExtraRuleType.cs @@ -22,6 +22,6 @@ namespace Emby.Naming.Video /// /// Match against the name of the directory containing the file. /// - DirectoryName = 3, + DirectoryName = 3 } } diff --git a/Emby.Naming/Video/FlagParser.cs b/Emby.Naming/Video/FlagParser.cs index a8bd9d5c5..27ca1abf1 100644 --- a/Emby.Naming/Video/FlagParser.cs +++ b/Emby.Naming/Video/FlagParser.cs @@ -20,7 +20,7 @@ namespace Emby.Naming.Video return GetFlags(path, _options.VideoFlagDelimiters); } - public string[] GetFlags(string path, char[] delimeters) + public string[] GetFlags(string path, char[] delimiters) { if (string.IsNullOrEmpty(path)) { @@ -31,7 +31,7 @@ namespace Emby.Naming.Video var file = Path.GetFileName(path); - return file.Split(delimeters, StringSplitOptions.RemoveEmptyEntries); + return file.Split(delimiters, StringSplitOptions.RemoveEmptyEntries); } } } diff --git a/Emby.Naming/Video/Format3DParser.cs b/Emby.Naming/Video/Format3DParser.cs index 3a9eaa1a1..fb881f978 100644 --- a/Emby.Naming/Video/Format3DParser.cs +++ b/Emby.Naming/Video/Format3DParser.cs @@ -18,11 +18,11 @@ namespace Emby.Naming.Video public Format3DResult Parse(string path) { int oldLen = _options.VideoFlagDelimiters.Length; - var delimeters = new char[oldLen + 1]; - _options.VideoFlagDelimiters.CopyTo(delimeters, 0); - delimeters[oldLen] = ' '; + var delimiters = new char[oldLen + 1]; + _options.VideoFlagDelimiters.CopyTo(delimiters, 0); + delimiters[oldLen] = ' '; - return Parse(new FlagParser(_options).GetFlags(path, delimeters)); + return Parse(new FlagParser(_options).GetFlags(path, delimiters)); } internal Format3DResult Parse(string[] videoFlags) @@ -44,7 +44,7 @@ namespace Emby.Naming.Video { var result = new Format3DResult(); - if (string.IsNullOrEmpty(rule.PreceedingToken)) + if (string.IsNullOrEmpty(rule.PrecedingToken)) { result.Format3D = new[] { rule.Token }.FirstOrDefault(i => videoFlags.Contains(i, StringComparer.OrdinalIgnoreCase)); result.Is3D = !string.IsNullOrEmpty(result.Format3D); @@ -63,7 +63,7 @@ namespace Emby.Naming.Video { if (foundPrefix) { - result.Tokens.Add(rule.PreceedingToken); + result.Tokens.Add(rule.PrecedingToken); if (string.Equals(rule.Token, flag, StringComparison.OrdinalIgnoreCase)) { @@ -74,7 +74,7 @@ namespace Emby.Naming.Video break; } - foundPrefix = string.Equals(flag, rule.PreceedingToken, StringComparison.OrdinalIgnoreCase); + foundPrefix = string.Equals(flag, rule.PrecedingToken, StringComparison.OrdinalIgnoreCase); } result.Is3D = foundPrefix && !string.IsNullOrEmpty(format); diff --git a/Emby.Naming/Video/Format3DRule.cs b/Emby.Naming/Video/Format3DRule.cs index a35f0d9d9..7679164b3 100644 --- a/Emby.Naming/Video/Format3DRule.cs +++ b/Emby.Naming/Video/Format3DRule.cs @@ -4,10 +4,10 @@ namespace Emby.Naming.Video { public class Format3DRule { - public Format3DRule(string token, string? preceedingToken = null) + public Format3DRule(string token, string? precedingToken = null) { Token = token; - PreceedingToken = preceedingToken; + PrecedingToken = precedingToken; } /// @@ -17,9 +17,9 @@ namespace Emby.Naming.Video public string Token { get; set; } /// - /// Gets or sets the preceeding token. + /// Gets or sets the preceding token. /// - /// The preceeding token. - public string? PreceedingToken { get; set; } + /// The preceding token. + public string? PrecedingToken { get; set; } } } diff --git a/Emby.Naming/Video/StubResult.cs b/Emby.Naming/Video/StubResult.cs deleted file mode 100644 index 1b8e99b0d..000000000 --- a/Emby.Naming/Video/StubResult.cs +++ /dev/null @@ -1,19 +0,0 @@ -#pragma warning disable CS1591 - -namespace Emby.Naming.Video -{ - public struct StubResult - { - /// - /// Gets or sets a value indicating whether this instance is stub. - /// - /// true if this instance is stub; otherwise, false. - public bool IsStub { get; set; } - - /// - /// Gets or sets the type of the stub. - /// - /// The type of the stub. - public string StubType { get; set; } - } -} diff --git a/Emby.Naming/Video/VideoListResolver.cs b/Emby.Naming/Video/VideoListResolver.cs index 601c6c0b6..190562cfc 100644 --- a/Emby.Naming/Video/VideoListResolver.cs +++ b/Emby.Naming/Video/VideoListResolver.cs @@ -136,7 +136,7 @@ namespace Emby.Naming.Video } // If there's only one video, accept all trailers - // Be lenient because people use all kinds of mish mash conventions with trailers + // Be lenient because people use all kinds of mishmash conventions with trailers if (list.Count == 1) { var trailers = remainingFiles diff --git a/Emby.Server.Implementations/Library/LibraryManager.cs b/Emby.Server.Implementations/Library/LibraryManager.cs index e121e9eaf..6f85a2408 100644 --- a/Emby.Server.Implementations/Library/LibraryManager.cs +++ b/Emby.Server.Implementations/Library/LibraryManager.cs @@ -2562,12 +2562,12 @@ namespace Emby.Server.Implementations.Library if (!episode.IndexNumberEnd.HasValue || forceRefresh) { - if (episode.IndexNumberEnd != episodeInfo.EndingEpsiodeNumber) + if (episode.IndexNumberEnd != episodeInfo.EndingEpisodeNumber) { changed = true; } - episode.IndexNumberEnd = episodeInfo.EndingEpsiodeNumber; + episode.IndexNumberEnd = episodeInfo.EndingEpisodeNumber; } if (!episode.ParentIndexNumber.HasValue || forceRefresh) diff --git a/tests/Jellyfin.Naming.Tests/TV/MultiEpisodeTests.cs b/tests/Jellyfin.Naming.Tests/TV/MultiEpisodeTests.cs index 3513050b6..58ea0bec5 100644 --- a/tests/Jellyfin.Naming.Tests/TV/MultiEpisodeTests.cs +++ b/tests/Jellyfin.Naming.Tests/TV/MultiEpisodeTests.cs @@ -74,7 +74,7 @@ namespace Jellyfin.Naming.Tests.TV var result = new EpisodePathParser(options) .Parse(filename, false); - Assert.Equal(result.EndingEpsiodeNumber, endingEpisodeNumber); + Assert.Equal(result.EndingEpisodeNumber, endingEpisodeNumber); } } } -- cgit v1.2.3 From 693760e38ae51b9267f9383c3957df742bb136a6 Mon Sep 17 00:00:00 2001 From: Stepan Date: Tue, 10 Nov 2020 17:11:48 +0100 Subject: Xml-doc part1 --- Emby.Naming/Audio/AlbumParser.cs | 15 +++++++-- Emby.Naming/Audio/AudioFileParser.cs | 12 +++++-- Emby.Naming/AudioBook/AudioBookFilePathParser.cs | 15 +++++++-- .../AudioBook/AudioBookFilePathParserResult.cs | 12 +++++-- Emby.Naming/AudioBook/AudioBookListResolver.cs | 14 ++++++-- Emby.Naming/AudioBook/AudioBookNameParser.cs | 15 +++++++-- Emby.Naming/AudioBook/AudioBookNameParserResult.cs | 12 +++++-- Emby.Naming/AudioBook/AudioBookResolver.cs | 15 +++++++-- Emby.Naming/Common/EpisodeExpression.cs | 38 +++++++++++++++++----- Emby.Naming/Common/MediaType.cs | 2 -- Emby.Naming/Common/NamingOptions.cs | 2 -- Emby.Naming/Subtitles/SubtitleInfo.cs | 2 -- Emby.Naming/Subtitles/SubtitleParser.cs | 3 -- Emby.Naming/TV/EpisodeInfo.cs | 30 +++++++++++++++-- Emby.Naming/TV/EpisodePathParser.cs | 20 ++++++++++-- Emby.Naming/TV/EpisodePathParserResult.cs | 33 +++++++++++++++++-- Emby.Naming/TV/EpisodeResolver.cs | 3 -- Emby.Naming/TV/SeasonPathParser.cs | 2 -- Emby.Naming/TV/SeasonPathParserResult.cs | 2 -- Emby.Naming/Video/CleanDateTimeParser.cs | 9 +++-- Emby.Naming/Video/CleanDateTimeResult.cs | 19 +++++------ Emby.Naming/Video/CleanStringParser.cs | 10 ++++-- Emby.Naming/Video/ExtraResolver.cs | 3 -- Emby.Naming/Video/ExtraResult.cs | 2 -- Emby.Naming/Video/ExtraRule.cs | 2 -- Emby.Naming/Video/ExtraRuleType.cs | 5 +-- Emby.Naming/Video/FileStack.cs | 2 -- Emby.Naming/Video/FlagParser.cs | 2 -- Emby.Naming/Video/Format3DParser.cs | 2 -- Emby.Naming/Video/Format3DResult.cs | 2 -- Emby.Naming/Video/Format3DRule.cs | 2 -- Emby.Naming/Video/StackResolver.cs | 2 -- Emby.Naming/Video/StubResolver.cs | 3 -- Emby.Naming/Video/StubTypeRule.cs | 2 -- Emby.Naming/Video/VideoListResolver.cs | 2 -- Emby.Naming/Video/VideoResolver.cs | 3 -- 36 files changed, 218 insertions(+), 101 deletions(-) (limited to 'Emby.Naming/Video/Format3DParser.cs') diff --git a/Emby.Naming/Audio/AlbumParser.cs b/Emby.Naming/Audio/AlbumParser.cs index b63be3a64..bbfdccc90 100644 --- a/Emby.Naming/Audio/AlbumParser.cs +++ b/Emby.Naming/Audio/AlbumParser.cs @@ -1,6 +1,3 @@ -#nullable enable -#pragma warning disable CS1591 - using System; using System.Globalization; using System.IO; @@ -9,15 +6,27 @@ using Emby.Naming.Common; namespace Emby.Naming.Audio { + /// + /// Helper class to determine if Album is multipart. + /// public class AlbumParser { private readonly NamingOptions _options; + /// + /// Initializes a new instance of the class. + /// + /// Naming options containing AlbumStackingPrefixes. public AlbumParser(NamingOptions options) { _options = options; } + /// + /// Function that determines if album is multipart. + /// + /// Path to file. + /// True if album is multipart. public bool IsMultiPart(string path) { var filename = Path.GetFileName(path); diff --git a/Emby.Naming/Audio/AudioFileParser.cs b/Emby.Naming/Audio/AudioFileParser.cs index 6b2f4be93..8b47dd12e 100644 --- a/Emby.Naming/Audio/AudioFileParser.cs +++ b/Emby.Naming/Audio/AudioFileParser.cs @@ -1,6 +1,3 @@ -#nullable enable -#pragma warning disable CS1591 - using System; using System.IO; using System.Linq; @@ -8,8 +5,17 @@ using Emby.Naming.Common; namespace Emby.Naming.Audio { + /// + /// Static helper class to determine if file at path is audio file. + /// public static class AudioFileParser { + /// + /// Static helper method to determine if file at path is audio file. + /// + /// Path to file. + /// containing AudioFileExtensions. + /// True if file at path is audio file. public static bool IsAudioFile(string path, NamingOptions options) { var extension = Path.GetExtension(path); diff --git a/Emby.Naming/AudioBook/AudioBookFilePathParser.cs b/Emby.Naming/AudioBook/AudioBookFilePathParser.cs index 56580f194..7b4429ab1 100644 --- a/Emby.Naming/AudioBook/AudioBookFilePathParser.cs +++ b/Emby.Naming/AudioBook/AudioBookFilePathParser.cs @@ -1,6 +1,3 @@ -#nullable enable -#pragma warning disable CS1591 - using System.Globalization; using System.IO; using System.Text.RegularExpressions; @@ -8,15 +5,27 @@ using Emby.Naming.Common; namespace Emby.Naming.AudioBook { + /// + /// Parser class to extract part and/or chapter number from audiobook filename. + /// public class AudioBookFilePathParser { private readonly NamingOptions _options; + /// + /// Initializes a new instance of the class. + /// + /// Naming options containing AudioBookPartsExpressions. public AudioBookFilePathParser(NamingOptions options) { _options = options; } + /// + /// Based on regex determines if filename includes part/chapter number. + /// + /// Path to audiobook file. + /// Returns object. public AudioBookFilePathParserResult Parse(string path) { AudioBookFilePathParserResult result = default; diff --git a/Emby.Naming/AudioBook/AudioBookFilePathParserResult.cs b/Emby.Naming/AudioBook/AudioBookFilePathParserResult.cs index b65d231df..48ab8b57d 100644 --- a/Emby.Naming/AudioBook/AudioBookFilePathParserResult.cs +++ b/Emby.Naming/AudioBook/AudioBookFilePathParserResult.cs @@ -1,12 +1,18 @@ -#nullable enable -#pragma warning disable CS1591 - namespace Emby.Naming.AudioBook { + /// + /// Data object for passing result of audiobook part/chapter extraction. + /// public struct AudioBookFilePathParserResult { + /// + /// Gets or sets optional number of path extracted from audiobook filename. + /// public int? PartNumber { get; set; } + /// + /// Gets or sets optional number of chapter extracted from audiobook filename. + /// public int? ChapterNumber { get; set; } } } diff --git a/Emby.Naming/AudioBook/AudioBookListResolver.cs b/Emby.Naming/AudioBook/AudioBookListResolver.cs index e8908aa37..b203f9902 100644 --- a/Emby.Naming/AudioBook/AudioBookListResolver.cs +++ b/Emby.Naming/AudioBook/AudioBookListResolver.cs @@ -1,5 +1,3 @@ -#pragma warning disable CS1591 - using System; using System.Collections.Generic; using System.IO; @@ -10,15 +8,27 @@ using MediaBrowser.Model.IO; namespace Emby.Naming.AudioBook { + /// + /// Class used to resolve Name, Year, alternative files and extras from stack of files. + /// public class AudioBookListResolver { private readonly NamingOptions _options; + /// + /// Initializes a new instance of the class. + /// + /// Naming options passed along to and . public AudioBookListResolver(NamingOptions options) { _options = options; } + /// + /// Resolves Name, Year and differentiate alternative files and extras from regular audiobook files. + /// + /// List of files related to audiobook. + /// Returns IEnumerable of . public IEnumerable Resolve(IEnumerable files) { var audioBookResolver = new AudioBookResolver(_options); diff --git a/Emby.Naming/AudioBook/AudioBookNameParser.cs b/Emby.Naming/AudioBook/AudioBookNameParser.cs index 7c8616124..120482bc2 100644 --- a/Emby.Naming/AudioBook/AudioBookNameParser.cs +++ b/Emby.Naming/AudioBook/AudioBookNameParser.cs @@ -1,21 +1,30 @@ -#nullable enable -#pragma warning disable CS1591 - using System.Globalization; using System.Text.RegularExpressions; using Emby.Naming.Common; namespace Emby.Naming.AudioBook { + /// + /// Helper class to retrieve name and year from audiobook previously retrieved name. + /// public class AudioBookNameParser { private readonly NamingOptions _options; + /// + /// Initializes a new instance of the class. + /// + /// Naming options containing AudioBookNamesExpressions. public AudioBookNameParser(NamingOptions options) { _options = options; } + /// + /// Parse name and year from previously determined name of audiobook. + /// + /// Name of the audiobook. + /// Returns object. public AudioBookNameParserResult Parse(string name) { AudioBookNameParserResult result = default; diff --git a/Emby.Naming/AudioBook/AudioBookNameParserResult.cs b/Emby.Naming/AudioBook/AudioBookNameParserResult.cs index b28e259dd..3f2d7b2b0 100644 --- a/Emby.Naming/AudioBook/AudioBookNameParserResult.cs +++ b/Emby.Naming/AudioBook/AudioBookNameParserResult.cs @@ -1,12 +1,18 @@ -#nullable enable -#pragma warning disable CS1591 - namespace Emby.Naming.AudioBook { + /// + /// Data object used to pass result of name and year parsing. + /// public struct AudioBookNameParserResult { + /// + /// Gets or sets name of audiobook. + /// public string Name { get; set; } + /// + /// Gets or sets optional year of release. + /// public int? Year { get; set; } } } diff --git a/Emby.Naming/AudioBook/AudioBookResolver.cs b/Emby.Naming/AudioBook/AudioBookResolver.cs index c7b3b2d2d..f6ad3601d 100644 --- a/Emby.Naming/AudioBook/AudioBookResolver.cs +++ b/Emby.Naming/AudioBook/AudioBookResolver.cs @@ -1,6 +1,3 @@ -#nullable enable -#pragma warning disable CS1591 - using System; using System.IO; using System.Linq; @@ -8,15 +5,27 @@ using Emby.Naming.Common; namespace Emby.Naming.AudioBook { + /// + /// Resolve specifics (path, container, partNumber, chapterNumber) about audiobook file. + /// public class AudioBookResolver { private readonly NamingOptions _options; + /// + /// Initializes a new instance of the class. + /// + /// containing AudioFileExtensions and also used to pass to AudioBookFilePathParser. public AudioBookResolver(NamingOptions options) { _options = options; } + /// + /// Resolve specifics (path, container, partNumber, chapterNumber) about audiobook file. + /// + /// Path to audiobook file. + /// Returns object. public AudioBookFileInfo? Resolve(string path) { if (path.Length == 0 || Path.GetFileNameWithoutExtension(path).Length == 0) diff --git a/Emby.Naming/Common/EpisodeExpression.cs b/Emby.Naming/Common/EpisodeExpression.cs index 00b27541a..19d3c7aab 100644 --- a/Emby.Naming/Common/EpisodeExpression.cs +++ b/Emby.Naming/Common/EpisodeExpression.cs @@ -1,16 +1,22 @@ -#pragma warning disable CS1591 - using System; using System.Text.RegularExpressions; namespace Emby.Naming.Common { + /// + /// Regular expressions for parsing TV Episodes. + /// public class EpisodeExpression { private string _expression; private Regex? _regex; - public EpisodeExpression(string expression, bool byDate) + /// + /// Initializes a new instance of the class. + /// + /// Regular expressions. + /// True if date is expected. + public EpisodeExpression(string expression, bool byDate = false) { _expression = expression; IsByDate = byDate; @@ -18,11 +24,9 @@ namespace Emby.Naming.Common SupportsAbsoluteEpisodeNumbers = true; } - public EpisodeExpression(string expression) - : this(expression, false) - { - } - + /// + /// Gets or sets raw expressions string. + /// public string Expression { get => _expression; @@ -33,16 +37,34 @@ namespace Emby.Naming.Common } } + /// + /// Gets or sets a value indicating whether gets or sets property indicating if date can be find in expression. + /// public bool IsByDate { get; set; } + /// + /// Gets or sets a value indicating whether gets or sets property indicating if expression is optimistic. + /// public bool IsOptimistic { get; set; } + /// + /// Gets or sets a value indicating whether gets or sets property indicating if expression is named. + /// public bool IsNamed { get; set; } + /// + /// Gets or sets a value indicating whether gets or sets property indicating if expression supports episodes with absolute numbers. + /// public bool SupportsAbsoluteEpisodeNumbers { get; set; } + /// + /// Gets or sets optional list of date formats used for date parsing. + /// public string[] DateTimeFormats { get; set; } + /// + /// Gets a expressions objects (creates it if null). + /// public Regex Regex => _regex ??= new Regex(Expression, RegexOptions.IgnoreCase | RegexOptions.Compiled); } } diff --git a/Emby.Naming/Common/MediaType.cs b/Emby.Naming/Common/MediaType.cs index 148833765..1231b1887 100644 --- a/Emby.Naming/Common/MediaType.cs +++ b/Emby.Naming/Common/MediaType.cs @@ -1,5 +1,3 @@ -#pragma warning disable CS1591 - namespace Emby.Naming.Common { public enum MediaType diff --git a/Emby.Naming/Common/NamingOptions.cs b/Emby.Naming/Common/NamingOptions.cs index 471491d22..0f02c03cb 100644 --- a/Emby.Naming/Common/NamingOptions.cs +++ b/Emby.Naming/Common/NamingOptions.cs @@ -1,5 +1,3 @@ -#pragma warning disable CS1591 - using System; using System.Linq; using System.Text.RegularExpressions; diff --git a/Emby.Naming/Subtitles/SubtitleInfo.cs b/Emby.Naming/Subtitles/SubtitleInfo.cs index 2f16fb2df..62cc3ead1 100644 --- a/Emby.Naming/Subtitles/SubtitleInfo.cs +++ b/Emby.Naming/Subtitles/SubtitleInfo.cs @@ -1,5 +1,3 @@ -#pragma warning disable CS1591 - namespace Emby.Naming.Subtitles { public class SubtitleInfo diff --git a/Emby.Naming/Subtitles/SubtitleParser.cs b/Emby.Naming/Subtitles/SubtitleParser.cs index c8659e1b2..476a83cf3 100644 --- a/Emby.Naming/Subtitles/SubtitleParser.cs +++ b/Emby.Naming/Subtitles/SubtitleParser.cs @@ -1,6 +1,3 @@ -#nullable enable -#pragma warning disable CS1591 - using System; using System.IO; using System.Linq; diff --git a/Emby.Naming/TV/EpisodeInfo.cs b/Emby.Naming/TV/EpisodeInfo.cs index e01c81062..a8920b36a 100644 --- a/Emby.Naming/TV/EpisodeInfo.cs +++ b/Emby.Naming/TV/EpisodeInfo.cs @@ -1,9 +1,14 @@ -#pragma warning disable CS1591 - namespace Emby.Naming.TV { + /// + /// Holder object for Episode information. + /// public class EpisodeInfo { + /// + /// Initializes a new instance of the class. + /// + /// Path to the file. public EpisodeInfo(string path) { Path = path; @@ -51,18 +56,39 @@ namespace Emby.Naming.TV /// The type of the stub. public string? StubType { get; set; } + /// + /// Gets or sets optional season number. + /// public int? SeasonNumber { get; set; } + /// + /// Gets or sets optional episode number. + /// public int? EpisodeNumber { get; set; } + /// + /// Gets or sets optional ending episode number. For multi-episode files 1-13. + /// public int? EndingEpisodeNumber { get; set; } + /// + /// Gets or sets optional year of release. + /// public int? Year { get; set; } + /// + /// Gets or sets optional year of release. + /// public int? Month { get; set; } + /// + /// Gets or sets optional day of release. + /// public int? Day { get; set; } + /// + /// Gets or sets a value indicating whether by date expression was used. + /// public bool IsByDate { get; set; } } } diff --git a/Emby.Naming/TV/EpisodePathParser.cs b/Emby.Naming/TV/EpisodePathParser.cs index d9cc8172b..6d0597356 100644 --- a/Emby.Naming/TV/EpisodePathParser.cs +++ b/Emby.Naming/TV/EpisodePathParser.cs @@ -1,6 +1,3 @@ -#pragma warning disable CS1591 -#nullable enable - using System; using System.Collections.Generic; using System.Globalization; @@ -9,15 +6,32 @@ using Emby.Naming.Common; namespace Emby.Naming.TV { + /// + /// Used to parse information about episode from path. + /// public class EpisodePathParser { private readonly NamingOptions _options; + /// + /// Initializes a new instance of the class. + /// + /// object containing EpisodeExpressions and MultipleEpisodeExpressions. public EpisodePathParser(NamingOptions options) { _options = options; } + /// + /// Parses information about episode from path. + /// + /// Path. + /// Is path for a directory or file. + /// Do we want to use IsNamed expressions. + /// Do we want to use Optimistic expressions. + /// Do we want to use expressions supporting absolute episode numbers. + /// Should we attempt to retrieve extended information. + /// Returns object. public EpisodePathParserResult Parse( string path, bool isDirectory, diff --git a/Emby.Naming/TV/EpisodePathParserResult.cs b/Emby.Naming/TV/EpisodePathParserResult.cs index 5fa0b6f0b..233d5a4f6 100644 --- a/Emby.Naming/TV/EpisodePathParserResult.cs +++ b/Emby.Naming/TV/EpisodePathParserResult.cs @@ -1,25 +1,54 @@ -#pragma warning disable CS1591 - namespace Emby.Naming.TV { + /// + /// Holder object for result. + /// public class EpisodePathParserResult { + /// + /// Gets or sets optional season number. + /// public int? SeasonNumber { get; set; } + /// + /// Gets or sets optional episode number. + /// public int? EpisodeNumber { get; set; } + /// + /// Gets or sets optional ending episode number. For multi-episode files 1-13. + /// public int? EndingEpisodeNumber { get; set; } + /// + /// Gets or sets the name of the series. + /// + /// The name of the series. public string? SeriesName { get; set; } + /// + /// Gets or sets a value indicating whether parsing was successful. + /// public bool Success { get; set; } + /// + /// Gets or sets a value indicating whether by date expression was used. + /// public bool IsByDate { get; set; } + /// + /// Gets or sets optional year of release. + /// public int? Year { get; set; } + /// + /// Gets or sets optional year of release. + /// public int? Month { get; set; } + /// + /// Gets or sets optional day of release. + /// public int? Day { get; set; } } } diff --git a/Emby.Naming/TV/EpisodeResolver.cs b/Emby.Naming/TV/EpisodeResolver.cs index 5f02c553d..26dd6915b 100644 --- a/Emby.Naming/TV/EpisodeResolver.cs +++ b/Emby.Naming/TV/EpisodeResolver.cs @@ -1,6 +1,3 @@ -#pragma warning disable CS1591 -#nullable enable - using System; using System.IO; using System.Linq; diff --git a/Emby.Naming/TV/SeasonPathParser.cs b/Emby.Naming/TV/SeasonPathParser.cs index 142680f0c..cf99097bc 100644 --- a/Emby.Naming/TV/SeasonPathParser.cs +++ b/Emby.Naming/TV/SeasonPathParser.cs @@ -1,5 +1,3 @@ -#pragma warning disable CS1591 - using System; using System.Globalization; using System.IO; diff --git a/Emby.Naming/TV/SeasonPathParserResult.cs b/Emby.Naming/TV/SeasonPathParserResult.cs index a142fafea..f52f941a7 100644 --- a/Emby.Naming/TV/SeasonPathParserResult.cs +++ b/Emby.Naming/TV/SeasonPathParserResult.cs @@ -1,5 +1,3 @@ -#pragma warning disable CS1591 - namespace Emby.Naming.TV { public class SeasonPathParserResult diff --git a/Emby.Naming/Video/CleanDateTimeParser.cs b/Emby.Naming/Video/CleanDateTimeParser.cs index f05d540f8..0ee633dcc 100644 --- a/Emby.Naming/Video/CleanDateTimeParser.cs +++ b/Emby.Naming/Video/CleanDateTimeParser.cs @@ -1,6 +1,3 @@ -#pragma warning disable CS1591 -#nullable enable - using System.Collections.Generic; using System.Globalization; using System.Text.RegularExpressions; @@ -12,6 +9,12 @@ namespace Emby.Naming.Video /// public static class CleanDateTimeParser { + /// + /// Attempts to clean the name. + /// + /// Name of video. + /// Optional list of regexes to clean the name. + /// Returns object. public static CleanDateTimeResult Clean(string name, IReadOnlyList cleanDateTimeRegexes) { CleanDateTimeResult result = new CleanDateTimeResult(name); diff --git a/Emby.Naming/Video/CleanDateTimeResult.cs b/Emby.Naming/Video/CleanDateTimeResult.cs index 57eeaa7e3..c675a19d0 100644 --- a/Emby.Naming/Video/CleanDateTimeResult.cs +++ b/Emby.Naming/Video/CleanDateTimeResult.cs @@ -1,22 +1,21 @@ -#pragma warning disable CS1591 -#nullable enable - namespace Emby.Naming.Video { + /// + /// Holder structure for name and year. + /// public readonly struct CleanDateTimeResult { - public CleanDateTimeResult(string name, int? year) + /// + /// Initializes a new instance of the struct. + /// + /// Name of video. + /// Year of release. + public CleanDateTimeResult(string name, int? year = null) { Name = name; Year = year; } - public CleanDateTimeResult(string name) - { - Name = name; - Year = null; - } - /// /// Gets the name. /// diff --git a/Emby.Naming/Video/CleanStringParser.cs b/Emby.Naming/Video/CleanStringParser.cs index 3f584d584..09a0cd189 100644 --- a/Emby.Naming/Video/CleanStringParser.cs +++ b/Emby.Naming/Video/CleanStringParser.cs @@ -1,6 +1,3 @@ -#pragma warning disable CS1591 -#nullable enable - using System; using System.Collections.Generic; using System.Text.RegularExpressions; @@ -12,6 +9,13 @@ namespace Emby.Naming.Video /// public static class CleanStringParser { + /// + /// Attempts to extract clean name with regular expressions. + /// + /// Name of file. + /// List of regex to parse name and year from. + /// Parsing result string. + /// True if parsing was successful. public static bool TryClean(string name, IReadOnlyList expressions, out ReadOnlySpan newName) { var len = expressions.Count; diff --git a/Emby.Naming/Video/ExtraResolver.cs b/Emby.Naming/Video/ExtraResolver.cs index bd78299dc..98ea342ac 100644 --- a/Emby.Naming/Video/ExtraResolver.cs +++ b/Emby.Naming/Video/ExtraResolver.cs @@ -1,9 +1,6 @@ -#pragma warning disable CS1591 - using System; using System.IO; using System.Linq; -using System.Text.RegularExpressions; using Emby.Naming.Audio; using Emby.Naming.Common; diff --git a/Emby.Naming/Video/ExtraResult.cs b/Emby.Naming/Video/ExtraResult.cs index 6be7e6052..f3b8d2a2f 100644 --- a/Emby.Naming/Video/ExtraResult.cs +++ b/Emby.Naming/Video/ExtraResult.cs @@ -1,5 +1,3 @@ -#pragma warning disable CS1591 - using MediaBrowser.Model.Entities; namespace Emby.Naming.Video diff --git a/Emby.Naming/Video/ExtraRule.cs b/Emby.Naming/Video/ExtraRule.cs index c018894fd..a93474bc6 100644 --- a/Emby.Naming/Video/ExtraRule.cs +++ b/Emby.Naming/Video/ExtraRule.cs @@ -1,5 +1,3 @@ -#pragma warning disable CS1591 - using MediaBrowser.Model.Entities; using MediaType = Emby.Naming.Common.MediaType; diff --git a/Emby.Naming/Video/ExtraRuleType.cs b/Emby.Naming/Video/ExtraRuleType.cs index 98114c7e8..324319505 100644 --- a/Emby.Naming/Video/ExtraRuleType.cs +++ b/Emby.Naming/Video/ExtraRuleType.cs @@ -1,7 +1,8 @@ -#pragma warning disable CS1591 - namespace Emby.Naming.Video { + /// + /// Extra rules type to determine against what should be matched. + /// public enum ExtraRuleType { /// diff --git a/Emby.Naming/Video/FileStack.cs b/Emby.Naming/Video/FileStack.cs index b0a22b18b..75620e961 100644 --- a/Emby.Naming/Video/FileStack.cs +++ b/Emby.Naming/Video/FileStack.cs @@ -1,5 +1,3 @@ -#pragma warning disable CS1591 - using System; using System.Collections.Generic; using System.Linq; diff --git a/Emby.Naming/Video/FlagParser.cs b/Emby.Naming/Video/FlagParser.cs index 6015c41a0..cd15b4666 100644 --- a/Emby.Naming/Video/FlagParser.cs +++ b/Emby.Naming/Video/FlagParser.cs @@ -1,5 +1,3 @@ -#pragma warning disable CS1591 - using System; using System.IO; using Emby.Naming.Common; diff --git a/Emby.Naming/Video/Format3DParser.cs b/Emby.Naming/Video/Format3DParser.cs index fb881f978..73ad36af4 100644 --- a/Emby.Naming/Video/Format3DParser.cs +++ b/Emby.Naming/Video/Format3DParser.cs @@ -1,5 +1,3 @@ -#pragma warning disable CS1591 - using System; using System.Linq; using Emby.Naming.Common; diff --git a/Emby.Naming/Video/Format3DResult.cs b/Emby.Naming/Video/Format3DResult.cs index 36dc1c12b..539060c98 100644 --- a/Emby.Naming/Video/Format3DResult.cs +++ b/Emby.Naming/Video/Format3DResult.cs @@ -1,5 +1,3 @@ -#pragma warning disable CS1591 - using System.Collections.Generic; namespace Emby.Naming.Video diff --git a/Emby.Naming/Video/Format3DRule.cs b/Emby.Naming/Video/Format3DRule.cs index 7679164b3..bee5c109e 100644 --- a/Emby.Naming/Video/Format3DRule.cs +++ b/Emby.Naming/Video/Format3DRule.cs @@ -1,5 +1,3 @@ -#pragma warning disable CS1591 - namespace Emby.Naming.Video { public class Format3DRule diff --git a/Emby.Naming/Video/StackResolver.cs b/Emby.Naming/Video/StackResolver.cs index 30b812e21..d6de468cc 100644 --- a/Emby.Naming/Video/StackResolver.cs +++ b/Emby.Naming/Video/StackResolver.cs @@ -1,5 +1,3 @@ -#pragma warning disable CS1591 - using System; using System.Collections.Generic; using System.IO; diff --git a/Emby.Naming/Video/StubResolver.cs b/Emby.Naming/Video/StubResolver.cs index b0eb92e53..6241a46b0 100644 --- a/Emby.Naming/Video/StubResolver.cs +++ b/Emby.Naming/Video/StubResolver.cs @@ -1,6 +1,3 @@ -#pragma warning disable CS1591 -#nullable enable - using System; using System.IO; using System.Linq; diff --git a/Emby.Naming/Video/StubTypeRule.cs b/Emby.Naming/Video/StubTypeRule.cs index fa42af604..df2d3c7d2 100644 --- a/Emby.Naming/Video/StubTypeRule.cs +++ b/Emby.Naming/Video/StubTypeRule.cs @@ -1,5 +1,3 @@ -#pragma warning disable CS1591 - namespace Emby.Naming.Video { public class StubTypeRule diff --git a/Emby.Naming/Video/VideoListResolver.cs b/Emby.Naming/Video/VideoListResolver.cs index be9b4959a..dda322521 100644 --- a/Emby.Naming/Video/VideoListResolver.cs +++ b/Emby.Naming/Video/VideoListResolver.cs @@ -1,5 +1,3 @@ -#pragma warning disable CS1591 - using System; using System.Collections.Generic; using System.IO; diff --git a/Emby.Naming/Video/VideoResolver.cs b/Emby.Naming/Video/VideoResolver.cs index fed567d03..31b47cdf1 100644 --- a/Emby.Naming/Video/VideoResolver.cs +++ b/Emby.Naming/Video/VideoResolver.cs @@ -1,6 +1,3 @@ -#pragma warning disable CS1591 -#nullable enable - using System; using System.IO; using System.Linq; -- cgit v1.2.3 From 158eff62d75db2d5e6e6f09fbe6e03eac607fc56 Mon Sep 17 00:00:00 2001 From: Stepan Date: Tue, 10 Nov 2020 19:23:10 +0100 Subject: Xml-doc part2 --- Emby.Naming/Common/MediaType.cs | 3 + Emby.Naming/Common/NamingOptions.cs | 87 ++++++++++++++++++++++ Emby.Naming/Subtitles/SubtitleInfo.cs | 9 +++ Emby.Naming/Subtitles/SubtitleParser.cs | 14 +++- Emby.Naming/TV/EpisodeResolver.cs | 17 +++++ Emby.Naming/TV/SeasonPathParser.cs | 10 +++ Emby.Naming/TV/SeasonPathParserResult.cs | 7 ++ Emby.Naming/Video/ExtraResolver.cs | 12 +++ Emby.Naming/Video/ExtraResult.cs | 3 + Emby.Naming/Video/ExtraRule.cs | 7 ++ Emby.Naming/Video/FileStack.cs | 21 ++++++ Emby.Naming/Video/FlagParser.cs | 18 +++++ Emby.Naming/Video/Format3DParser.cs | 12 +++ Emby.Naming/Video/Format3DResult.cs | 6 ++ Emby.Naming/Video/Format3DRule.cs | 8 ++ Emby.Naming/Video/StackResolver.cs | 27 +++++++ Emby.Naming/Video/StubResolver.cs | 10 +++ Emby.Naming/Video/StubTypeRule.cs | 8 ++ Emby.Naming/Video/VideoListResolver.cs | 13 ++++ Emby.Naming/Video/VideoResolver.cs | 29 ++++++++ .../Subtitles/SubtitleParserTests.cs | 7 +- 21 files changed, 321 insertions(+), 7 deletions(-) (limited to 'Emby.Naming/Video/Format3DParser.cs') diff --git a/Emby.Naming/Common/MediaType.cs b/Emby.Naming/Common/MediaType.cs index 1231b1887..dc9784c6d 100644 --- a/Emby.Naming/Common/MediaType.cs +++ b/Emby.Naming/Common/MediaType.cs @@ -1,5 +1,8 @@ namespace Emby.Naming.Common { + /// + /// Type of audiovisual media. + /// public enum MediaType { /// diff --git a/Emby.Naming/Common/NamingOptions.cs b/Emby.Naming/Common/NamingOptions.cs index 0f02c03cb..035d1b228 100644 --- a/Emby.Naming/Common/NamingOptions.cs +++ b/Emby.Naming/Common/NamingOptions.cs @@ -8,8 +8,14 @@ using MediaBrowser.Model.Entities; namespace Emby.Naming.Common { + /// + /// Big ugly class containing lot of different naming options that should be split and injected instead of passes everywhere. + /// public class NamingOptions { + /// + /// Initializes a new instance of the class. + /// public NamingOptions() { VideoFileExtensions = new[] @@ -644,58 +650,139 @@ namespace Emby.Naming.Common Compile(); } + /// + /// Gets or sets list of audio file extensions. + /// public string[] AudioFileExtensions { get; set; } + /// + /// Gets or sets list of album stacking prefixes. + /// public string[] AlbumStackingPrefixes { get; set; } + /// + /// Gets or sets list of subtitle file extensions. + /// public string[] SubtitleFileExtensions { get; set; } + /// + /// Gets or sets list of subtitles flag delimiters. + /// public char[] SubtitleFlagDelimiters { get; set; } + /// + /// Gets or sets list of subtitle forced flags. + /// public string[] SubtitleForcedFlags { get; set; } + /// + /// Gets or sets list of subtitle default flags. + /// public string[] SubtitleDefaultFlags { get; set; } + /// + /// Gets or sets list of episode regular expressions. + /// public EpisodeExpression[] EpisodeExpressions { get; set; } + /// + /// Gets or sets list of raw episode without season regular expressions strings. + /// public string[] EpisodeWithoutSeasonExpressions { get; set; } + /// + /// Gets or sets list of raw multi-part episodes regular expressions strings. + /// public string[] EpisodeMultiPartExpressions { get; set; } + /// + /// Gets or sets list of video file extensions. + /// public string[] VideoFileExtensions { get; set; } + /// + /// Gets or sets list of video stub file extensions. + /// public string[] StubFileExtensions { get; set; } + /// + /// Gets or sets list of raw audiobook parts regular expressions strings. + /// public string[] AudioBookPartsExpressions { get; set; } + /// + /// Gets or sets list of raw audiobook names regular expressions strings. + /// public string[] AudioBookNamesExpressions { get; set; } + /// + /// Gets or sets list of stub type rules. + /// public StubTypeRule[] StubTypes { get; set; } + /// + /// Gets or sets list of video flag delimiters. + /// public char[] VideoFlagDelimiters { get; set; } + /// + /// Gets or sets list of 3D Format rules. + /// public Format3DRule[] Format3DRules { get; set; } + /// + /// Gets or sets list of raw video file-stacking expressions strings. + /// public string[] VideoFileStackingExpressions { get; set; } + /// + /// Gets or sets list of raw clean DateTimes regular expressions strings. + /// public string[] CleanDateTimes { get; set; } + /// + /// Gets or sets list of raw clean strings regular expressions strings. + /// public string[] CleanStrings { get; set; } + /// + /// Gets or sets list of multi-episode regular expressions. + /// public EpisodeExpression[] MultipleEpisodeExpressions { get; set; } + /// + /// Gets or sets list of extra rules for videos. + /// public ExtraRule[] VideoExtraRules { get; set; } + /// + /// Gets list of video file-stack regular expressions. + /// public Regex[] VideoFileStackingRegexes { get; private set; } = Array.Empty(); + /// + /// Gets list of clean datetime regular expressions. + /// public Regex[] CleanDateTimeRegexes { get; private set; } = Array.Empty(); + /// + /// Gets list of clean string regular expressions. + /// public Regex[] CleanStringRegexes { get; private set; } = Array.Empty(); + /// + /// Gets list of episode without season regular expressions. + /// public Regex[] EpisodeWithoutSeasonRegexes { get; private set; } = Array.Empty(); + /// + /// Gets list of multi-part episode regular expressions. + /// public Regex[] EpisodeMultiPartRegexes { get; private set; } = Array.Empty(); + /// + /// Compiles raw regex strings into regexes. + /// public void Compile() { VideoFileStackingRegexes = VideoFileStackingExpressions.Select(Compile).ToArray(); diff --git a/Emby.Naming/Subtitles/SubtitleInfo.cs b/Emby.Naming/Subtitles/SubtitleInfo.cs index 62cc3ead1..1fb2e0dc8 100644 --- a/Emby.Naming/Subtitles/SubtitleInfo.cs +++ b/Emby.Naming/Subtitles/SubtitleInfo.cs @@ -1,7 +1,16 @@ namespace Emby.Naming.Subtitles { + /// + /// Class holding information about subtitle. + /// public class SubtitleInfo { + /// + /// Initializes a new instance of the class. + /// + /// Path to file. + /// Is subtitle default. + /// Is subtitle forced. public SubtitleInfo(string path, bool isDefault, bool isForced) { Path = path; diff --git a/Emby.Naming/Subtitles/SubtitleParser.cs b/Emby.Naming/Subtitles/SubtitleParser.cs index 476a83cf3..e87245251 100644 --- a/Emby.Naming/Subtitles/SubtitleParser.cs +++ b/Emby.Naming/Subtitles/SubtitleParser.cs @@ -5,20 +5,32 @@ using Emby.Naming.Common; namespace Emby.Naming.Subtitles { + /// + /// Subtitle Parser class. + /// public class SubtitleParser { private readonly NamingOptions _options; + /// + /// Initializes a new instance of the class. + /// + /// object containing SubtitleFileExtensions, SubtitleDefaultFlags, SubtitleForcedFlags and SubtitleFlagDelimiters. public SubtitleParser(NamingOptions options) { _options = options; } + /// + /// Parse file to determine if is subtitle and . + /// + /// Path to file. + /// Returns null or object if parsing is successful. public SubtitleInfo? ParseFile(string path) { if (path.Length == 0) { - throw new ArgumentException("File path can't be empty.", nameof(path)); + return null; } var extension = Path.GetExtension(path); diff --git a/Emby.Naming/TV/EpisodeResolver.cs b/Emby.Naming/TV/EpisodeResolver.cs index 26dd6915b..f7df58786 100644 --- a/Emby.Naming/TV/EpisodeResolver.cs +++ b/Emby.Naming/TV/EpisodeResolver.cs @@ -6,15 +6,32 @@ using Emby.Naming.Video; namespace Emby.Naming.TV { + /// + /// Used to resolve information about episode from path. + /// public class EpisodeResolver { private readonly NamingOptions _options; + /// + /// Initializes a new instance of the class. + /// + /// object containing VideoFileExtensions and passed to , , and . public EpisodeResolver(NamingOptions options) { _options = options; } + /// + /// Resolve information about episode from path. + /// + /// Path. + /// Is path for a directory or file. + /// Do we want to use IsNamed expressions. + /// Do we want to use Optimistic expressions. + /// Do we want to use expressions supporting absolute episode numbers. + /// Should we attempt to retrieve extended information. + /// Returns null or object if successful. public EpisodeInfo? Resolve( string path, bool isDirectory, diff --git a/Emby.Naming/TV/SeasonPathParser.cs b/Emby.Naming/TV/SeasonPathParser.cs index cf99097bc..d11c7c99e 100644 --- a/Emby.Naming/TV/SeasonPathParser.cs +++ b/Emby.Naming/TV/SeasonPathParser.cs @@ -4,6 +4,9 @@ using System.IO; namespace Emby.Naming.TV { + /// + /// Class to parse season paths. + /// public static class SeasonPathParser { /// @@ -21,6 +24,13 @@ namespace Emby.Naming.TV "stagione" }; + /// + /// Attempts to parse season number from path. + /// + /// Path to season. + /// Support special aliases when parsing. + /// Support numeric season folders when parsing. + /// Returns object. public static SeasonPathParserResult Parse(string path, bool supportSpecialAliases, bool supportNumericSeasonFolders) { var result = new SeasonPathParserResult(); diff --git a/Emby.Naming/TV/SeasonPathParserResult.cs b/Emby.Naming/TV/SeasonPathParserResult.cs index f52f941a7..b4b6f236a 100644 --- a/Emby.Naming/TV/SeasonPathParserResult.cs +++ b/Emby.Naming/TV/SeasonPathParserResult.cs @@ -1,5 +1,8 @@ namespace Emby.Naming.TV { + /// + /// Data object to pass result of . + /// public class SeasonPathParserResult { /// @@ -14,6 +17,10 @@ namespace Emby.Naming.TV /// true if success; otherwise, false. public bool Success { get; set; } + /// + /// Gets or sets a value indicating whether "Is season folder". + /// Seems redundant and barely used. + /// public bool IsSeasonFolder { get; set; } } } diff --git a/Emby.Naming/Video/ExtraResolver.cs b/Emby.Naming/Video/ExtraResolver.cs index 98ea342ac..dd934d91b 100644 --- a/Emby.Naming/Video/ExtraResolver.cs +++ b/Emby.Naming/Video/ExtraResolver.cs @@ -6,15 +6,27 @@ using Emby.Naming.Common; namespace Emby.Naming.Video { + /// + /// Resolve if file is extra for video. + /// public class ExtraResolver { private readonly NamingOptions _options; + /// + /// Initializes a new instance of the class. + /// + /// object containing VideoExtraRules and passed to and . public ExtraResolver(NamingOptions options) { _options = options; } + /// + /// Attempts to resolve if file is extra. + /// + /// Path to file. + /// Returns object. public ExtraResult GetExtraInfo(string path) { return _options.VideoExtraRules diff --git a/Emby.Naming/Video/ExtraResult.cs b/Emby.Naming/Video/ExtraResult.cs index f3b8d2a2f..243fc2b41 100644 --- a/Emby.Naming/Video/ExtraResult.cs +++ b/Emby.Naming/Video/ExtraResult.cs @@ -2,6 +2,9 @@ using MediaBrowser.Model.Entities; namespace Emby.Naming.Video { + /// + /// Holder object for passing results from ExtraResolver. + /// public class ExtraResult { /// diff --git a/Emby.Naming/Video/ExtraRule.cs b/Emby.Naming/Video/ExtraRule.cs index a93474bc6..e267ac55f 100644 --- a/Emby.Naming/Video/ExtraRule.cs +++ b/Emby.Naming/Video/ExtraRule.cs @@ -8,6 +8,13 @@ namespace Emby.Naming.Video /// public class ExtraRule { + /// + /// Initializes a new instance of the class. + /// + /// Type of extra. + /// Type of rule. + /// Token. + /// Media type. public ExtraRule(ExtraType extraType, ExtraRuleType ruleType, string token, MediaType mediaType) { Token = token; diff --git a/Emby.Naming/Video/FileStack.cs b/Emby.Naming/Video/FileStack.cs index 75620e961..6519db57c 100644 --- a/Emby.Naming/Video/FileStack.cs +++ b/Emby.Naming/Video/FileStack.cs @@ -4,19 +4,40 @@ using System.Linq; namespace Emby.Naming.Video { + /// + /// Object holding list of files paths with additional information. + /// public class FileStack { + /// + /// Initializes a new instance of the class. + /// public FileStack() { Files = new List(); } + /// + /// Gets or sets name of file stack. + /// public string Name { get; set; } = string.Empty; + /// + /// Gets or sets list of paths in stack. + /// public List Files { get; set; } + /// + /// Gets or sets a value indicating whether stack is directory stack. + /// public bool IsDirectoryStack { get; set; } + /// + /// Helper function to determine if path is in the stack. + /// + /// Path of desired file. + /// Requested type of stack. + /// True if file is in the stack. public bool ContainsFile(string file, bool isDirectory) { if (IsDirectoryStack == isDirectory) diff --git a/Emby.Naming/Video/FlagParser.cs b/Emby.Naming/Video/FlagParser.cs index cd15b4666..439de1813 100644 --- a/Emby.Naming/Video/FlagParser.cs +++ b/Emby.Naming/Video/FlagParser.cs @@ -4,20 +4,38 @@ using Emby.Naming.Common; namespace Emby.Naming.Video { + /// + /// Parses list of flags from filename based on delimiters. + /// public class FlagParser { private readonly NamingOptions _options; + /// + /// Initializes a new instance of the class. + /// + /// object containing VideoFlagDelimiters. public FlagParser(NamingOptions options) { _options = options; } + /// + /// Calls GetFlags function with _options.VideoFlagDelimiters parameter. + /// + /// Path to file. + /// List of found flags. public string[] GetFlags(string path) { return GetFlags(path, _options.VideoFlagDelimiters); } + /// + /// Parses flags from filename based on delimiters. + /// + /// Path to file. + /// Delimiters used to extract flags. + /// List of found flags. public string[] GetFlags(string path, char[] delimiters) { if (string.IsNullOrEmpty(path)) diff --git a/Emby.Naming/Video/Format3DParser.cs b/Emby.Naming/Video/Format3DParser.cs index 73ad36af4..4fd5d78ba 100644 --- a/Emby.Naming/Video/Format3DParser.cs +++ b/Emby.Naming/Video/Format3DParser.cs @@ -4,15 +4,27 @@ using Emby.Naming.Common; namespace Emby.Naming.Video { + /// + /// Parste 3D format related flags. + /// public class Format3DParser { private readonly NamingOptions _options; + /// + /// Initializes a new instance of the class. + /// + /// object containing VideoFlagDelimiters and passes options to . public Format3DParser(NamingOptions options) { _options = options; } + /// + /// Parse 3D format related flags. + /// + /// Path to file. + /// Returns object. public Format3DResult Parse(string path) { int oldLen = _options.VideoFlagDelimiters.Length; diff --git a/Emby.Naming/Video/Format3DResult.cs b/Emby.Naming/Video/Format3DResult.cs index 539060c98..ac935f203 100644 --- a/Emby.Naming/Video/Format3DResult.cs +++ b/Emby.Naming/Video/Format3DResult.cs @@ -2,8 +2,14 @@ using System.Collections.Generic; namespace Emby.Naming.Video { + /// + /// Helper object to return data from . + /// public class Format3DResult { + /// + /// Initializes a new instance of the class. + /// public Format3DResult() { Tokens = new List(); diff --git a/Emby.Naming/Video/Format3DRule.cs b/Emby.Naming/Video/Format3DRule.cs index bee5c109e..e562691df 100644 --- a/Emby.Naming/Video/Format3DRule.cs +++ b/Emby.Naming/Video/Format3DRule.cs @@ -1,7 +1,15 @@ namespace Emby.Naming.Video { + /// + /// Data holder class for 3D format rule. + /// public class Format3DRule { + /// + /// Initializes a new instance of the class. + /// + /// Token. + /// Token present before current token. public Format3DRule(string token, string? precedingToken = null) { Token = token; diff --git a/Emby.Naming/Video/StackResolver.cs b/Emby.Naming/Video/StackResolver.cs index d6de468cc..550c42961 100644 --- a/Emby.Naming/Video/StackResolver.cs +++ b/Emby.Naming/Video/StackResolver.cs @@ -9,25 +9,47 @@ using MediaBrowser.Model.IO; namespace Emby.Naming.Video { + /// + /// Resolve from list of paths. + /// public class StackResolver { private readonly NamingOptions _options; + /// + /// Initializes a new instance of the class. + /// + /// object containing VideoFileStackingRegexes and passes options to . public StackResolver(NamingOptions options) { _options = options; } + /// + /// Resolves only directories from paths. + /// + /// List of paths. + /// Enumerable of directories. public IEnumerable ResolveDirectories(IEnumerable files) { return Resolve(files.Select(i => new FileSystemMetadata { FullName = i, IsDirectory = true })); } + /// + /// Resolves only files from paths. + /// + /// List of paths. + /// Enumerable of files. public IEnumerable ResolveFiles(IEnumerable files) { return Resolve(files.Select(i => new FileSystemMetadata { FullName = i, IsDirectory = false })); } + /// + /// Resolves audiobooks from paths. + /// + /// List of paths. + /// Enumerable of directories. public IEnumerable ResolveAudioBooks(IEnumerable files) { var groupedDirectoryFiles = files.GroupBy(file => Path.GetDirectoryName(file.Path)); @@ -56,6 +78,11 @@ namespace Emby.Naming.Video } } + /// + /// Resolves videos from paths. + /// + /// List of paths. + /// Enumerable of videos. public IEnumerable Resolve(IEnumerable files) { var resolver = new VideoResolver(_options); diff --git a/Emby.Naming/Video/StubResolver.cs b/Emby.Naming/Video/StubResolver.cs index 6241a46b0..079987fe8 100644 --- a/Emby.Naming/Video/StubResolver.cs +++ b/Emby.Naming/Video/StubResolver.cs @@ -5,8 +5,18 @@ using Emby.Naming.Common; namespace Emby.Naming.Video { + /// + /// Resolve if file is stub (.disc). + /// public static class StubResolver { + /// + /// Tries to resolve if file is stub (.disc). + /// + /// Path to file. + /// NamingOptions containing StubFileExtensions and StubTypes. + /// Stub type. + /// True if file is a stub. public static bool TryResolveFile(string path, NamingOptions options, out string? stubType) { stubType = default; diff --git a/Emby.Naming/Video/StubTypeRule.cs b/Emby.Naming/Video/StubTypeRule.cs index df2d3c7d2..dfb3ac013 100644 --- a/Emby.Naming/Video/StubTypeRule.cs +++ b/Emby.Naming/Video/StubTypeRule.cs @@ -1,7 +1,15 @@ namespace Emby.Naming.Video { + /// + /// Data class holding information about Stub type rule. + /// public class StubTypeRule { + /// + /// Initializes a new instance of the class. + /// + /// Token. + /// Stub type. public StubTypeRule(string token, string stubType) { Token = token; diff --git a/Emby.Naming/Video/VideoListResolver.cs b/Emby.Naming/Video/VideoListResolver.cs index dda322521..ee0e4d465 100644 --- a/Emby.Naming/Video/VideoListResolver.cs +++ b/Emby.Naming/Video/VideoListResolver.cs @@ -9,15 +9,28 @@ using MediaBrowser.Model.IO; namespace Emby.Naming.Video { + /// + /// Resolves alternative versions and extras from list of video files. + /// public class VideoListResolver { private readonly NamingOptions _options; + /// + /// Initializes a new instance of the class. + /// + /// object containing CleanStringRegexes and VideoFlagDelimiters and passes options to and . public VideoListResolver(NamingOptions options) { _options = options; } + /// + /// Resolves alternative versions and extras from list of video files. + /// + /// List of related video files. + /// Indication we should consider multi-versions of content. + /// Returns enumerable of which groups files togeather when related. public IEnumerable Resolve(List files, bool supportMultiVersion = true) { var videoResolver = new VideoResolver(_options); diff --git a/Emby.Naming/Video/VideoResolver.cs b/Emby.Naming/Video/VideoResolver.cs index 31b47cdf1..d7165d8d7 100644 --- a/Emby.Naming/Video/VideoResolver.cs +++ b/Emby.Naming/Video/VideoResolver.cs @@ -5,10 +5,18 @@ using Emby.Naming.Common; namespace Emby.Naming.Video { + /// + /// Resolves from file path. + /// public class VideoResolver { private readonly NamingOptions _options; + /// + /// Initializes a new instance of the class. + /// + /// object containing VideoFileExtensions, StubFileExtensions, CleanStringRegexes and CleanDateTimeRegexes + /// and passes options in , , and . public VideoResolver(NamingOptions options) { _options = options; @@ -110,23 +118,44 @@ namespace Emby.Naming.Video extraRule: extraResult.Rule); } + /// + /// Determines if path is video file based on extension. + /// + /// Path to file. + /// True if is video file. public bool IsVideoFile(string path) { var extension = Path.GetExtension(path) ?? string.Empty; return _options.VideoFileExtensions.Contains(extension, StringComparer.OrdinalIgnoreCase); } + /// + /// Determines if path is video file stub based on extension. + /// + /// Path to file. + /// True if is video file stub. public bool IsStubFile(string path) { var extension = Path.GetExtension(path) ?? string.Empty; return _options.StubFileExtensions.Contains(extension, StringComparer.OrdinalIgnoreCase); } + /// + /// Tries to clean name of clutter. + /// + /// Raw name. + /// Clean name. + /// True if cleaning of name was successful. public bool TryCleanString(string name, out ReadOnlySpan newName) { return CleanStringParser.TryClean(name, _options.CleanStringRegexes, out newName); } + /// + /// Tries to get name and year from raw name. + /// + /// Raw name. + /// Returns with name and optional year. public CleanDateTimeResult CleanDateTime(string name) { return CleanDateTimeParser.Clean(name, _options.CleanDateTimeRegexes); diff --git a/tests/Jellyfin.Naming.Tests/Subtitles/SubtitleParserTests.cs b/tests/Jellyfin.Naming.Tests/Subtitles/SubtitleParserTests.cs index 515209890..f3abacb4f 100644 --- a/tests/Jellyfin.Naming.Tests/Subtitles/SubtitleParserTests.cs +++ b/tests/Jellyfin.Naming.Tests/Subtitles/SubtitleParserTests.cs @@ -31,17 +31,12 @@ namespace Jellyfin.Naming.Tests.Subtitles [Theory] [InlineData("The Skin I Live In (2011).mp4")] + [InlineData("")] public void SubtitleParser_InvalidFileName_ReturnsNull(string input) { var parser = new SubtitleParser(_namingOptions); Assert.Null(parser.ParseFile(input)); } - - [Fact] - public void SubtitleParser_EmptyFileName_ThrowsArgumentException() - { - Assert.Throws(() => new SubtitleParser(_namingOptions).ParseFile(string.Empty)); - } } } -- cgit v1.2.3