ManualPlaylistsFolder.cs 1.6 KB

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