jellyfin/Emby.Naming/Video/FlagParser.cs

36 lines
857 B
C#
Raw Normal View History

using System;
2018-09-12 19:26:21 +02:00
using System.IO;
2019-01-13 20:17:29 +01:00
using Emby.Naming.Common;
2018-09-12 19:26:21 +02:00
namespace Emby.Naming.Video
{
public class FlagParser
{
private readonly NamingOptions _options;
public FlagParser(NamingOptions options)
{
_options = options;
}
public string[] GetFlags(string path)
{
return GetFlags(path, _options.VideoFlagDelimiters);
}
2020-11-01 11:19:22 +01:00
public string[] GetFlags(string path, char[] delimiters)
2018-09-12 19:26:21 +02:00
{
if (string.IsNullOrEmpty(path))
{
2020-11-05 16:59:15 +01:00
return Array.Empty<string>();
2018-09-12 19:26:21 +02:00
}
// Note: the tags need be be surrounded be either a space ( ), hyphen -, dot . or underscore _.
var file = Path.GetFileName(path);
2020-11-01 11:19:22 +01:00
return file.Split(delimiters, StringSplitOptions.RemoveEmptyEntries);
2018-09-12 19:26:21 +02:00
}
}
}