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. 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) && GetRecursiveChildren(user, false)
  18. .OfType<Playlist>()
  19. .Any(i => i.IsVisible(user));
  20. }
  21. protected override IEnumerable<BaseItem> GetEligibleChildrenForRecursiveChildren(User user)
  22. {
  23. return RecursiveChildren
  24. .OfType<Playlist>();
  25. }
  26. public override bool IsHidden
  27. {
  28. get
  29. {
  30. return true;
  31. }
  32. }
  33. public override bool IsHiddenFromUser(User user)
  34. {
  35. return false;
  36. }
  37. public override string CollectionType
  38. {
  39. get { return Model.Entities.CollectionType.Playlists; }
  40. }
  41. }
  42. public class PlaylistssDynamicFolder : IVirtualFolderCreator
  43. {
  44. private readonly IApplicationPaths _appPaths;
  45. public PlaylistssDynamicFolder(IApplicationPaths appPaths)
  46. {
  47. _appPaths = appPaths;
  48. }
  49. public BasePluginFolder GetFolder()
  50. {
  51. var path = Path.Combine(_appPaths.DataPath, "playlists");
  52. Directory.CreateDirectory(path);
  53. return new PlaylistsFolder
  54. {
  55. Path = path
  56. };
  57. }
  58. }
  59. }