ManualPlaylistsFolder.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. namespace MediaBrowser.Server.Implementations.Playlists
  8. {
  9. public class PlaylistsFolder : BasePluginFolder
  10. {
  11. public PlaylistsFolder()
  12. {
  13. Name = "Playlists";
  14. }
  15. public override bool IsVisible(User user)
  16. {
  17. return base.IsVisible(user) && GetChildren(user, false)
  18. .OfType<Playlist>()
  19. .Any(i => i.IsVisible(user));
  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. public PlaylistsDynamicFolder(IApplicationPaths appPaths)
  45. {
  46. _appPaths = appPaths;
  47. }
  48. public BasePluginFolder GetFolder()
  49. {
  50. var path = Path.Combine(_appPaths.DataPath, "playlists");
  51. Directory.CreateDirectory(path);
  52. return new PlaylistsFolder
  53. {
  54. Path = path
  55. };
  56. }
  57. }
  58. }