2
0

ILibraryManager.cs 21 KB

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