IItemRepository.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. #nullable disable
  2. #pragma warning disable CS1591
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Threading;
  6. using System.Threading.Tasks;
  7. using Jellyfin.Data.Enums;
  8. using Jellyfin.Database.Implementations.Entities;
  9. using MediaBrowser.Controller.Entities;
  10. using MediaBrowser.Controller.Entities.Audio;
  11. using MediaBrowser.Model.Dto;
  12. using MediaBrowser.Model.Querying;
  13. namespace MediaBrowser.Controller.Persistence;
  14. /// <summary>
  15. /// Provides an interface to implement an Item repository.
  16. /// </summary>
  17. public interface IItemRepository
  18. {
  19. /// <summary>
  20. /// Deletes the item.
  21. /// </summary>
  22. /// <param name="ids">The identifier to delete.</param>
  23. void DeleteItem(params IReadOnlyList<Guid> ids);
  24. /// <summary>
  25. /// Saves the items.
  26. /// </summary>
  27. /// <param name="items">The items.</param>
  28. /// <param name="cancellationToken">The cancellation token.</param>
  29. void SaveItems(IReadOnlyList<BaseItem> items, CancellationToken cancellationToken);
  30. void SaveImages(BaseItem item);
  31. /// <summary>
  32. /// Retrieves the item.
  33. /// </summary>
  34. /// <param name="id">The id.</param>
  35. /// <returns>BaseItem.</returns>
  36. BaseItem RetrieveItem(Guid id);
  37. /// <summary>
  38. /// Gets the items.
  39. /// </summary>
  40. /// <param name="filter">The query.</param>
  41. /// <returns>QueryResult&lt;BaseItem&gt;.</returns>
  42. QueryResult<BaseItem> GetItems(InternalItemsQuery filter);
  43. /// <summary>
  44. /// Gets the item ids list.
  45. /// </summary>
  46. /// <param name="filter">The query.</param>
  47. /// <returns>List&lt;Guid&gt;.</returns>
  48. IReadOnlyList<Guid> GetItemIdsList(InternalItemsQuery filter);
  49. /// <summary>
  50. /// Gets the item list.
  51. /// </summary>
  52. /// <param name="filter">The query.</param>
  53. /// <returns>List&lt;BaseItem&gt;.</returns>
  54. IReadOnlyList<BaseItem> GetItemList(InternalItemsQuery filter);
  55. /// <summary>
  56. /// Gets the item list. Used mainly by the Latest api endpoint.
  57. /// </summary>
  58. /// <param name="filter">The query.</param>
  59. /// <param name="collectionType">Collection Type.</param>
  60. /// <returns>List&lt;BaseItem&gt;.</returns>
  61. IReadOnlyList<BaseItem> GetLatestItemList(InternalItemsQuery filter, CollectionType collectionType);
  62. /// <summary>
  63. /// Gets the list of series presentation keys for next up.
  64. /// </summary>
  65. /// <param name="filter">The query.</param>
  66. /// <param name="dateCutoff">The minimum date for a series to have been most recently watched.</param>
  67. /// <returns>The list of keys.</returns>
  68. IReadOnlyList<string> GetNextUpSeriesKeys(InternalItemsQuery filter, DateTime dateCutoff);
  69. /// <summary>
  70. /// Updates the inherited values.
  71. /// </summary>
  72. void UpdateInheritedValues();
  73. int GetCount(InternalItemsQuery filter);
  74. ItemCounts GetItemCounts(InternalItemsQuery filter);
  75. QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetGenres(InternalItemsQuery filter);
  76. QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetMusicGenres(InternalItemsQuery filter);
  77. QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetStudios(InternalItemsQuery filter);
  78. QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetArtists(InternalItemsQuery filter);
  79. QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetAlbumArtists(InternalItemsQuery filter);
  80. QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetAllArtists(InternalItemsQuery filter);
  81. IReadOnlyList<string> GetMusicGenreNames();
  82. IReadOnlyList<string> GetStudioNames();
  83. IReadOnlyList<string> GetGenreNames();
  84. IReadOnlyList<string> GetAllArtistNames();
  85. /// <summary>
  86. /// Checks if an item has been persisted to the database.
  87. /// </summary>
  88. /// <param name="id">The id to check.</param>
  89. /// <returns>True if the item exists, otherwise false.</returns>
  90. Task<bool> ItemExistsAsync(Guid id);
  91. /// <summary>
  92. /// Gets a value indicating wherever all children of the requested Id has been played.
  93. /// </summary>
  94. /// <param name="user">The userdata to check against.</param>
  95. /// <param name="id">The Top id to check.</param>
  96. /// <param name="recursive">Whever the check should be done recursive. Warning expensive operation.</param>
  97. /// <returns>A value indicating whever all children has been played.</returns>
  98. bool GetIsPlayed(User user, Guid id, bool recursive);
  99. /// <summary>
  100. /// Gets all artist matches from the db.
  101. /// </summary>
  102. /// <param name="artistNames">The names of the artists.</param>
  103. /// <returns>A map of the artist name and the potential matches.</returns>
  104. IReadOnlyDictionary<string, MusicArtist[]> FindArtists(IReadOnlyList<string> artistNames);
  105. }