ManualPlaylistsFolder.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. 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 base.GetEligibleChildrenForRecursiveChildren(user).OfType<Playlist>();
  23. }
  24. public override bool IsHidden
  25. {
  26. get
  27. {
  28. return true;
  29. }
  30. }
  31. public override string CollectionType
  32. {
  33. get { return Model.Entities.CollectionType.Playlists; }
  34. }
  35. }
  36. public class PlaylistsDynamicFolder : IVirtualFolderCreator
  37. {
  38. private readonly IApplicationPaths _appPaths;
  39. private readonly IFileSystem _fileSystem;
  40. public PlaylistsDynamicFolder(IApplicationPaths appPaths, IFileSystem fileSystem)
  41. {
  42. _appPaths = appPaths;
  43. _fileSystem = fileSystem;
  44. }
  45. public BasePluginFolder GetFolder()
  46. {
  47. var path = Path.Combine(_appPaths.DataPath, "playlists");
  48. _fileSystem.CreateDirectory(path);
  49. return new PlaylistsFolder
  50. {
  51. Path = path
  52. };
  53. }
  54. }
  55. }