ILibraryManager.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564
  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. void UpdateImages(BaseItem item);
  117. /// <summary>
  118. /// Gets the default view.
  119. /// </summary>
  120. /// <returns>IEnumerable{VirtualFolderInfo}.</returns>
  121. List<VirtualFolderInfo> GetVirtualFolders();
  122. List<VirtualFolderInfo> GetVirtualFolders(bool includeRefreshState);
  123. /// <summary>
  124. /// Gets the item by id.
  125. /// </summary>
  126. /// <param name="id">The id.</param>
  127. /// <returns>BaseItem.</returns>
  128. BaseItem GetItemById(Guid id);
  129. /// <summary>
  130. /// Gets the intros.
  131. /// </summary>
  132. /// <param name="item">The item.</param>
  133. /// <param name="user">The user.</param>
  134. /// <returns>IEnumerable{System.String}.</returns>
  135. Task<IEnumerable<Video>> GetIntros(BaseItem item, User user);
  136. /// <summary>
  137. /// Gets all intro files.
  138. /// </summary>
  139. /// <returns>IEnumerable{System.String}.</returns>
  140. IEnumerable<string> GetAllIntroFiles();
  141. /// <summary>
  142. /// Adds the parts.
  143. /// </summary>
  144. /// <param name="rules">The rules.</param>
  145. /// <param name="pluginFolders">The plugin folders.</param>
  146. /// <param name="resolvers">The resolvers.</param>
  147. /// <param name="introProviders">The intro providers.</param>
  148. /// <param name="itemComparers">The item comparers.</param>
  149. /// <param name="postscanTasks">The postscan tasks.</param>
  150. void AddParts(IEnumerable<IResolverIgnoreRule> rules,
  151. IEnumerable<IVirtualFolderCreator> pluginFolders,
  152. IEnumerable<IItemResolver> resolvers,
  153. IEnumerable<IIntroProvider> introProviders,
  154. IEnumerable<IBaseItemComparer> itemComparers,
  155. IEnumerable<ILibraryPostScanTask> postscanTasks);
  156. /// <summary>
  157. /// Sorts the specified items.
  158. /// </summary>
  159. /// <param name="items">The items.</param>
  160. /// <param name="user">The user.</param>
  161. /// <param name="sortBy">The sort by.</param>
  162. /// <param name="sortOrder">The sort order.</param>
  163. /// <returns>IEnumerable{BaseItem}.</returns>
  164. IEnumerable<BaseItem> Sort(IEnumerable<BaseItem> items, User user, IEnumerable<string> sortBy, SortOrder sortOrder);
  165. IEnumerable<BaseItem> Sort(IEnumerable<BaseItem> items, User user, IEnumerable<Tuple<string, SortOrder>> orderBy);
  166. /// <summary>
  167. /// Gets the user root folder.
  168. /// </summary>
  169. /// <returns>UserRootFolder.</returns>
  170. Folder GetUserRootFolder();
  171. /// <summary>
  172. /// Creates the item.
  173. /// </summary>
  174. /// <param name="item">The item.</param>
  175. /// <param name="cancellationToken">The cancellation token.</param>
  176. void CreateItem(BaseItem item, CancellationToken cancellationToken);
  177. /// <summary>
  178. /// Creates the items.
  179. /// </summary>
  180. /// <param name="items">The items.</param>
  181. /// <param name="cancellationToken">The cancellation token.</param>
  182. void CreateItems(IEnumerable<BaseItem> items, CancellationToken cancellationToken);
  183. /// <summary>
  184. /// Updates the item.
  185. /// </summary>
  186. void UpdateItem(BaseItem item, ItemUpdateType updateReason, CancellationToken cancellationToken);
  187. /// <summary>
  188. /// Retrieves the item.
  189. /// </summary>
  190. /// <param name="id">The id.</param>
  191. /// <returns>BaseItem.</returns>
  192. BaseItem RetrieveItem(Guid id);
  193. bool IsScanRunning { get; }
  194. /// <summary>
  195. /// Occurs when [item added].
  196. /// </summary>
  197. event EventHandler<ItemChangeEventArgs> ItemAdded;
  198. /// <summary>
  199. /// Occurs when [item updated].
  200. /// </summary>
  201. event EventHandler<ItemChangeEventArgs> ItemUpdated;
  202. /// <summary>
  203. /// Occurs when [item removed].
  204. /// </summary>
  205. event EventHandler<ItemChangeEventArgs> ItemRemoved;
  206. /// <summary>
  207. /// Reports the item removed.
  208. /// </summary>
  209. /// <param name="item">The item.</param>
  210. void ReportItemRemoved(BaseItem item);
  211. /// <summary>
  212. /// Finds the type of the collection.
  213. /// </summary>
  214. /// <param name="item">The item.</param>
  215. /// <returns>System.String.</returns>
  216. string GetContentType(BaseItem item);
  217. /// <summary>
  218. /// Gets the type of the inherited content.
  219. /// </summary>
  220. /// <param name="item">The item.</param>
  221. /// <returns>System.String.</returns>
  222. string GetInheritedContentType(BaseItem item);
  223. /// <summary>
  224. /// Gets the type of the configured content.
  225. /// </summary>
  226. /// <param name="item">The item.</param>
  227. /// <returns>System.String.</returns>
  228. string GetConfiguredContentType(BaseItem item);
  229. /// <summary>
  230. /// Gets the type of the configured content.
  231. /// </summary>
  232. /// <param name="path">The path.</param>
  233. /// <returns>System.String.</returns>
  234. string GetConfiguredContentType(string path);
  235. /// <summary>
  236. /// Normalizes the root path list.
  237. /// </summary>
  238. /// <param name="paths">The paths.</param>
  239. /// <returns>IEnumerable{System.String}.</returns>
  240. List<FileSystemMetadata> NormalizeRootPathList(IEnumerable<FileSystemMetadata> paths);
  241. /// <summary>
  242. /// Registers the item.
  243. /// </summary>
  244. /// <param name="item">The item.</param>
  245. void RegisterItem(BaseItem item);
  246. /// <summary>
  247. /// Deletes the item.
  248. /// </summary>
  249. /// <param name="item">The item.</param>
  250. /// <param name="options">The options.</param>
  251. /// <returns>Task.</returns>
  252. Task DeleteItem(BaseItem item, DeleteOptions options);
  253. /// <summary>
  254. /// Gets the named view.
  255. /// </summary>
  256. /// <param name="user">The user.</param>
  257. /// <param name="name">The name.</param>
  258. /// <param name="parentId">The parent identifier.</param>
  259. /// <param name="viewType">Type of the view.</param>
  260. /// <param name="sortName">Name of the sort.</param>
  261. /// <param name="cancellationToken">The cancellation token.</param>
  262. /// <returns>Task&lt;UserView&gt;.</returns>
  263. UserView GetNamedView(User user,
  264. string name,
  265. string parentId,
  266. string viewType,
  267. string sortName,
  268. CancellationToken cancellationToken);
  269. /// <summary>
  270. /// Gets the named view.
  271. /// </summary>
  272. /// <param name="user">The user.</param>
  273. /// <param name="name">The name.</param>
  274. /// <param name="viewType">Type of the view.</param>
  275. /// <param name="sortName">Name of the sort.</param>
  276. /// <param name="cancellationToken">The cancellation token.</param>
  277. /// <returns>Task&lt;UserView&gt;.</returns>
  278. UserView GetNamedView(User user,
  279. string name,
  280. string viewType,
  281. string sortName,
  282. CancellationToken cancellationToken);
  283. /// <summary>
  284. /// Gets the named view.
  285. /// </summary>
  286. /// <param name="name">The name.</param>
  287. /// <param name="viewType">Type of the view.</param>
  288. /// <param name="sortName">Name of the sort.</param>
  289. /// <param name="cancellationToken">The cancellation token.</param>
  290. UserView GetNamedView(string name,
  291. string viewType,
  292. string sortName,
  293. CancellationToken cancellationToken);
  294. /// <summary>
  295. /// Gets the named view.
  296. /// </summary>
  297. /// <param name="name">The name.</param>
  298. /// <param name="parentId">The parent identifier.</param>
  299. /// <param name="viewType">Type of the view.</param>
  300. /// <param name="sortName">Name of the sort.</param>
  301. /// <param name="uniqueId">The unique identifier.</param>
  302. /// <param name="cancellationToken">The cancellation token.</param>
  303. UserView GetNamedView(string name,
  304. string parentId,
  305. string viewType,
  306. string sortName,
  307. string uniqueId,
  308. CancellationToken cancellationToken);
  309. /// <summary>
  310. /// Gets the shadow view.
  311. /// </summary>
  312. /// <param name="parent">The parent.</param>
  313. /// <param name="viewType">Type of the view.</param>
  314. /// <param name="sortName">Name of the sort.</param>
  315. /// <param name="cancellationToken">The cancellation token.</param>
  316. /// <returns>Task&lt;UserView&gt;.</returns>
  317. UserView GetShadowView(BaseItem parent,
  318. string viewType,
  319. string sortName,
  320. CancellationToken cancellationToken);
  321. /// <summary>
  322. /// Determines whether [is video file] [the specified path].
  323. /// </summary>
  324. /// <param name="path">The path.</param>
  325. /// <returns><c>true</c> if [is video file] [the specified path]; otherwise, <c>false</c>.</returns>
  326. bool IsVideoFile(string path);
  327. /// <summary>
  328. /// Determines whether [is audio file] [the specified path].
  329. /// </summary>
  330. /// <param name="path">The path.</param>
  331. /// <returns><c>true</c> if [is audio file] [the specified path]; otherwise, <c>false</c>.</returns>
  332. bool IsAudioFile(string path);
  333. bool IsAudioFile(string path, LibraryOptions libraryOptions);
  334. bool IsVideoFile(string path, LibraryOptions libraryOptions);
  335. /// <summary>
  336. /// Gets the season number from path.
  337. /// </summary>
  338. /// <param name="path">The path.</param>
  339. /// <returns>System.Nullable&lt;System.Int32&gt;.</returns>
  340. int? GetSeasonNumberFromPath(string path);
  341. /// <summary>
  342. /// Fills the missing episode numbers from path.
  343. /// </summary>
  344. /// <param name="episode">The episode.</param>
  345. /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
  346. bool FillMissingEpisodeNumbersFromPath(Episode episode);
  347. /// <summary>
  348. /// Parses the name.
  349. /// </summary>
  350. /// <param name="name">The name.</param>
  351. /// <returns>ItemInfo.</returns>
  352. ItemLookupInfo ParseName(string name);
  353. /// <summary>
  354. /// Gets the new item identifier.
  355. /// </summary>
  356. /// <param name="key">The key.</param>
  357. /// <param name="type">The type.</param>
  358. /// <returns>Guid.</returns>
  359. Guid GetNewItemId(string key, Type type);
  360. /// <summary>
  361. /// Finds the trailers.
  362. /// </summary>
  363. /// <param name="owner">The owner.</param>
  364. /// <param name="fileSystemChildren">The file system children.</param>
  365. /// <param name="directoryService">The directory service.</param>
  366. /// <returns>IEnumerable&lt;Trailer&gt;.</returns>
  367. IEnumerable<Video> FindTrailers(BaseItem owner, List<FileSystemMetadata> fileSystemChildren,
  368. IDirectoryService directoryService);
  369. /// <summary>
  370. /// Finds the extras.
  371. /// </summary>
  372. /// <param name="owner">The owner.</param>
  373. /// <param name="fileSystemChildren">The file system children.</param>
  374. /// <param name="directoryService">The directory service.</param>
  375. /// <returns>IEnumerable&lt;Video&gt;.</returns>
  376. IEnumerable<Video> FindExtras(BaseItem owner, List<FileSystemMetadata> fileSystemChildren,
  377. IDirectoryService directoryService);
  378. /// <summary>
  379. /// Gets the collection folders.
  380. /// </summary>
  381. /// <param name="item">The item.</param>
  382. /// <returns>IEnumerable&lt;Folder&gt;.</returns>
  383. List<Folder> GetCollectionFolders(BaseItem item);
  384. List<Folder> GetCollectionFolders(BaseItem item, List<Folder> allUserRootChildren);
  385. LibraryOptions GetLibraryOptions(BaseItem item);
  386. /// <summary>
  387. /// Gets the people.
  388. /// </summary>
  389. /// <param name="item">The item.</param>
  390. /// <returns>List&lt;PersonInfo&gt;.</returns>
  391. List<PersonInfo> GetPeople(BaseItem item);
  392. /// <summary>
  393. /// Gets the people.
  394. /// </summary>
  395. /// <param name="query">The query.</param>
  396. /// <returns>List&lt;PersonInfo&gt;.</returns>
  397. List<PersonInfo> GetPeople(InternalPeopleQuery query);
  398. /// <summary>
  399. /// Gets the people items.
  400. /// </summary>
  401. /// <param name="query">The query.</param>
  402. /// <returns>List&lt;Person&gt;.</returns>
  403. List<Person> GetPeopleItems(InternalPeopleQuery query);
  404. /// <summary>
  405. /// Updates the people.
  406. /// </summary>
  407. /// <param name="item">The item.</param>
  408. /// <param name="people">The people.</param>
  409. void UpdatePeople(BaseItem item, List<PersonInfo> people);
  410. /// <summary>
  411. /// Gets the item ids.
  412. /// </summary>
  413. /// <param name="query">The query.</param>
  414. /// <returns>List&lt;Guid&gt;.</returns>
  415. List<Guid> GetItemIds(InternalItemsQuery query);
  416. /// <summary>
  417. /// Gets the people names.
  418. /// </summary>
  419. /// <param name="query">The query.</param>
  420. /// <returns>List&lt;System.String&gt;.</returns>
  421. List<string> GetPeopleNames(InternalPeopleQuery query);
  422. /// <summary>
  423. /// Queries the items.
  424. /// </summary>
  425. /// <param name="query">The query.</param>
  426. /// <returns>QueryResult&lt;BaseItem&gt;.</returns>
  427. QueryResult<BaseItem> QueryItems(InternalItemsQuery query);
  428. string GetPathAfterNetworkSubstitution(string path, BaseItem ownerItem = null);
  429. /// <summary>
  430. /// Substitutes the path.
  431. /// </summary>
  432. /// <param name="path">The path.</param>
  433. /// <param name="from">From.</param>
  434. /// <param name="to">To.</param>
  435. /// <returns>System.String.</returns>
  436. string SubstitutePath(string path, string from, string to);
  437. /// <summary>
  438. /// Converts the image to local.
  439. /// </summary>
  440. /// <param name="item">The item.</param>
  441. /// <param name="image">The image.</param>
  442. /// <param name="imageIndex">Index of the image.</param>
  443. /// <returns>Task.</returns>
  444. Task<ItemImageInfo> ConvertImageToLocal(IHasMetadata item, ItemImageInfo image, int imageIndex);
  445. /// <summary>
  446. /// Gets the items.
  447. /// </summary>
  448. /// <param name="query">The query.</param>
  449. /// <returns>QueryResult&lt;BaseItem&gt;.</returns>
  450. List<BaseItem> GetItemList(InternalItemsQuery query);
  451. List<BaseItem> GetItemList(InternalItemsQuery query, bool allowExternalContent);
  452. /// <summary>
  453. /// Gets the items.
  454. /// </summary>
  455. List<BaseItem> GetItemList(InternalItemsQuery query, List<BaseItem> parents);
  456. /// <summary>
  457. /// Gets the items result.
  458. /// </summary>
  459. /// <param name="query">The query.</param>
  460. /// <returns>QueryResult&lt;BaseItem&gt;.</returns>
  461. QueryResult<BaseItem> GetItemsResult(InternalItemsQuery query);
  462. /// <summary>
  463. /// Ignores the file.
  464. /// </summary>
  465. /// <param name="file">The file.</param>
  466. /// <param name="parent">The parent.</param>
  467. /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
  468. bool IgnoreFile(FileSystemMetadata file, BaseItem parent);
  469. Guid GetStudioId(string name);
  470. Guid GetGenreId(string name);
  471. Guid GetMusicGenreId(string name);
  472. Guid GetGameGenreId(string name);
  473. void AddVirtualFolder(string name, string collectionType, LibraryOptions options, bool refreshLibrary);
  474. void RemoveVirtualFolder(string name, bool refreshLibrary);
  475. void AddMediaPath(string virtualFolderName, MediaPathInfo path);
  476. void UpdateMediaPath(string virtualFolderName, MediaPathInfo path);
  477. void RemoveMediaPath(string virtualFolderName, string path);
  478. QueryResult<Tuple<BaseItem, ItemCounts>> GetGenres(InternalItemsQuery query);
  479. QueryResult<Tuple<BaseItem, ItemCounts>> GetMusicGenres(InternalItemsQuery query);
  480. QueryResult<Tuple<BaseItem, ItemCounts>> GetGameGenres(InternalItemsQuery query);
  481. QueryResult<Tuple<BaseItem, ItemCounts>> GetStudios(InternalItemsQuery query);
  482. QueryResult<Tuple<BaseItem, ItemCounts>> GetArtists(InternalItemsQuery query);
  483. QueryResult<Tuple<BaseItem, ItemCounts>> GetAlbumArtists(InternalItemsQuery query);
  484. QueryResult<Tuple<BaseItem, ItemCounts>> GetAllArtists(InternalItemsQuery query);
  485. int GetCount(InternalItemsQuery query);
  486. }
  487. }