using System;
using System.IO;
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))
{
return Array.Empty();
}
// Note: the tags need be be surrounded be either a space ( ), hyphen -, dot . or underscore _.
var file = Path.GetFileName(path);
return file.Split(delimiters, StringSplitOptions.RemoveEmptyEntries);
}
}
}