FlagParser.cs 874 B

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