ManualPlaylistsFolder.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 bool IsHiddenFromUser(User user)
  33. {
  34. return false;
  35. }
  36. public override string CollectionType
  37. {
  38. get { return Model.Entities.CollectionType.Playlists; }
  39. }
  40. }
  41. public class PlaylistsDynamicFolder : IVirtualFolderCreator
  42. {
  43. private readonly IApplicationPaths _appPaths;
  44. private readonly IFileSystem _fileSystem;
  45. public PlaylistsDynamicFolder(IApplicationPaths appPaths, IFileSystem fileSystem)
  46. {
  47. _appPaths = appPaths;
  48. _fileSystem = fileSystem;
  49. }
  50. public BasePluginFolder GetFolder()
  51. {
  52. var path = Path.Combine(_appPaths.DataPath, "playlists");
  53. _fileSystem.CreateDirectory(path);
  54. return new PlaylistsFolder
  55. {
  56. Path = path
  57. };
  58. }
  59. }
  60. }