mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-05-24 02:02:29 -04:00
Xml-doc part2
This commit is contained in:
parent
693760e38a
commit
158eff62d7
@ -1,5 +1,8 @@
|
||||
namespace Emby.Naming.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// Type of audiovisual media.
|
||||
/// </summary>
|
||||
public enum MediaType
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -8,8 +8,14 @@ using MediaBrowser.Model.Entities;
|
||||
|
||||
namespace Emby.Naming.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// Big ugly class containing lot of different naming options that should be split and injected instead of passes everywhere.
|
||||
/// </summary>
|
||||
public class NamingOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="NamingOptions"/> class.
|
||||
/// </summary>
|
||||
public NamingOptions()
|
||||
{
|
||||
VideoFileExtensions = new[]
|
||||
@ -644,58 +650,139 @@ namespace Emby.Naming.Common
|
||||
Compile();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets list of audio file extensions.
|
||||
/// </summary>
|
||||
public string[] AudioFileExtensions { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets list of album stacking prefixes.
|
||||
/// </summary>
|
||||
public string[] AlbumStackingPrefixes { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets list of subtitle file extensions.
|
||||
/// </summary>
|
||||
public string[] SubtitleFileExtensions { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets list of subtitles flag delimiters.
|
||||
/// </summary>
|
||||
public char[] SubtitleFlagDelimiters { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets list of subtitle forced flags.
|
||||
/// </summary>
|
||||
public string[] SubtitleForcedFlags { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets list of subtitle default flags.
|
||||
/// </summary>
|
||||
public string[] SubtitleDefaultFlags { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets list of episode regular expressions.
|
||||
/// </summary>
|
||||
public EpisodeExpression[] EpisodeExpressions { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets list of raw episode without season regular expressions strings.
|
||||
/// </summary>
|
||||
public string[] EpisodeWithoutSeasonExpressions { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets list of raw multi-part episodes regular expressions strings.
|
||||
/// </summary>
|
||||
public string[] EpisodeMultiPartExpressions { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets list of video file extensions.
|
||||
/// </summary>
|
||||
public string[] VideoFileExtensions { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets list of video stub file extensions.
|
||||
/// </summary>
|
||||
public string[] StubFileExtensions { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets list of raw audiobook parts regular expressions strings.
|
||||
/// </summary>
|
||||
public string[] AudioBookPartsExpressions { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets list of raw audiobook names regular expressions strings.
|
||||
/// </summary>
|
||||
public string[] AudioBookNamesExpressions { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets list of stub type rules.
|
||||
/// </summary>
|
||||
public StubTypeRule[] StubTypes { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets list of video flag delimiters.
|
||||
/// </summary>
|
||||
public char[] VideoFlagDelimiters { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets list of 3D Format rules.
|
||||
/// </summary>
|
||||
public Format3DRule[] Format3DRules { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets list of raw video file-stacking expressions strings.
|
||||
/// </summary>
|
||||
public string[] VideoFileStackingExpressions { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets list of raw clean DateTimes regular expressions strings.
|
||||
/// </summary>
|
||||
public string[] CleanDateTimes { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets list of raw clean strings regular expressions strings.
|
||||
/// </summary>
|
||||
public string[] CleanStrings { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets list of multi-episode regular expressions.
|
||||
/// </summary>
|
||||
public EpisodeExpression[] MultipleEpisodeExpressions { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets list of extra rules for videos.
|
||||
/// </summary>
|
||||
public ExtraRule[] VideoExtraRules { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets list of video file-stack regular expressions.
|
||||
/// </summary>
|
||||
public Regex[] VideoFileStackingRegexes { get; private set; } = Array.Empty<Regex>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets list of clean datetime regular expressions.
|
||||
/// </summary>
|
||||
public Regex[] CleanDateTimeRegexes { get; private set; } = Array.Empty<Regex>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets list of clean string regular expressions.
|
||||
/// </summary>
|
||||
public Regex[] CleanStringRegexes { get; private set; } = Array.Empty<Regex>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets list of episode without season regular expressions.
|
||||
/// </summary>
|
||||
public Regex[] EpisodeWithoutSeasonRegexes { get; private set; } = Array.Empty<Regex>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets list of multi-part episode regular expressions.
|
||||
/// </summary>
|
||||
public Regex[] EpisodeMultiPartRegexes { get; private set; } = Array.Empty<Regex>();
|
||||
|
||||
/// <summary>
|
||||
/// Compiles raw regex strings into regexes.
|
||||
/// </summary>
|
||||
public void Compile()
|
||||
{
|
||||
VideoFileStackingRegexes = VideoFileStackingExpressions.Select(Compile).ToArray();
|
||||
|
@ -1,7 +1,16 @@
|
||||
namespace Emby.Naming.Subtitles
|
||||
{
|
||||
/// <summary>
|
||||
/// Class holding information about subtitle.
|
||||
/// </summary>
|
||||
public class SubtitleInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SubtitleInfo"/> class.
|
||||
/// </summary>
|
||||
/// <param name="path">Path to file.</param>
|
||||
/// <param name="isDefault">Is subtitle default.</param>
|
||||
/// <param name="isForced">Is subtitle forced.</param>
|
||||
public SubtitleInfo(string path, bool isDefault, bool isForced)
|
||||
{
|
||||
Path = path;
|
||||
|
@ -5,20 +5,32 @@ using Emby.Naming.Common;
|
||||
|
||||
namespace Emby.Naming.Subtitles
|
||||
{
|
||||
/// <summary>
|
||||
/// Subtitle Parser class.
|
||||
/// </summary>
|
||||
public class SubtitleParser
|
||||
{
|
||||
private readonly NamingOptions _options;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SubtitleParser"/> class.
|
||||
/// </summary>
|
||||
/// <param name="options"><see cref="NamingOptions"/> object containing SubtitleFileExtensions, SubtitleDefaultFlags, SubtitleForcedFlags and SubtitleFlagDelimiters.</param>
|
||||
public SubtitleParser(NamingOptions options)
|
||||
{
|
||||
_options = options;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parse file to determine if is subtitle and <see cref="SubtitleInfo"/>.
|
||||
/// </summary>
|
||||
/// <param name="path">Path to file.</param>
|
||||
/// <returns>Returns null or <see cref="SubtitleInfo"/> object if parsing is successful.</returns>
|
||||
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);
|
||||
|
@ -6,15 +6,32 @@ using Emby.Naming.Video;
|
||||
|
||||
namespace Emby.Naming.TV
|
||||
{
|
||||
/// <summary>
|
||||
/// Used to resolve information about episode from path.
|
||||
/// </summary>
|
||||
public class EpisodeResolver
|
||||
{
|
||||
private readonly NamingOptions _options;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="EpisodeResolver"/> class.
|
||||
/// </summary>
|
||||
/// <param name="options"><see cref="NamingOptions"/> object containing VideoFileExtensions and passed to <see cref="StubResolver"/>, <see cref="FlagParser"/>, <see cref="Format3DParser"/> and <see cref="EpisodePathParser"/>.</param>
|
||||
public EpisodeResolver(NamingOptions options)
|
||||
{
|
||||
_options = options;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resolve information about episode from path.
|
||||
/// </summary>
|
||||
/// <param name="path">Path.</param>
|
||||
/// <param name="isDirectory">Is path for a directory or file.</param>
|
||||
/// <param name="isNamed">Do we want to use IsNamed expressions.</param>
|
||||
/// <param name="isOptimistic">Do we want to use Optimistic expressions.</param>
|
||||
/// <param name="supportsAbsoluteNumbers">Do we want to use expressions supporting absolute episode numbers.</param>
|
||||
/// <param name="fillExtendedInfo">Should we attempt to retrieve extended information.</param>
|
||||
/// <returns>Returns null or <see cref="EpisodeInfo"/> object if successful.</returns>
|
||||
public EpisodeInfo? Resolve(
|
||||
string path,
|
||||
bool isDirectory,
|
||||
|
@ -4,6 +4,9 @@ using System.IO;
|
||||
|
||||
namespace Emby.Naming.TV
|
||||
{
|
||||
/// <summary>
|
||||
/// Class to parse season paths.
|
||||
/// </summary>
|
||||
public static class SeasonPathParser
|
||||
{
|
||||
/// <summary>
|
||||
@ -21,6 +24,13 @@ namespace Emby.Naming.TV
|
||||
"stagione"
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to parse season number from path.
|
||||
/// </summary>
|
||||
/// <param name="path">Path to season.</param>
|
||||
/// <param name="supportSpecialAliases">Support special aliases when parsing.</param>
|
||||
/// <param name="supportNumericSeasonFolders">Support numeric season folders when parsing.</param>
|
||||
/// <returns>Returns <see cref="SeasonPathParserResult"/> object.</returns>
|
||||
public static SeasonPathParserResult Parse(string path, bool supportSpecialAliases, bool supportNumericSeasonFolders)
|
||||
{
|
||||
var result = new SeasonPathParserResult();
|
||||
|
@ -1,5 +1,8 @@
|
||||
namespace Emby.Naming.TV
|
||||
{
|
||||
/// <summary>
|
||||
/// Data object to pass result of <see cref="SeasonPathParser"/>.
|
||||
/// </summary>
|
||||
public class SeasonPathParserResult
|
||||
{
|
||||
/// <summary>
|
||||
@ -14,6 +17,10 @@ namespace Emby.Naming.TV
|
||||
/// <value><c>true</c> if success; otherwise, <c>false</c>.</value>
|
||||
public bool Success { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether "Is season folder".
|
||||
/// Seems redundant and barely used.
|
||||
/// </summary>
|
||||
public bool IsSeasonFolder { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -6,15 +6,27 @@ using Emby.Naming.Common;
|
||||
|
||||
namespace Emby.Naming.Video
|
||||
{
|
||||
/// <summary>
|
||||
/// Resolve if file is extra for video.
|
||||
/// </summary>
|
||||
public class ExtraResolver
|
||||
{
|
||||
private readonly NamingOptions _options;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ExtraResolver"/> class.
|
||||
/// </summary>
|
||||
/// <param name="options"><see cref="NamingOptions"/> object containing VideoExtraRules and passed to <see cref="AudioFileParser"/> and <see cref="VideoResolver"/>.</param>
|
||||
public ExtraResolver(NamingOptions options)
|
||||
{
|
||||
_options = options;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to resolve if file is extra.
|
||||
/// </summary>
|
||||
/// <param name="path">Path to file.</param>
|
||||
/// <returns>Returns <see cref="ExtraResult"/> object.</returns>
|
||||
public ExtraResult GetExtraInfo(string path)
|
||||
{
|
||||
return _options.VideoExtraRules
|
||||
|
@ -2,6 +2,9 @@ using MediaBrowser.Model.Entities;
|
||||
|
||||
namespace Emby.Naming.Video
|
||||
{
|
||||
/// <summary>
|
||||
/// Holder object for passing results from ExtraResolver.
|
||||
/// </summary>
|
||||
public class ExtraResult
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -8,6 +8,13 @@ namespace Emby.Naming.Video
|
||||
/// </summary>
|
||||
public class ExtraRule
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ExtraRule"/> class.
|
||||
/// </summary>
|
||||
/// <param name="extraType">Type of extra.</param>
|
||||
/// <param name="ruleType">Type of rule.</param>
|
||||
/// <param name="token">Token.</param>
|
||||
/// <param name="mediaType">Media type.</param>
|
||||
public ExtraRule(ExtraType extraType, ExtraRuleType ruleType, string token, MediaType mediaType)
|
||||
{
|
||||
Token = token;
|
||||
|
@ -4,19 +4,40 @@ using System.Linq;
|
||||
|
||||
namespace Emby.Naming.Video
|
||||
{
|
||||
/// <summary>
|
||||
/// Object holding list of files paths with additional information.
|
||||
/// </summary>
|
||||
public class FileStack
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="FileStack"/> class.
|
||||
/// </summary>
|
||||
public FileStack()
|
||||
{
|
||||
Files = new List<string>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets name of file stack.
|
||||
/// </summary>
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets list of paths in stack.
|
||||
/// </summary>
|
||||
public List<string> Files { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether stack is directory stack.
|
||||
/// </summary>
|
||||
public bool IsDirectoryStack { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Helper function to determine if path is in the stack.
|
||||
/// </summary>
|
||||
/// <param name="file">Path of desired file.</param>
|
||||
/// <param name="isDirectory">Requested type of stack.</param>
|
||||
/// <returns>True if file is in the stack.</returns>
|
||||
public bool ContainsFile(string file, bool isDirectory)
|
||||
{
|
||||
if (IsDirectoryStack == isDirectory)
|
||||
|
@ -4,20 +4,38 @@ using Emby.Naming.Common;
|
||||
|
||||
namespace Emby.Naming.Video
|
||||
{
|
||||
/// <summary>
|
||||
/// Parses list of flags from filename based on delimiters.
|
||||
/// </summary>
|
||||
public class FlagParser
|
||||
{
|
||||
private readonly NamingOptions _options;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="FlagParser"/> class.
|
||||
/// </summary>
|
||||
/// <param name="options"><see cref="NamingOptions"/> object containing VideoFlagDelimiters.</param>
|
||||
public FlagParser(NamingOptions options)
|
||||
{
|
||||
_options = options;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calls GetFlags function with _options.VideoFlagDelimiters parameter.
|
||||
/// </summary>
|
||||
/// <param name="path">Path to file.</param>
|
||||
/// <returns>List of found flags.</returns>
|
||||
public string[] GetFlags(string path)
|
||||
{
|
||||
return GetFlags(path, _options.VideoFlagDelimiters);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parses flags from filename based on delimiters.
|
||||
/// </summary>
|
||||
/// <param name="path">Path to file.</param>
|
||||
/// <param name="delimiters">Delimiters used to extract flags.</param>
|
||||
/// <returns>List of found flags.</returns>
|
||||
public string[] GetFlags(string path, char[] delimiters)
|
||||
{
|
||||
if (string.IsNullOrEmpty(path))
|
||||
|
@ -4,15 +4,27 @@ using Emby.Naming.Common;
|
||||
|
||||
namespace Emby.Naming.Video
|
||||
{
|
||||
/// <summary>
|
||||
/// Parste 3D format related flags.
|
||||
/// </summary>
|
||||
public class Format3DParser
|
||||
{
|
||||
private readonly NamingOptions _options;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Format3DParser"/> class.
|
||||
/// </summary>
|
||||
/// <param name="options"><see cref="NamingOptions"/> object containing VideoFlagDelimiters and passes options to <see cref="FlagParser"/>.</param>
|
||||
public Format3DParser(NamingOptions options)
|
||||
{
|
||||
_options = options;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parse 3D format related flags.
|
||||
/// </summary>
|
||||
/// <param name="path">Path to file.</param>
|
||||
/// <returns>Returns <see cref="Format3DResult"/> object.</returns>
|
||||
public Format3DResult Parse(string path)
|
||||
{
|
||||
int oldLen = _options.VideoFlagDelimiters.Length;
|
||||
|
@ -2,8 +2,14 @@ using System.Collections.Generic;
|
||||
|
||||
namespace Emby.Naming.Video
|
||||
{
|
||||
/// <summary>
|
||||
/// Helper object to return data from <see cref="Format3DParser"/>.
|
||||
/// </summary>
|
||||
public class Format3DResult
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Format3DResult"/> class.
|
||||
/// </summary>
|
||||
public Format3DResult()
|
||||
{
|
||||
Tokens = new List<string>();
|
||||
|
@ -1,7 +1,15 @@
|
||||
namespace Emby.Naming.Video
|
||||
{
|
||||
/// <summary>
|
||||
/// Data holder class for 3D format rule.
|
||||
/// </summary>
|
||||
public class Format3DRule
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Format3DRule"/> class.
|
||||
/// </summary>
|
||||
/// <param name="token">Token.</param>
|
||||
/// <param name="precedingToken">Token present before current token.</param>
|
||||
public Format3DRule(string token, string? precedingToken = null)
|
||||
{
|
||||
Token = token;
|
||||
|
@ -9,25 +9,47 @@ using MediaBrowser.Model.IO;
|
||||
|
||||
namespace Emby.Naming.Video
|
||||
{
|
||||
/// <summary>
|
||||
/// Resolve <see cref="FileStack"/> from list of paths.
|
||||
/// </summary>
|
||||
public class StackResolver
|
||||
{
|
||||
private readonly NamingOptions _options;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="StackResolver"/> class.
|
||||
/// </summary>
|
||||
/// <param name="options"><see cref="NamingOptions"/> object containing VideoFileStackingRegexes and passes options to <see cref="VideoResolver"/>.</param>
|
||||
public StackResolver(NamingOptions options)
|
||||
{
|
||||
_options = options;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resolves only directories from paths.
|
||||
/// </summary>
|
||||
/// <param name="files">List of paths.</param>
|
||||
/// <returns>Enumerable <see cref="FileStack"/> of directories.</returns>
|
||||
public IEnumerable<FileStack> ResolveDirectories(IEnumerable<string> files)
|
||||
{
|
||||
return Resolve(files.Select(i => new FileSystemMetadata { FullName = i, IsDirectory = true }));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resolves only files from paths.
|
||||
/// </summary>
|
||||
/// <param name="files">List of paths.</param>
|
||||
/// <returns>Enumerable <see cref="FileStack"/> of files.</returns>
|
||||
public IEnumerable<FileStack> ResolveFiles(IEnumerable<string> files)
|
||||
{
|
||||
return Resolve(files.Select(i => new FileSystemMetadata { FullName = i, IsDirectory = false }));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resolves audiobooks from paths.
|
||||
/// </summary>
|
||||
/// <param name="files">List of paths.</param>
|
||||
/// <returns>Enumerable <see cref="FileStack"/> of directories.</returns>
|
||||
public IEnumerable<FileStack> ResolveAudioBooks(IEnumerable<AudioBookFileInfo> files)
|
||||
{
|
||||
var groupedDirectoryFiles = files.GroupBy(file => Path.GetDirectoryName(file.Path));
|
||||
@ -56,6 +78,11 @@ namespace Emby.Naming.Video
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resolves videos from paths.
|
||||
/// </summary>
|
||||
/// <param name="files">List of paths.</param>
|
||||
/// <returns>Enumerable <see cref="FileStack"/> of videos.</returns>
|
||||
public IEnumerable<FileStack> Resolve(IEnumerable<FileSystemMetadata> files)
|
||||
{
|
||||
var resolver = new VideoResolver(_options);
|
||||
|
@ -5,8 +5,18 @@ using Emby.Naming.Common;
|
||||
|
||||
namespace Emby.Naming.Video
|
||||
{
|
||||
/// <summary>
|
||||
/// Resolve if file is stub (.disc).
|
||||
/// </summary>
|
||||
public static class StubResolver
|
||||
{
|
||||
/// <summary>
|
||||
/// Tries to resolve if file is stub (.disc).
|
||||
/// </summary>
|
||||
/// <param name="path">Path to file.</param>
|
||||
/// <param name="options">NamingOptions containing StubFileExtensions and StubTypes.</param>
|
||||
/// <param name="stubType">Stub type.</param>
|
||||
/// <returns>True if file is a stub.</returns>
|
||||
public static bool TryResolveFile(string path, NamingOptions options, out string? stubType)
|
||||
{
|
||||
stubType = default;
|
||||
|
@ -1,7 +1,15 @@
|
||||
namespace Emby.Naming.Video
|
||||
{
|
||||
/// <summary>
|
||||
/// Data class holding information about Stub type rule.
|
||||
/// </summary>
|
||||
public class StubTypeRule
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="StubTypeRule"/> class.
|
||||
/// </summary>
|
||||
/// <param name="token">Token.</param>
|
||||
/// <param name="stubType">Stub type.</param>
|
||||
public StubTypeRule(string token, string stubType)
|
||||
{
|
||||
Token = token;
|
||||
|
@ -9,15 +9,28 @@ using MediaBrowser.Model.IO;
|
||||
|
||||
namespace Emby.Naming.Video
|
||||
{
|
||||
/// <summary>
|
||||
/// Resolves alternative versions and extras from list of video files.
|
||||
/// </summary>
|
||||
public class VideoListResolver
|
||||
{
|
||||
private readonly NamingOptions _options;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="VideoListResolver"/> class.
|
||||
/// </summary>
|
||||
/// <param name="options"><see cref="NamingOptions"/> object containing CleanStringRegexes and VideoFlagDelimiters and passes options to <see cref="StackResolver"/> and <see cref="VideoResolver"/>.</param>
|
||||
public VideoListResolver(NamingOptions options)
|
||||
{
|
||||
_options = options;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resolves alternative versions and extras from list of video files.
|
||||
/// </summary>
|
||||
/// <param name="files">List of related video files.</param>
|
||||
/// <param name="supportMultiVersion">Indication we should consider multi-versions of content.</param>
|
||||
/// <returns>Returns enumerable of <see cref="VideoInfo"/> which groups files togeather when related.</returns>
|
||||
public IEnumerable<VideoInfo> Resolve(List<FileSystemMetadata> files, bool supportMultiVersion = true)
|
||||
{
|
||||
var videoResolver = new VideoResolver(_options);
|
||||
|
@ -5,10 +5,18 @@ using Emby.Naming.Common;
|
||||
|
||||
namespace Emby.Naming.Video
|
||||
{
|
||||
/// <summary>
|
||||
/// Resolves <see cref="VideoFileInfo"/> from file path.
|
||||
/// </summary>
|
||||
public class VideoResolver
|
||||
{
|
||||
private readonly NamingOptions _options;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="VideoResolver"/> class.
|
||||
/// </summary>
|
||||
/// <param name="options"><see cref="NamingOptions"/> object containing VideoFileExtensions, StubFileExtensions, CleanStringRegexes and CleanDateTimeRegexes
|
||||
/// and passes options in <see cref="StubResolver"/>, <see cref="FlagParser"/>, <see cref="Format3DParser"/> and <see cref="ExtraResolver"/>.</param>
|
||||
public VideoResolver(NamingOptions options)
|
||||
{
|
||||
_options = options;
|
||||
@ -110,23 +118,44 @@ namespace Emby.Naming.Video
|
||||
extraRule: extraResult.Rule);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines if path is video file based on extension.
|
||||
/// </summary>
|
||||
/// <param name="path">Path to file.</param>
|
||||
/// <returns>True if is video file.</returns>
|
||||
public bool IsVideoFile(string path)
|
||||
{
|
||||
var extension = Path.GetExtension(path) ?? string.Empty;
|
||||
return _options.VideoFileExtensions.Contains(extension, StringComparer.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines if path is video file stub based on extension.
|
||||
/// </summary>
|
||||
/// <param name="path">Path to file.</param>
|
||||
/// <returns>True if is video file stub.</returns>
|
||||
public bool IsStubFile(string path)
|
||||
{
|
||||
var extension = Path.GetExtension(path) ?? string.Empty;
|
||||
return _options.StubFileExtensions.Contains(extension, StringComparer.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tries to clean name of clutter.
|
||||
/// </summary>
|
||||
/// <param name="name">Raw name.</param>
|
||||
/// <param name="newName">Clean name.</param>
|
||||
/// <returns>True if cleaning of name was successful.</returns>
|
||||
public bool TryCleanString(string name, out ReadOnlySpan<char> newName)
|
||||
{
|
||||
return CleanStringParser.TryClean(name, _options.CleanStringRegexes, out newName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tries to get name and year from raw name.
|
||||
/// </summary>
|
||||
/// <param name="name">Raw name.</param>
|
||||
/// <returns>Returns <see cref="CleanDateTimeResult"/> with name and optional year.</returns>
|
||||
public CleanDateTimeResult CleanDateTime(string name)
|
||||
{
|
||||
return CleanDateTimeParser.Clean(name, _options.CleanDateTimeRegexes);
|
||||
|
@ -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<ArgumentException>(() => new SubtitleParser(_namingOptions).ParseFile(string.Empty));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user