ILibraryManager.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568
  1. using MediaBrowser.Controller.Entities;
  2. using MediaBrowser.Controller.Entities.Audio;
  3. using MediaBrowser.Controller.Entities.TV;
  4. using MediaBrowser.Controller.Providers;
  5. using MediaBrowser.Controller.Resolvers;
  6. using MediaBrowser.Controller.Sorting;
  7. using MediaBrowser.Model.Entities;
  8. using MediaBrowser.Model.Querying;
  9. using System;
  10. using System.Collections.Generic;
  11. using System.Threading;
  12. using System.Threading.Tasks;
  13. using MediaBrowser.Controller.Configuration;
  14. using MediaBrowser.Controller.Dto;
  15. using MediaBrowser.Controller.IO;
  16. using MediaBrowser.Model.Configuration;
  17. using MediaBrowser.Model.Dto;
  18. using MediaBrowser.Model.IO;
  19. namespace MediaBrowser.Controller.Library
  20. {
  21. /// <summary>
  22. /// Interface ILibraryManager
  23. /// </summary>
  24. public interface ILibraryManager
  25. {
  26. /// <summary>
  27. /// Resolves the path.
  28. /// </summary>
  29. /// <param name="fileInfo">The file information.</param>
  30. /// <param name="parent">The parent.</param>
  31. /// <returns>BaseItem.</returns>
  32. BaseItem ResolvePath(FileSystemMetadata fileInfo,
  33. Folder parent = null);
  34. /// <summary>
  35. /// Resolves a set of files into a list of BaseItem
  36. /// </summary>
  37. IEnumerable<BaseItem> ResolvePaths(IEnumerable<FileSystemMetadata> files,
  38. IDirectoryService directoryService,
  39. Folder parent,
  40. LibraryOptions libraryOptions,
  41. string collectionType = null);
  42. /// <summary>
  43. /// Gets the root folder.
  44. /// </summary>
  45. /// <value>The root folder.</value>
  46. AggregateFolder RootFolder { get; }
  47. /// <summary>
  48. /// Gets a Person
  49. /// </summary>
  50. /// <param name="name">The name.</param>
  51. /// <returns>Task{Person}.</returns>
  52. Person GetPerson(string name);
  53. /// <summary>
  54. /// Finds the by path.
  55. /// </summary>
  56. /// <param name="path">The path.</param>
  57. /// <returns>BaseItem.</returns>
  58. BaseItem FindByPath(string path, bool? isFolder);
  59. /// <summary>
  60. /// Gets the artist.
  61. /// </summary>
  62. /// <param name="name">The name.</param>
  63. /// <returns>Task{Artist}.</returns>
  64. MusicArtist GetArtist(string name);
  65. MusicArtist GetArtist(string name, DtoOptions options);
  66. /// <summary>
  67. /// Gets a Studio
  68. /// </summary>
  69. /// <param name="name">The name.</param>
  70. /// <returns>Task{Studio}.</returns>
  71. Studio GetStudio(string name);
  72. /// <summary>
  73. /// Gets a Genre
  74. /// </summary>
  75. /// <param name="name">The name.</param>
  76. /// <returns>Task{Genre}.</returns>
  77. Genre GetGenre(string name);
  78. /// <summary>
  79. /// Gets the genre.
  80. /// </summary>
  81. /// <param name="name">The name.</param>
  82. /// <returns>Task{MusicGenre}.</returns>
  83. MusicGenre GetMusicGenre(string name);
  84. /// <summary>
  85. /// Gets the game genre.
  86. /// </summary>
  87. /// <param name="name">The name.</param>
  88. /// <returns>Task{GameGenre}.</returns>
  89. GameGenre GetGameGenre(string name);
  90. /// <summary>
  91. /// Gets a Year
  92. /// </summary>
  93. /// <param name="value">The value.</param>
  94. /// <returns>Task{Year}.</returns>
  95. /// <exception cref="System.ArgumentOutOfRangeException"></exception>
  96. Year GetYear(int value);
  97. /// <summary>
  98. /// Validate and refresh the People sub-set of the IBN.
  99. /// The items are stored in the db but not loaded into memory until actually requested by an operation.
  100. /// </summary>
  101. /// <param name="cancellationToken">The cancellation token.</param>
  102. /// <param name="progress">The progress.</param>
  103. /// <returns>Task.</returns>
  104. Task ValidatePeople(CancellationToken cancellationToken, IProgress<double> progress);
  105. /// <summary>
  106. /// Reloads the root media folder
  107. /// </summary>
  108. /// <param name="progress">The progress.</param>
  109. /// <param name="cancellationToken">The cancellation token.</param>
  110. /// <returns>Task.</returns>
  111. Task ValidateMediaLibrary(IProgress<double> progress, CancellationToken cancellationToken);
  112. /// <summary>
  113. /// Queues the library scan.
  114. /// </summary>
  115. void QueueLibraryScan();
  116. /// <summary>
  117. /// Gets the default view.
  118. /// </summary>
  119. /// <returns>IEnumerable{VirtualFolderInfo}.</returns>
  120. List<VirtualFolderInfo> GetVirtualFolders();
  121. List<VirtualFolderInfo> GetVirtualFolders(bool includeRefreshState);
  122. /// <summary>
  123. /// Gets the item by id.
  124. /// </summary>
  125. /// <param name="id">The id.</param>
  126. /// <returns>BaseItem.</returns>
  127. BaseItem GetItemById(Guid id);
  128. /// <summary>
  129. /// Gets the intros.
  130. /// </summary>
  131. /// <param name="item">The item.</param>
  132. /// <param name="user">The user.</param>
  133. /// <returns>IEnumerable{System.String}.</returns>
  134. Task<IEnumerable<Video>> GetIntros(BaseItem item, User user);
  135. /// <summary>
  136. /// Gets all intro files.
  137. /// </summary>
  138. /// <returns>IEnumerable{System.String}.</returns>
  139. IEnumerable<string> GetAllIntroFiles();
  140. /// <summary>
  141. /// Adds the parts.
  142. /// </summary>
  143. /// <param name="rules">The rules.</param>
  144. /// <param name="pluginFolders">The plugin folders.</param>
  145. /// <param name="resolvers">The resolvers.</param>
  146. /// <param name="introProviders">The intro providers.</param>
  147. /// <param name="itemComparers">The item comparers.</param>
  148. /// <param name="postscanTasks">The postscan tasks.</param>
  149. void AddParts(IEnumerable<IResolverIgnoreRule> rules,
  150. IEnumerable<IVirtualFolderCreator> pluginFolders,
  151. IEnumerable<IItemResolver> resolvers,
  152. IEnumerable<IIntroProvider> introProviders,
  153. IEnumerable<IBaseItemComparer> itemComparers,
  154. IEnumerable<ILibraryPostScanTask> postscanTasks);
  155. /// <summary>
  156. /// Sorts the specified items.
  157. /// </summary>
  158. /// <param name="items">The items.</param>
  159. /// <param name="user">The user.</param>
  160. /// <param name="sortBy">The sort by.</param>
  161. /// <param name="sortOrder">The sort order.</param>
  162. /// <returns>IEnumerable{BaseItem}.</returns>
  163. IEnumerable<BaseItem> Sort(IEnumerable<BaseItem> items, User user, IEnumerable<string> sortBy, SortOrder sortOrder);
  164. IEnumerable<BaseItem> Sort(IEnumerable<BaseItem> items, User user, IEnumerable<Tuple<string, SortOrder>> orderBy);
  165. /// <summary>
  166. /// Gets the user root folder.
  167. /// </summary>
  168. /// <returns>UserRootFolder.</returns>
  169. Folder GetUserRootFolder();
  170. /// <summary>
  171. /// Creates the item.
  172. /// </summary>
  173. /// <param name="item">The item.</param>
  174. /// <param name="cancellationToken">The cancellation token.</param>
  175. void CreateItem(BaseItem item, CancellationToken cancellationToken);
  176. /// <summary>
  177. /// Creates the items.
  178. /// </summary>
  179. /// <param name="items">The items.</param>
  180. /// <param name="cancellationToken">The cancellation token.</param>
  181. void CreateItems(IEnumerable<BaseItem> items, CancellationToken cancellationToken);
  182. /// <summary>
  183. /// Updates the item.
  184. /// </summary>
  185. /// <param name="item">The item.</param>
  186. /// <param name="updateReason">The update reason.</param>
  187. /// <param name="cancellationToken">The cancellation token.</param>
  188. /// <returns>Task.</returns>
  189. Task UpdateItem(BaseItem item, ItemUpdateType updateReason, CancellationToken cancellationToken);
  190. /// <summary>
  191. /// Retrieves the item.
  192. /// </summary>
  193. /// <param name="id">The id.</param>
  194. /// <returns>BaseItem.</returns>
  195. BaseItem RetrieveItem(Guid id);
  196. bool IsScanRunning { get; }
  197. /// <summary>
  198. /// Occurs when [item added].
  199. /// </summary>
  200. event EventHandler<ItemChangeEventArgs> ItemAdded;
  201. /// <summary>
  202. /// Occurs when [item updated].
  203. /// </summary>
  204. event EventHandler<ItemChangeEventArgs> ItemUpdated;
  205. /// <summary>
  206. /// Occurs when [item removed].
  207. /// </summary>
  208. event EventHandler<ItemChangeEventArgs> ItemRemoved;
  209. /// <summary>
  210. /// Reports the item removed.
  211. /// </summary>
  212. /// <param name="item">The item.</param>
  213. void ReportItemRemoved(BaseItem item);
  214. /// <summary>
  215. /// Finds the type of the collection.
  216. /// </summary>
  217. /// <param name="item">The item.</param>
  218. /// <returns>System.String.</returns>
  219. string GetContentType(BaseItem item);
  220. /// <summary>
  221. /// Gets the type of the inherited content.
  222. /// </summary>
  223. /// <param name="item">The item.</param>
  224. /// <returns>System.String.</returns>
  225. string GetInheritedContentType(BaseItem item);
  226. /// <summary>
  227. /// Gets the type of the configured content.
  228. /// </summary>
  229. /// <param name="item">The item.</param>
  230. /// <returns>System.String.</returns>
  231. string GetConfiguredContentType(BaseItem item);
  232. /// <summary>
  233. /// Gets the type of the configured content.
  234. /// </summary>
  235. /// <param name="path">The path.</param>
  236. /// <returns>System.String.</returns>
  237. string GetConfiguredContentType(string path);
  238. /// <summary>
  239. /// Normalizes the root path list.
  240. /// </summary>
  241. /// <param name="paths">The paths.</param>
  242. /// <returns>IEnumerable{System.String}.</returns>
  243. List<FileSystemMetadata> NormalizeRootPathList(IEnumerable<FileSystemMetadata> paths);
  244. /// <summary>
  245. /// Registers the item.
  246. /// </summary>
  247. /// <param name="item">The item.</param>
  248. void RegisterItem(BaseItem item);
  249. /// <summary>
  250. /// Deletes the item.
  251. /// </summary>
  252. /// <param name="item">The item.</param>
  253. /// <param name="options">The options.</param>
  254. /// <returns>Task.</returns>
  255. Task DeleteItem(BaseItem item, DeleteOptions options);
  256. /// <summary>
  257. /// Gets the named view.
  258. /// </summary>
  259. /// <param name="user">The user.</param>
  260. /// <param name="name">The name.</param>
  261. /// <param name="parentId">The parent identifier.</param>
  262. /// <param name="viewType">Type of the view.</param>
  263. /// <param name="sortName">Name of the sort.</param>
  264. /// <param name="cancellationToken">The cancellation token.</param>
  265. /// <returns>Task&lt;UserView&gt;.</returns>
  266. UserView GetNamedView(User user,
  267. string name,
  268. string parentId,
  269. string viewType,
  270. string sortName,
  271. CancellationToken cancellationToken);
  272. /// <summary>
  273. /// Gets the named view.
  274. /// </summary>
  275. /// <param name="user">The user.</param>
  276. /// <param name="name">The name.</param>
  277. /// <param name="viewType">Type of the view.</param>
  278. /// <param name="sortName">Name of the sort.</param>
  279. /// <param name="cancellationToken">The cancellation token.</param>
  280. /// <returns>Task&lt;UserView&gt;.</returns>
  281. UserView GetNamedView(User user,
  282. string name,
  283. string viewType,
  284. string sortName,
  285. CancellationToken cancellationToken);
  286. /// <summary>
  287. /// Gets the named view.
  288. /// </summary>
  289. /// <param name="name">The name.</param>
  290. /// <param name="viewType">Type of the view.</param>
  291. /// <param name="sortName">Name of the sort.</param>
  292. /// <param name="cancellationToken">The cancellation token.</param>
  293. /// <returns>Task&lt;UserView&gt;.</returns>
  294. Task<UserView> GetNamedView(string name,
  295. string viewType,
  296. string sortName,
  297. CancellationToken cancellationToken);
  298. /// <summary>
  299. /// Gets the named view.
  300. /// </summary>
  301. /// <param name="name">The name.</param>
  302. /// <param name="parentId">The parent identifier.</param>
  303. /// <param name="viewType">Type of the view.</param>
  304. /// <param name="sortName">Name of the sort.</param>
  305. /// <param name="uniqueId">The unique identifier.</param>
  306. /// <param name="cancellationToken">The cancellation token.</param>
  307. /// <returns>Task&lt;UserView&gt;.</returns>
  308. Task<UserView> GetNamedView(string name,
  309. string parentId,
  310. string viewType,
  311. string sortName,
  312. string uniqueId,
  313. CancellationToken cancellationToken);
  314. /// <summary>
  315. /// Gets the shadow view.
  316. /// </summary>
  317. /// <param name="parent">The parent.</param>
  318. /// <param name="viewType">Type of the view.</param>
  319. /// <param name="sortName">Name of the sort.</param>
  320. /// <param name="cancellationToken">The cancellation token.</param>
  321. /// <returns>Task&lt;UserView&gt;.</returns>
  322. UserView GetShadowView(BaseItem parent,
  323. string viewType,
  324. string sortName,
  325. CancellationToken cancellationToken);
  326. /// <summary>
  327. /// Determines whether [is video file] [the specified path].
  328. /// </summary>
  329. /// <param name="path">The path.</param>
  330. /// <returns><c>true</c> if [is video file] [the specified path]; otherwise, <c>false</c>.</returns>
  331. bool IsVideoFile(string path);
  332. /// <summary>
  333. /// Determines whether [is audio file] [the specified path].
  334. /// </summary>
  335. /// <param name="path">The path.</param>
  336. /// <returns><c>true</c> if [is audio file] [the specified path]; otherwise, <c>false</c>.</returns>
  337. bool IsAudioFile(string path);
  338. bool IsAudioFile(string path, LibraryOptions libraryOptions);
  339. bool IsVideoFile(string path, LibraryOptions libraryOptions);
  340. /// <summary>
  341. /// Gets the season number from path.
  342. /// </summary>
  343. /// <param name="path">The path.</param>
  344. /// <returns>System.Nullable&lt;System.Int32&gt;.</returns>
  345. int? GetSeasonNumberFromPath(string path);
  346. /// <summary>
  347. /// Fills the missing episode numbers from path.
  348. /// </summary>
  349. /// <param name="episode">The episode.</param>
  350. /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
  351. bool FillMissingEpisodeNumbersFromPath(Episode episode);
  352. /// <summary>
  353. /// Parses the name.
  354. /// </summary>
  355. /// <param name="name">The name.</param>
  356. /// <returns>ItemInfo.</returns>
  357. ItemLookupInfo ParseName(string name);
  358. /// <summary>
  359. /// Gets the new item identifier.
  360. /// </summary>
  361. /// <param name="key">The key.</param>
  362. /// <param name="type">The type.</param>
  363. /// <returns>Guid.</returns>
  364. Guid GetNewItemId(string key, Type type);
  365. /// <summary>
  366. /// Finds the trailers.
  367. /// </summary>
  368. /// <param name="owner">The owner.</param>
  369. /// <param name="fileSystemChildren">The file system children.</param>
  370. /// <param name="directoryService">The directory service.</param>
  371. /// <returns>IEnumerable&lt;Trailer&gt;.</returns>
  372. IEnumerable<Video> FindTrailers(BaseItem owner, List<FileSystemMetadata> fileSystemChildren,
  373. IDirectoryService directoryService);
  374. /// <summary>
  375. /// Finds the extras.
  376. /// </summary>
  377. /// <param name="owner">The owner.</param>
  378. /// <param name="fileSystemChildren">The file system children.</param>
  379. /// <param name="directoryService">The directory service.</param>
  380. /// <returns>IEnumerable&lt;Video&gt;.</returns>
  381. IEnumerable<Video> FindExtras(BaseItem owner, List<FileSystemMetadata> fileSystemChildren,
  382. IDirectoryService directoryService);
  383. /// <summary>
  384. /// Gets the collection folders.
  385. /// </summary>
  386. /// <param name="item">The item.</param>
  387. /// <returns>IEnumerable&lt;Folder&gt;.</returns>
  388. List<Folder> GetCollectionFolders(BaseItem item);
  389. List<Folder> GetCollectionFolders(BaseItem item, List<Folder> allUserRootChildren);
  390. LibraryOptions GetLibraryOptions(BaseItem item);
  391. /// <summary>
  392. /// Gets the people.
  393. /// </summary>
  394. /// <param name="item">The item.</param>
  395. /// <returns>List&lt;PersonInfo&gt;.</returns>
  396. List<PersonInfo> GetPeople(BaseItem item);
  397. /// <summary>
  398. /// Gets the people.
  399. /// </summary>
  400. /// <param name="query">The query.</param>
  401. /// <returns>List&lt;PersonInfo&gt;.</returns>
  402. List<PersonInfo> GetPeople(InternalPeopleQuery query);
  403. /// <summary>
  404. /// Gets the people items.
  405. /// </summary>
  406. /// <param name="query">The query.</param>
  407. /// <returns>List&lt;Person&gt;.</returns>
  408. List<Person> GetPeopleItems(InternalPeopleQuery query);
  409. /// <summary>
  410. /// Updates the people.
  411. /// </summary>
  412. /// <param name="item">The item.</param>
  413. /// <param name="people">The people.</param>
  414. void UpdatePeople(BaseItem item, List<PersonInfo> people);
  415. /// <summary>
  416. /// Gets the item ids.
  417. /// </summary>
  418. /// <param name="query">The query.</param>
  419. /// <returns>List&lt;Guid&gt;.</returns>
  420. List<Guid> GetItemIds(InternalItemsQuery query);
  421. /// <summary>
  422. /// Gets the people names.
  423. /// </summary>
  424. /// <param name="query">The query.</param>
  425. /// <returns>List&lt;System.String&gt;.</returns>
  426. List<string> GetPeopleNames(InternalPeopleQuery query);
  427. /// <summary>
  428. /// Queries the items.
  429. /// </summary>
  430. /// <param name="query">The query.</param>
  431. /// <returns>QueryResult&lt;BaseItem&gt;.</returns>
  432. QueryResult<BaseItem> QueryItems(InternalItemsQuery query);
  433. string GetPathAfterNetworkSubstitution(string path, BaseItem ownerItem = null);
  434. /// <summary>
  435. /// Substitutes the path.
  436. /// </summary>
  437. /// <param name="path">The path.</param>
  438. /// <param name="from">From.</param>
  439. /// <param name="to">To.</param>
  440. /// <returns>System.String.</returns>
  441. string SubstitutePath(string path, string from, string to);
  442. /// <summary>
  443. /// Converts the image to local.
  444. /// </summary>
  445. /// <param name="item">The item.</param>
  446. /// <param name="image">The image.</param>
  447. /// <param name="imageIndex">Index of the image.</param>
  448. /// <returns>Task.</returns>
  449. Task<ItemImageInfo> ConvertImageToLocal(IHasMetadata item, ItemImageInfo image, int imageIndex);
  450. /// <summary>
  451. /// Gets the items.
  452. /// </summary>
  453. /// <param name="query">The query.</param>
  454. /// <returns>QueryResult&lt;BaseItem&gt;.</returns>
  455. List<BaseItem> GetItemList(InternalItemsQuery query);
  456. List<BaseItem> GetItemList(InternalItemsQuery query, bool allowExternalContent);
  457. /// <summary>
  458. /// Gets the items.
  459. /// </summary>
  460. List<BaseItem> GetItemList(InternalItemsQuery query, List<BaseItem> parents);
  461. /// <summary>
  462. /// Gets the items result.
  463. /// </summary>
  464. /// <param name="query">The query.</param>
  465. /// <returns>QueryResult&lt;BaseItem&gt;.</returns>
  466. QueryResult<BaseItem> GetItemsResult(InternalItemsQuery query);
  467. /// <summary>
  468. /// Ignores the file.
  469. /// </summary>
  470. /// <param name="file">The file.</param>
  471. /// <param name="parent">The parent.</param>
  472. /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
  473. bool IgnoreFile(FileSystemMetadata file, BaseItem parent);
  474. Guid GetStudioId(string name);
  475. Guid GetGenreId(string name);
  476. Guid GetMusicGenreId(string name);
  477. Guid GetGameGenreId(string name);
  478. void AddVirtualFolder(string name, string collectionType, LibraryOptions options, bool refreshLibrary);
  479. void RemoveVirtualFolder(string name, bool refreshLibrary);
  480. void AddMediaPath(string virtualFolderName, MediaPathInfo path);
  481. void UpdateMediaPath(string virtualFolderName, MediaPathInfo path);
  482. void RemoveMediaPath(string virtualFolderName, string path);
  483. QueryResult<Tuple<BaseItem, ItemCounts>> GetGenres(InternalItemsQuery query);
  484. QueryResult<Tuple<BaseItem, ItemCounts>> GetMusicGenres(InternalItemsQuery query);
  485. QueryResult<Tuple<BaseItem, ItemCounts>> GetGameGenres(InternalItemsQuery query);
  486. QueryResult<Tuple<BaseItem, ItemCounts>> GetStudios(InternalItemsQuery query);
  487. QueryResult<Tuple<BaseItem, ItemCounts>> GetArtists(InternalItemsQuery query);
  488. QueryResult<Tuple<BaseItem, ItemCounts>> GetAlbumArtists(InternalItemsQuery query);
  489. QueryResult<Tuple<BaseItem, ItemCounts>> GetAllArtists(InternalItemsQuery query);
  490. int GetCount(InternalItemsQuery query);
  491. }
  492. }