ManualPlaylistsFolder.cs 1.7 KB

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