2013-05-02 21:10:11 -07:00
|
|
|
|
using MediaBrowser.Controller.Entities;
|
2013-04-20 18:02:16 -07:00
|
|
|
|
using MediaBrowser.Controller.Entities.Audio;
|
2014-02-12 22:11:54 -07:00
|
|
|
|
using MediaBrowser.Controller.Providers;
|
2013-03-03 09:53:58 -07:00
|
|
|
|
using MediaBrowser.Controller.Resolvers;
|
2013-03-09 21:22:36 -07:00
|
|
|
|
using MediaBrowser.Controller.Sorting;
|
2013-02-28 12:32:41 -07:00
|
|
|
|
using MediaBrowser.Model.Entities;
|
2013-03-01 19:44:46 -07:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2013-05-02 21:10:11 -07:00
|
|
|
|
using System.IO;
|
2013-03-01 19:44:46 -07:00
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
2013-02-28 12:32:41 -07:00
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Controller.Library
|
|
|
|
|
{
|
2013-05-20 20:16:43 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Interface ILibraryManager
|
|
|
|
|
/// </summary>
|
2013-02-28 12:32:41 -07:00
|
|
|
|
public interface ILibraryManager
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Resolves the item.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="args">The args.</param>
|
|
|
|
|
/// <returns>BaseItem.</returns>
|
|
|
|
|
BaseItem ResolveItem(ItemResolveArgs args);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Resolves a path into a BaseItem
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="fileInfo">The file info.</param>
|
2014-02-12 22:11:54 -07:00
|
|
|
|
/// <param name="directoryService">The directory service.</param>
|
2013-06-11 13:35:54 -07:00
|
|
|
|
/// <param name="parent">The parent.</param>
|
2013-02-28 12:32:41 -07:00
|
|
|
|
/// <returns>BaseItem.</returns>
|
|
|
|
|
/// <exception cref="System.ArgumentNullException"></exception>
|
2014-02-12 22:11:54 -07:00
|
|
|
|
BaseItem ResolvePath(FileSystemInfo fileInfo, IDirectoryService directoryService, Folder parent = null);
|
2013-02-28 12:32:41 -07:00
|
|
|
|
|
2014-02-12 22:11:54 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Resolves the path.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="fileInfo">The file information.</param>
|
|
|
|
|
/// <param name="parent">The parent.</param>
|
|
|
|
|
/// <returns>BaseItem.</returns>
|
|
|
|
|
BaseItem ResolvePath(FileSystemInfo fileInfo, Folder parent = null);
|
2014-02-19 21:53:15 -07:00
|
|
|
|
|
2013-02-28 12:32:41 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Resolves a set of files into a list of BaseItem
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <typeparam name="T"></typeparam>
|
|
|
|
|
/// <param name="files">The files.</param>
|
2014-02-12 22:11:54 -07:00
|
|
|
|
/// <param name="directoryService">The directory service.</param>
|
2013-02-28 12:32:41 -07:00
|
|
|
|
/// <param name="parent">The parent.</param>
|
|
|
|
|
/// <returns>List{``0}.</returns>
|
2014-02-12 22:11:54 -07:00
|
|
|
|
List<T> ResolvePaths<T>(IEnumerable<FileSystemInfo> files, IDirectoryService directoryService, Folder parent)
|
2013-02-28 12:32:41 -07:00
|
|
|
|
where T : BaseItem;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the root folder.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The root folder.</value>
|
|
|
|
|
AggregateFolder RootFolder { get; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets a Person
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="name">The name.</param>
|
|
|
|
|
/// <returns>Task{Person}.</returns>
|
2013-09-16 19:08:18 -07:00
|
|
|
|
Person GetPerson(string name);
|
2013-02-28 12:32:41 -07:00
|
|
|
|
|
2013-04-20 18:02:16 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the artist.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="name">The name.</param>
|
|
|
|
|
/// <returns>Task{Artist}.</returns>
|
2013-11-21 13:48:26 -07:00
|
|
|
|
MusicArtist GetArtist(string name);
|
2013-04-20 18:02:16 -07:00
|
|
|
|
|
2013-02-28 12:32:41 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets a Studio
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="name">The name.</param>
|
|
|
|
|
/// <returns>Task{Studio}.</returns>
|
2013-09-16 19:08:18 -07:00
|
|
|
|
Studio GetStudio(string name);
|
2013-02-28 12:32:41 -07:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets a Genre
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="name">The name.</param>
|
|
|
|
|
/// <returns>Task{Genre}.</returns>
|
2013-09-16 19:08:18 -07:00
|
|
|
|
Genre GetGenre(string name);
|
2013-02-28 12:32:41 -07:00
|
|
|
|
|
2013-06-10 20:31:00 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the genre.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="name">The name.</param>
|
|
|
|
|
/// <returns>Task{MusicGenre}.</returns>
|
2013-09-16 19:08:18 -07:00
|
|
|
|
MusicGenre GetMusicGenre(string name);
|
2013-07-01 10:17:33 -07:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the game genre.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="name">The name.</param>
|
|
|
|
|
/// <returns>Task{GameGenre}.</returns>
|
2013-09-16 19:08:18 -07:00
|
|
|
|
GameGenre GetGameGenre(string name);
|
|
|
|
|
|
2013-02-28 12:32:41 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets a Year
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="value">The value.</param>
|
|
|
|
|
/// <returns>Task{Year}.</returns>
|
|
|
|
|
/// <exception cref="System.ArgumentOutOfRangeException"></exception>
|
2013-09-16 19:08:18 -07:00
|
|
|
|
Year GetYear(int value);
|
2013-02-28 12:32:41 -07:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Validate and refresh the People sub-set of the IBN.
|
|
|
|
|
/// The items are stored in the db but not loaded into memory until actually requested by an operation.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="cancellationToken">The cancellation token.</param>
|
|
|
|
|
/// <param name="progress">The progress.</param>
|
|
|
|
|
/// <returns>Task.</returns>
|
|
|
|
|
Task ValidatePeople(CancellationToken cancellationToken, IProgress<double> progress);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Reloads the root media folder
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="progress">The progress.</param>
|
|
|
|
|
/// <param name="cancellationToken">The cancellation token.</param>
|
|
|
|
|
/// <returns>Task.</returns>
|
|
|
|
|
Task ValidateMediaLibrary(IProgress<double> progress, CancellationToken cancellationToken);
|
|
|
|
|
|
2013-12-15 09:53:32 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Queues the library scan.
|
|
|
|
|
/// </summary>
|
|
|
|
|
void QueueLibraryScan();
|
|
|
|
|
|
2013-02-28 12:32:41 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the default view.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>IEnumerable{VirtualFolderInfo}.</returns>
|
|
|
|
|
IEnumerable<VirtualFolderInfo> GetDefaultVirtualFolders();
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the view.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="user">The user.</param>
|
|
|
|
|
/// <returns>IEnumerable{VirtualFolderInfo}.</returns>
|
|
|
|
|
IEnumerable<VirtualFolderInfo> GetVirtualFolders(User user);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the item by id.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="id">The id.</param>
|
|
|
|
|
/// <returns>BaseItem.</returns>
|
|
|
|
|
BaseItem GetItemById(Guid id);
|
|
|
|
|
|
2013-03-01 19:44:46 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the intros.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="item">The item.</param>
|
|
|
|
|
/// <param name="user">The user.</param>
|
|
|
|
|
/// <returns>IEnumerable{System.String}.</returns>
|
2013-10-04 10:04:18 -07:00
|
|
|
|
IEnumerable<Video> GetIntros(BaseItem item, User user);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets all intro files.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>IEnumerable{System.String}.</returns>
|
|
|
|
|
IEnumerable<string> GetAllIntroFiles();
|
2013-03-01 19:44:46 -07:00
|
|
|
|
|
2013-03-01 14:22:34 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Adds the parts.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="rules">The rules.</param>
|
|
|
|
|
/// <param name="pluginFolders">The plugin folders.</param>
|
|
|
|
|
/// <param name="resolvers">The resolvers.</param>
|
2013-03-01 19:44:46 -07:00
|
|
|
|
/// <param name="introProviders">The intro providers.</param>
|
2013-03-09 21:22:36 -07:00
|
|
|
|
/// <param name="itemComparers">The item comparers.</param>
|
2013-05-27 09:53:10 -07:00
|
|
|
|
/// <param name="postscanTasks">The postscan tasks.</param>
|
2013-09-16 19:08:18 -07:00
|
|
|
|
void AddParts(IEnumerable<IResolverIgnoreRule> rules,
|
|
|
|
|
IEnumerable<IVirtualFolderCreator> pluginFolders,
|
|
|
|
|
IEnumerable<IItemResolver> resolvers,
|
|
|
|
|
IEnumerable<IIntroProvider> introProviders,
|
2013-05-20 20:16:43 -07:00
|
|
|
|
IEnumerable<IBaseItemComparer> itemComparers,
|
2014-02-09 16:08:01 -07:00
|
|
|
|
IEnumerable<ILibraryPostScanTask> postscanTasks);
|
2013-03-09 21:22:36 -07:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Sorts the specified items.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="items">The items.</param>
|
|
|
|
|
/// <param name="user">The user.</param>
|
|
|
|
|
/// <param name="sortBy">The sort by.</param>
|
|
|
|
|
/// <param name="sortOrder">The sort order.</param>
|
|
|
|
|
/// <returns>IEnumerable{BaseItem}.</returns>
|
|
|
|
|
IEnumerable<BaseItem> Sort(IEnumerable<BaseItem> items, User user, IEnumerable<string> sortBy,
|
|
|
|
|
SortOrder sortOrder);
|
2013-03-11 21:26:23 -07:00
|
|
|
|
|
2013-03-15 12:08:49 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Ensure supplied item has only one instance throughout
|
|
|
|
|
/// </summary>
|
2013-05-20 20:16:43 -07:00
|
|
|
|
/// <param name="item">The item.</param>
|
2013-03-15 12:08:49 -07:00
|
|
|
|
/// <returns>The proper instance to the item</returns>
|
|
|
|
|
BaseItem GetOrAddByReferenceItem(BaseItem item);
|
2013-04-04 21:12:35 -07:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the user root folder.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>UserRootFolder.</returns>
|
2014-02-20 22:04:11 -07:00
|
|
|
|
Folder GetUserRootFolder();
|
2013-04-08 08:55:53 -07:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
2013-05-02 21:10:11 -07:00
|
|
|
|
/// Creates the item.
|
2013-04-08 08:55:53 -07:00
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="item">The item.</param>
|
|
|
|
|
/// <param name="cancellationToken">The cancellation token.</param>
|
|
|
|
|
/// <returns>Task.</returns>
|
2013-05-02 21:10:11 -07:00
|
|
|
|
Task CreateItem(BaseItem item, CancellationToken cancellationToken);
|
2013-04-08 08:55:53 -07:00
|
|
|
|
|
2013-05-23 08:39:48 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Creates the items.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="items">The items.</param>
|
|
|
|
|
/// <param name="cancellationToken">The cancellation token.</param>
|
|
|
|
|
/// <returns>Task.</returns>
|
|
|
|
|
Task CreateItems(IEnumerable<BaseItem> items, CancellationToken cancellationToken);
|
|
|
|
|
|
2013-05-02 21:10:11 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Updates the item.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="item">The item.</param>
|
2013-06-24 18:22:21 -07:00
|
|
|
|
/// <param name="updateReason">The update reason.</param>
|
2013-05-02 21:10:11 -07:00
|
|
|
|
/// <param name="cancellationToken">The cancellation token.</param>
|
|
|
|
|
/// <returns>Task.</returns>
|
2013-06-24 18:22:21 -07:00
|
|
|
|
Task UpdateItem(BaseItem item, ItemUpdateType updateReason, CancellationToken cancellationToken);
|
2013-05-20 20:16:43 -07:00
|
|
|
|
|
2013-04-08 08:55:53 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Retrieves the item.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="id">The id.</param>
|
2013-06-17 13:35:43 -07:00
|
|
|
|
/// <returns>BaseItem.</returns>
|
2013-06-26 09:08:16 -07:00
|
|
|
|
BaseItem RetrieveItem(Guid id);
|
2013-04-21 21:38:03 -07:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Validates the artists.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="cancellationToken">The cancellation token.</param>
|
|
|
|
|
/// <param name="progress">The progress.</param>
|
|
|
|
|
/// <returns>Task.</returns>
|
|
|
|
|
Task ValidateArtists(CancellationToken cancellationToken, IProgress<double> progress);
|
2013-05-02 21:10:11 -07:00
|
|
|
|
|
2013-09-10 11:56:00 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Validates the music genres.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="cancellationToken">The cancellation token.</param>
|
|
|
|
|
/// <param name="progress">The progress.</param>
|
|
|
|
|
/// <returns>Task.</returns>
|
|
|
|
|
Task ValidateMusicGenres(CancellationToken cancellationToken, IProgress<double> progress);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Validates the game genres.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="cancellationToken">The cancellation token.</param>
|
|
|
|
|
/// <param name="progress">The progress.</param>
|
|
|
|
|
/// <returns>Task.</returns>
|
|
|
|
|
Task ValidateGameGenres(CancellationToken cancellationToken, IProgress<double> progress);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Validates the genres.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="cancellationToken">The cancellation token.</param>
|
|
|
|
|
/// <param name="progress">The progress.</param>
|
|
|
|
|
/// <returns>Task.</returns>
|
|
|
|
|
Task ValidateGenres(CancellationToken cancellationToken, IProgress<double> progress);
|
2013-09-16 19:08:18 -07:00
|
|
|
|
|
2013-09-10 11:56:00 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Validates the studios.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="cancellationToken">The cancellation token.</param>
|
|
|
|
|
/// <param name="progress">The progress.</param>
|
|
|
|
|
/// <returns>Task.</returns>
|
|
|
|
|
Task ValidateStudios(CancellationToken cancellationToken, IProgress<double> progress);
|
2013-09-16 19:08:18 -07:00
|
|
|
|
|
2013-05-02 21:10:11 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Occurs when [item added].
|
|
|
|
|
/// </summary>
|
|
|
|
|
event EventHandler<ItemChangeEventArgs> ItemAdded;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Occurs when [item updated].
|
|
|
|
|
/// </summary>
|
|
|
|
|
event EventHandler<ItemChangeEventArgs> ItemUpdated;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Occurs when [item removed].
|
|
|
|
|
/// </summary>
|
|
|
|
|
event EventHandler<ItemChangeEventArgs> ItemRemoved;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Reports the item removed.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="item">The item.</param>
|
|
|
|
|
void ReportItemRemoved(BaseItem item);
|
2013-07-12 12:56:40 -07:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Finds the type of the collection.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="item">The item.</param>
|
|
|
|
|
/// <returns>System.String.</returns>
|
|
|
|
|
string FindCollectionType(BaseItem item);
|
2013-11-13 09:45:41 -07:00
|
|
|
|
|
2013-11-21 13:48:26 -07:00
|
|
|
|
/// <summary>
|
2014-01-01 11:26:31 -07:00
|
|
|
|
/// Normalizes the root path list.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="paths">The paths.</param>
|
|
|
|
|
/// <returns>IEnumerable{System.String}.</returns>
|
|
|
|
|
IEnumerable<string> NormalizeRootPathList(IEnumerable<string> paths);
|
2014-01-10 22:49:18 -07:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Registers the item.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="item">The item.</param>
|
|
|
|
|
void RegisterItem(BaseItem item);
|
2014-02-19 11:50:37 -07:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Deletes the item.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="item">The item.</param>
|
2014-02-19 21:53:15 -07:00
|
|
|
|
/// <param name="options">The options.</param>
|
2014-02-19 11:50:37 -07:00
|
|
|
|
/// <returns>Task.</returns>
|
2014-02-19 21:53:15 -07:00
|
|
|
|
Task DeleteItem(BaseItem item, DeleteOptions options);
|
2014-03-18 21:59:45 -07:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Replaces the videos with primary versions.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="items">The items.</param>
|
|
|
|
|
/// <returns>IEnumerable{BaseItem}.</returns>
|
|
|
|
|
IEnumerable<BaseItem> ReplaceVideosWithPrimaryVersions(IEnumerable<BaseItem> items);
|
2014-02-19 21:53:15 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static class LibraryManagerExtensions
|
|
|
|
|
{
|
|
|
|
|
public static Task DeleteItem(this ILibraryManager manager, BaseItem item)
|
|
|
|
|
{
|
|
|
|
|
return manager.DeleteItem(item, new DeleteOptions
|
|
|
|
|
{
|
|
|
|
|
DeleteFileLocation = true
|
|
|
|
|
});
|
|
|
|
|
}
|
2013-02-28 12:32:41 -07:00
|
|
|
|
}
|
|
|
|
|
}
|