ManualPlaylistsFolder.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. using MediaBrowser.Common.Configuration;
  2. using MediaBrowser.Controller.Entities;
  3. using MediaBrowser.Controller.Playlists;
  4. using System.Collections.Generic;
  5. using System.IO;
  6. using System.Linq;
  7. using CommonIO;
  8. using MediaBrowser.Common.IO;
  9. namespace MediaBrowser.Server.Implementations.Playlists
  10. {
  11. public class PlaylistsFolder : BasePluginFolder
  12. {
  13. public PlaylistsFolder()
  14. {
  15. Name = "Playlists";
  16. }
  17. public override bool IsVisible(User user)
  18. {
  19. return base.IsVisible(user) && GetChildren(user, false).Any();
  20. }
  21. protected override IEnumerable<BaseItem> GetEligibleChildrenForRecursiveChildren(User user)
  22. {
  23. return GetRecursiveChildren(i => i is Playlist);
  24. }
  25. public override bool IsHidden
  26. {
  27. get
  28. {
  29. return true;
  30. }
  31. }
  32. public override string CollectionType
  33. {
  34. get { return Model.Entities.CollectionType.Playlists; }
  35. }
  36. }
  37. public class PlaylistsDynamicFolder : IVirtualFolderCreator
  38. {
  39. private readonly IApplicationPaths _appPaths;
  40. private readonly IFileSystem _fileSystem;
  41. public PlaylistsDynamicFolder(IApplicationPaths appPaths, IFileSystem fileSystem)
  42. {
  43. _appPaths = appPaths;
  44. _fileSystem = fileSystem;
  45. }
  46. public BasePluginFolder GetFolder()
  47. {
  48. var path = Path.Combine(_appPaths.DataPath, "playlists");
  49. _fileSystem.CreateDirectory(path);
  50. return new PlaylistsFolder
  51. {
  52. Path = path
  53. };
  54. }
  55. }
  56. }