ItemTypeLookup.cs 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Threading.Channels;
  4. using Emby.Server.Implementations.Playlists;
  5. using Jellyfin.Data.Enums;
  6. using MediaBrowser.Controller.Entities;
  7. using MediaBrowser.Controller.Entities.Audio;
  8. using MediaBrowser.Controller.Entities.Movies;
  9. using MediaBrowser.Controller.Entities.TV;
  10. using MediaBrowser.Controller.LiveTv;
  11. using MediaBrowser.Controller.Persistence;
  12. using MediaBrowser.Controller.Playlists;
  13. using MediaBrowser.Model.Querying;
  14. namespace Jellyfin.Server.Implementations.Item;
  15. /// <summary>
  16. /// Provides static topic based lookups for the BaseItemKind.
  17. /// </summary>
  18. public class ItemTypeLookup : IItemTypeLookup
  19. {
  20. /// <summary>
  21. /// Gets all values of the ItemFields type.
  22. /// </summary>
  23. public IReadOnlyList<ItemFields> AllItemFields { get; } = Enum.GetValues<ItemFields>();
  24. /// <summary>
  25. /// Gets all BaseItemKinds that are considered Programs.
  26. /// </summary>
  27. public IReadOnlyList<BaseItemKind> ProgramTypes { get; } =
  28. [
  29. BaseItemKind.Program,
  30. BaseItemKind.TvChannel,
  31. BaseItemKind.LiveTvProgram,
  32. BaseItemKind.LiveTvChannel
  33. ];
  34. /// <summary>
  35. /// Gets all BaseItemKinds that should be excluded from parent lookup.
  36. /// </summary>
  37. public IReadOnlyList<BaseItemKind> ProgramExcludeParentTypes { get; } =
  38. [
  39. BaseItemKind.Series,
  40. BaseItemKind.Season,
  41. BaseItemKind.MusicAlbum,
  42. BaseItemKind.MusicArtist,
  43. BaseItemKind.PhotoAlbum
  44. ];
  45. /// <summary>
  46. /// Gets all BaseItemKinds that are considered to be provided by services.
  47. /// </summary>
  48. public IReadOnlyList<BaseItemKind> ServiceTypes { get; } =
  49. [
  50. BaseItemKind.TvChannel,
  51. BaseItemKind.LiveTvChannel
  52. ];
  53. /// <summary>
  54. /// Gets all BaseItemKinds that have a StartDate.
  55. /// </summary>
  56. public IReadOnlyList<BaseItemKind> StartDateTypes { get; } =
  57. [
  58. BaseItemKind.Program,
  59. BaseItemKind.LiveTvProgram
  60. ];
  61. /// <summary>
  62. /// Gets all BaseItemKinds that are considered Series.
  63. /// </summary>
  64. public IReadOnlyList<BaseItemKind> SeriesTypes { get; } =
  65. [
  66. BaseItemKind.Book,
  67. BaseItemKind.AudioBook,
  68. BaseItemKind.Episode,
  69. BaseItemKind.Season
  70. ];
  71. /// <summary>
  72. /// Gets all BaseItemKinds that are not to be evaluated for Artists.
  73. /// </summary>
  74. public IReadOnlyList<BaseItemKind> ArtistExcludeParentTypes { get; } =
  75. [
  76. BaseItemKind.Series,
  77. BaseItemKind.Season,
  78. BaseItemKind.PhotoAlbum
  79. ];
  80. /// <summary>
  81. /// Gets all BaseItemKinds that are considered Artists.
  82. /// </summary>
  83. public IReadOnlyList<BaseItemKind> ArtistsTypes { get; } =
  84. [
  85. BaseItemKind.Audio,
  86. BaseItemKind.MusicAlbum,
  87. BaseItemKind.MusicVideo,
  88. BaseItemKind.AudioBook
  89. ];
  90. /// <summary>
  91. /// Gets mapping for all BaseItemKinds and their expected serialisaition target.
  92. /// </summary>
  93. public IDictionary<BaseItemKind, string?> BaseItemKindNames { get; } = new Dictionary<BaseItemKind, string?>()
  94. {
  95. { BaseItemKind.AggregateFolder, typeof(AggregateFolder).FullName },
  96. { BaseItemKind.Audio, typeof(Audio).FullName },
  97. { BaseItemKind.AudioBook, typeof(AudioBook).FullName },
  98. { BaseItemKind.BasePluginFolder, typeof(BasePluginFolder).FullName },
  99. { BaseItemKind.Book, typeof(Book).FullName },
  100. { BaseItemKind.BoxSet, typeof(BoxSet).FullName },
  101. { BaseItemKind.Channel, typeof(Channel).FullName },
  102. { BaseItemKind.CollectionFolder, typeof(CollectionFolder).FullName },
  103. { BaseItemKind.Episode, typeof(Episode).FullName },
  104. { BaseItemKind.Folder, typeof(Folder).FullName },
  105. { BaseItemKind.Genre, typeof(Genre).FullName },
  106. { BaseItemKind.Movie, typeof(Movie).FullName },
  107. { BaseItemKind.LiveTvChannel, typeof(LiveTvChannel).FullName },
  108. { BaseItemKind.LiveTvProgram, typeof(LiveTvProgram).FullName },
  109. { BaseItemKind.MusicAlbum, typeof(MusicAlbum).FullName },
  110. { BaseItemKind.MusicArtist, typeof(MusicArtist).FullName },
  111. { BaseItemKind.MusicGenre, typeof(MusicGenre).FullName },
  112. { BaseItemKind.MusicVideo, typeof(MusicVideo).FullName },
  113. { BaseItemKind.Person, typeof(Person).FullName },
  114. { BaseItemKind.Photo, typeof(Photo).FullName },
  115. { BaseItemKind.PhotoAlbum, typeof(PhotoAlbum).FullName },
  116. { BaseItemKind.Playlist, typeof(Playlist).FullName },
  117. { BaseItemKind.PlaylistsFolder, typeof(PlaylistsFolder).FullName },
  118. { BaseItemKind.Season, typeof(Season).FullName },
  119. { BaseItemKind.Series, typeof(Series).FullName },
  120. { BaseItemKind.Studio, typeof(Studio).FullName },
  121. { BaseItemKind.Trailer, typeof(Trailer).FullName },
  122. { BaseItemKind.TvChannel, typeof(LiveTvChannel).FullName },
  123. { BaseItemKind.TvProgram, typeof(LiveTvProgram).FullName },
  124. { BaseItemKind.UserRootFolder, typeof(UserRootFolder).FullName },
  125. { BaseItemKind.UserView, typeof(UserView).FullName },
  126. { BaseItemKind.Video, typeof(Video).FullName },
  127. { BaseItemKind.Year, typeof(Year).FullName }
  128. }.AsReadOnly();
  129. }