ManualPlaylistsFolder.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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 MediaBrowser.Model.IO;
  8. using MediaBrowser.Model.Querying;
  9. using System.Threading.Tasks;
  10. using MediaBrowser.Common.IO;
  11. using MediaBrowser.Controller.IO;
  12. namespace MediaBrowser.Server.Implementations.Playlists
  13. {
  14. public class PlaylistsFolder : BasePluginFolder
  15. {
  16. public PlaylistsFolder()
  17. {
  18. Name = "Playlists";
  19. }
  20. public override bool IsVisible(User user)
  21. {
  22. return base.IsVisible(user) && GetChildren(user, true).Any();
  23. }
  24. protected override IEnumerable<BaseItem> GetEligibleChildrenForRecursiveChildren(User user)
  25. {
  26. return base.GetEligibleChildrenForRecursiveChildren(user).OfType<Playlist>();
  27. }
  28. public override bool IsHidden
  29. {
  30. get
  31. {
  32. return true;
  33. }
  34. }
  35. public override string CollectionType
  36. {
  37. get { return Model.Entities.CollectionType.Playlists; }
  38. }
  39. protected override Task<QueryResult<BaseItem>> GetItemsInternal(InternalItemsQuery query)
  40. {
  41. query.Recursive = false;
  42. return base.GetItemsInternal(query);
  43. }
  44. }
  45. public class PlaylistsDynamicFolder : IVirtualFolderCreator
  46. {
  47. private readonly IApplicationPaths _appPaths;
  48. private readonly IFileSystem _fileSystem;
  49. public PlaylistsDynamicFolder(IApplicationPaths appPaths, IFileSystem fileSystem)
  50. {
  51. _appPaths = appPaths;
  52. _fileSystem = fileSystem;
  53. }
  54. public BasePluginFolder GetFolder()
  55. {
  56. var path = Path.Combine(_appPaths.DataPath, "playlists");
  57. _fileSystem.CreateDirectory(path);
  58. return new PlaylistsFolder
  59. {
  60. Path = path
  61. };
  62. }
  63. }
  64. }