EntityResolutionHelper.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.IO;
  7. using MediaBrowser.Controller.IO;
  8. using MediaBrowser.Controller.Library;
  9. using MediaBrowser.Controller.Entities.TV;
  10. namespace MediaBrowser.Controller.Resolvers
  11. {
  12. public static class EntityResolutionHelper
  13. {
  14. /// <summary>
  15. /// Any folder named in this list will be ignored - can be added to at runtime for extensibility
  16. /// </summary>
  17. public static List<string> IgnoreFolders = new List<string>()
  18. {
  19. "trailers",
  20. "metadata",
  21. "bdmv",
  22. "certificate",
  23. "backup",
  24. "video_ts",
  25. "audio_ts",
  26. "ps3_update",
  27. "ps3_vprm",
  28. "adv_obj",
  29. "hvdvd_ts"
  30. };
  31. /// <summary>
  32. /// Determines whether a path should be resolved or ignored entirely - called before we even look at the contents
  33. /// </summary>
  34. /// <param name="path"></param>
  35. /// <returns>false if the path should be ignored</returns>
  36. public static bool ShouldResolvePath(WIN32_FIND_DATA path)
  37. {
  38. bool resolve = true;
  39. // Ignore hidden files and folders
  40. if (path.IsHidden || path.IsSystemFile)
  41. {
  42. resolve = false;
  43. }
  44. // Ignore any folders in our list
  45. else if (path.IsDirectory && IgnoreFolders.Contains(Path.GetFileName(path.Path), StringComparer.OrdinalIgnoreCase))
  46. {
  47. resolve = false;
  48. }
  49. return resolve;
  50. }
  51. /// <summary>
  52. /// Determines whether a path should be ignored based on its contents - called after the contents have been read
  53. /// </summary>
  54. public static bool ShouldResolvePathContents(ItemResolveEventArgs args)
  55. {
  56. bool resolve = true;
  57. if (args.ContainsFile(".ignore"))
  58. {
  59. // Ignore any folders containing a file called .ignore
  60. resolve = false;
  61. }
  62. return resolve;
  63. }
  64. }
  65. }