ManualPlaylistsFolder.cs 1.9 KB

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