2
0

ILibraryManager.cs 20 KB

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