EntityResolutionHelper.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. "bdmv",
  21. "certificate",
  22. "backup",
  23. "video_ts",
  24. "audio_ts",
  25. "ps3_update",
  26. "ps3_vprm"
  27. };
  28. /// <summary>
  29. /// Determines whether a path should be resolved or ignored entirely - called before we even look at the contents
  30. /// </summary>
  31. /// <param name="path"></param>
  32. /// <returns>false if the path should be ignored</returns>
  33. public static bool ShouldResolvePath(WIN32_FIND_DATA path)
  34. {
  35. bool resolve = true;
  36. // Ignore hidden files and folders
  37. if (path.IsHidden || path.IsSystemFile)
  38. {
  39. resolve = false;
  40. }
  41. // Ignore any folders in our list
  42. else if (path.IsDirectory && IgnoreFolders.Contains(Path.GetFileName(path.Path), StringComparer.OrdinalIgnoreCase))
  43. {
  44. resolve = false;
  45. }
  46. return resolve;
  47. }
  48. /// <summary>
  49. /// Determines whether a path should be ignored based on its contents - called after the contents have been read
  50. /// </summary>
  51. public static bool ShouldResolvePathContents(ItemResolveEventArgs args)
  52. {
  53. bool resolve = true;
  54. if (args.ContainsFile(".ignore"))
  55. {
  56. // Ignore any folders containing a file called .ignore
  57. resolve = false;
  58. }
  59. return resolve;
  60. }
  61. }
  62. }