FlagParser.cs 937 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #pragma warning disable CS1591
  2. #pragma warning disable SA1600
  3. using System;
  4. using System.IO;
  5. using Emby.Naming.Common;
  6. namespace Emby.Naming.Video
  7. {
  8. public class FlagParser
  9. {
  10. private readonly NamingOptions _options;
  11. public FlagParser(NamingOptions options)
  12. {
  13. _options = options;
  14. }
  15. public string[] GetFlags(string path)
  16. {
  17. return GetFlags(path, _options.VideoFlagDelimiters);
  18. }
  19. public string[] GetFlags(string path, char[] delimeters)
  20. {
  21. if (string.IsNullOrEmpty(path))
  22. {
  23. throw new ArgumentNullException(nameof(path));
  24. }
  25. // Note: the tags need be be surrounded be either a space ( ), hyphen -, dot . or underscore _.
  26. var file = Path.GetFileName(path);
  27. return file.Split(delimeters, StringSplitOptions.RemoveEmptyEntries);
  28. }
  29. }
  30. }