CollectionsDynamicFolder.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using MediaBrowser.Common.Configuration;
  2. using MediaBrowser.Controller.Entities;
  3. using System.IO;
  4. using System.Linq;
  5. namespace MediaBrowser.Server.Implementations.Collections
  6. {
  7. public class CollectionsDynamicFolder : IVirtualFolderCreator
  8. {
  9. private readonly IApplicationPaths _appPaths;
  10. public CollectionsDynamicFolder(IApplicationPaths appPaths)
  11. {
  12. _appPaths = appPaths;
  13. }
  14. public BasePluginFolder GetFolder()
  15. {
  16. var path = Path.Combine(_appPaths.DataPath, "collections");
  17. Directory.CreateDirectory(path);
  18. return new ManualCollectionsFolder
  19. {
  20. Path = path
  21. };
  22. }
  23. }
  24. public class ManualCollectionsFolder : BasePluginFolder
  25. {
  26. public ManualCollectionsFolder()
  27. {
  28. Name = "Collections";
  29. }
  30. public override bool IsVisible(User user)
  31. {
  32. if (!GetChildren(user, true).Any())
  33. {
  34. return false;
  35. }
  36. return base.IsVisible(user);
  37. }
  38. public override bool IsHidden
  39. {
  40. get
  41. {
  42. return !ActualChildren.Any() || base.IsHidden;
  43. }
  44. }
  45. }
  46. }