reduce task allocations by making IBN api synchronous
This commit is contained in:
parent
aaecc99d63
commit
1007f24200
|
@ -95,32 +95,32 @@ namespace MediaBrowser.Api
|
||||||
private readonly char[] _dashReplaceChars = new[] { '?', '/' };
|
private readonly char[] _dashReplaceChars = new[] { '?', '/' };
|
||||||
private const char SlugChar = '-';
|
private const char SlugChar = '-';
|
||||||
|
|
||||||
protected Task<Artist> GetArtist(string name, ILibraryManager libraryManager)
|
protected Artist GetArtist(string name, ILibraryManager libraryManager)
|
||||||
{
|
{
|
||||||
return libraryManager.GetArtist(DeSlugArtistName(name, libraryManager));
|
return libraryManager.GetArtist(DeSlugArtistName(name, libraryManager));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Task<Studio> GetStudio(string name, ILibraryManager libraryManager)
|
protected Studio GetStudio(string name, ILibraryManager libraryManager)
|
||||||
{
|
{
|
||||||
return libraryManager.GetStudio(DeSlugStudioName(name, libraryManager));
|
return libraryManager.GetStudio(DeSlugStudioName(name, libraryManager));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Task<Genre> GetGenre(string name, ILibraryManager libraryManager)
|
protected Genre GetGenre(string name, ILibraryManager libraryManager)
|
||||||
{
|
{
|
||||||
return libraryManager.GetGenre(DeSlugGenreName(name, libraryManager));
|
return libraryManager.GetGenre(DeSlugGenreName(name, libraryManager));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Task<MusicGenre> GetMusicGenre(string name, ILibraryManager libraryManager)
|
protected MusicGenre GetMusicGenre(string name, ILibraryManager libraryManager)
|
||||||
{
|
{
|
||||||
return libraryManager.GetMusicGenre(DeSlugGenreName(name, libraryManager));
|
return libraryManager.GetMusicGenre(DeSlugGenreName(name, libraryManager));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Task<GameGenre> GetGameGenre(string name, ILibraryManager libraryManager)
|
protected GameGenre GetGameGenre(string name, ILibraryManager libraryManager)
|
||||||
{
|
{
|
||||||
return libraryManager.GetGameGenre(DeSlugGameGenreName(name, libraryManager));
|
return libraryManager.GetGameGenre(DeSlugGameGenreName(name, libraryManager));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Task<Person> GetPerson(string name, ILibraryManager libraryManager)
|
protected Person GetPerson(string name, ILibraryManager libraryManager)
|
||||||
{
|
{
|
||||||
return libraryManager.GetPerson(DeSlugPersonName(name, libraryManager));
|
return libraryManager.GetPerson(DeSlugPersonName(name, libraryManager));
|
||||||
}
|
}
|
||||||
|
@ -257,37 +257,37 @@ namespace MediaBrowser.Api
|
||||||
/// <param name="libraryManager">The library manager.</param>
|
/// <param name="libraryManager">The library manager.</param>
|
||||||
/// <returns>Task{BaseItem}.</returns>
|
/// <returns>Task{BaseItem}.</returns>
|
||||||
/// <exception cref="System.ArgumentException"></exception>
|
/// <exception cref="System.ArgumentException"></exception>
|
||||||
protected async Task<BaseItem> GetItemByName(string name, string type, ILibraryManager libraryManager)
|
protected BaseItem GetItemByName(string name, string type, ILibraryManager libraryManager)
|
||||||
{
|
{
|
||||||
BaseItem item;
|
BaseItem item;
|
||||||
|
|
||||||
if (type.IndexOf("Person", StringComparison.OrdinalIgnoreCase) == 0)
|
if (type.IndexOf("Person", StringComparison.OrdinalIgnoreCase) == 0)
|
||||||
{
|
{
|
||||||
item = await GetPerson(name, libraryManager).ConfigureAwait(false);
|
item = GetPerson(name, libraryManager);
|
||||||
}
|
}
|
||||||
else if (type.IndexOf("Artist", StringComparison.OrdinalIgnoreCase) == 0)
|
else if (type.IndexOf("Artist", StringComparison.OrdinalIgnoreCase) == 0)
|
||||||
{
|
{
|
||||||
item = await GetArtist(name, libraryManager).ConfigureAwait(false);
|
item = GetArtist(name, libraryManager);
|
||||||
}
|
}
|
||||||
else if (type.IndexOf("Genre", StringComparison.OrdinalIgnoreCase) == 0)
|
else if (type.IndexOf("Genre", StringComparison.OrdinalIgnoreCase) == 0)
|
||||||
{
|
{
|
||||||
item = await GetGenre(name, libraryManager).ConfigureAwait(false);
|
item = GetGenre(name, libraryManager);
|
||||||
}
|
}
|
||||||
else if (type.IndexOf("MusicGenre", StringComparison.OrdinalIgnoreCase) == 0)
|
else if (type.IndexOf("MusicGenre", StringComparison.OrdinalIgnoreCase) == 0)
|
||||||
{
|
{
|
||||||
item = await GetMusicGenre(name, libraryManager).ConfigureAwait(false);
|
item = GetMusicGenre(name, libraryManager);
|
||||||
}
|
}
|
||||||
else if (type.IndexOf("GameGenre", StringComparison.OrdinalIgnoreCase) == 0)
|
else if (type.IndexOf("GameGenre", StringComparison.OrdinalIgnoreCase) == 0)
|
||||||
{
|
{
|
||||||
item = await GetGameGenre(name, libraryManager).ConfigureAwait(false);
|
item = GetGameGenre(name, libraryManager);
|
||||||
}
|
}
|
||||||
else if (type.IndexOf("Studio", StringComparison.OrdinalIgnoreCase) == 0)
|
else if (type.IndexOf("Studio", StringComparison.OrdinalIgnoreCase) == 0)
|
||||||
{
|
{
|
||||||
item = await GetStudio(name, libraryManager).ConfigureAwait(false);
|
item = GetStudio(name, libraryManager);
|
||||||
}
|
}
|
||||||
else if (type.IndexOf("Year", StringComparison.OrdinalIgnoreCase) == 0)
|
else if (type.IndexOf("Year", StringComparison.OrdinalIgnoreCase) == 0)
|
||||||
{
|
{
|
||||||
item = await libraryManager.GetYear(int.Parse(name)).ConfigureAwait(false);
|
item = libraryManager.GetYear(int.Parse(name));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -205,7 +205,7 @@ namespace MediaBrowser.Api.DefaultTheme
|
||||||
.Take(3)
|
.Take(3)
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
view.ActorItems = await GetActors(series).ConfigureAwait(false);
|
view.ActorItems = GetActors(series);
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
@ -218,8 +218,6 @@ namespace MediaBrowser.Api.DefaultTheme
|
||||||
.Where(i => i is Movie || i is Trailer || i is BoxSet)
|
.Where(i => i is Movie || i is Trailer || i is BoxSet)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
var actorsTask = GetActors(items);
|
|
||||||
|
|
||||||
// Exclude trailers from backdrops because they're not always 1080p
|
// Exclude trailers from backdrops because they're not always 1080p
|
||||||
var itemsWithBackdrops = items.Where(i => i.BackdropImagePaths.Count > 0 && !(i is Trailer))
|
var itemsWithBackdrops = items.Where(i => i.BackdropImagePaths.Count > 0 && !(i is Trailer))
|
||||||
.ToList();
|
.ToList();
|
||||||
|
@ -322,7 +320,7 @@ namespace MediaBrowser.Api.DefaultTheme
|
||||||
.Take(3)
|
.Take(3)
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
view.PeopleItems = await actorsTask.ConfigureAwait(false);
|
view.PeopleItems = GetActors(items);
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
@ -362,44 +360,35 @@ namespace MediaBrowser.Api.DefaultTheme
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<ItemStub[]> GetActors(IEnumerable<BaseItem> mediaItems)
|
private ItemStub[] GetActors(IEnumerable<BaseItem> mediaItems)
|
||||||
{
|
{
|
||||||
var actorStubs = new List<ItemStub>();
|
|
||||||
|
|
||||||
var actors = mediaItems.SelectMany(i => i.People)
|
var actors = mediaItems.SelectMany(i => i.People)
|
||||||
.Select(i => i.Name)
|
.Select(i => i.Name)
|
||||||
.Distinct(StringComparer.OrdinalIgnoreCase)
|
.Distinct(StringComparer.OrdinalIgnoreCase)
|
||||||
.OrderBy(i => Guid.NewGuid())
|
.OrderBy(i => Guid.NewGuid())
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
foreach (var actor in actors)
|
return actors.Select(actor =>
|
||||||
{
|
{
|
||||||
if (actorStubs.Count >= 3)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var person = await _libraryManager.GetPerson(actor).ConfigureAwait(false);
|
var person = _libraryManager.GetPerson(actor);
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(person.PrimaryImagePath))
|
if (!string.IsNullOrEmpty(person.PrimaryImagePath))
|
||||||
{
|
{
|
||||||
var stub = GetItemStub(person, ImageType.Primary);
|
return GetItemStub(person, ImageType.Primary);
|
||||||
|
|
||||||
if (stub != null)
|
|
||||||
{
|
|
||||||
actorStubs.Add(stub);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.ErrorException("Error getting person {0}", ex, actor);
|
_logger.ErrorException("Error getting person {0}", ex, actor);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return actorStubs.ToArray();
|
return null;
|
||||||
|
})
|
||||||
|
.Where(i => i != null)
|
||||||
|
.Take(3)
|
||||||
|
.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
private ItemStub GetItemStub(BaseItem item, ImageType imageType)
|
private ItemStub GetItemStub(BaseItem item, ImageType imageType)
|
||||||
|
|
|
@ -378,14 +378,14 @@ namespace MediaBrowser.Api.Images
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="request">The request.</param>
|
/// <param name="request">The request.</param>
|
||||||
/// <returns>Task{List{ImageInfo}}.</returns>
|
/// <returns>Task{List{ImageInfo}}.</returns>
|
||||||
public async Task<List<ImageInfo>> GetItemByNameImageInfos(GetItemByNameImageInfos request)
|
public Task<List<ImageInfo>> GetItemByNameImageInfos(GetItemByNameImageInfos request)
|
||||||
{
|
{
|
||||||
var pathInfo = PathInfo.Parse(RequestContext.PathInfo);
|
var pathInfo = PathInfo.Parse(RequestContext.PathInfo);
|
||||||
var type = pathInfo.GetArgumentValue<string>(0);
|
var type = pathInfo.GetArgumentValue<string>(0);
|
||||||
|
|
||||||
var item = await GetItemByName(request.Name, type, _libraryManager).ConfigureAwait(false);
|
var item = GetItemByName(request.Name, type, _libraryManager);
|
||||||
|
|
||||||
return await GetItemImageInfos(item).ConfigureAwait(false);
|
return GetItemImageInfos(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -532,7 +532,7 @@ namespace MediaBrowser.Api.Images
|
||||||
var pathInfo = PathInfo.Parse(RequestContext.PathInfo);
|
var pathInfo = PathInfo.Parse(RequestContext.PathInfo);
|
||||||
var type = pathInfo.GetArgumentValue<string>(0);
|
var type = pathInfo.GetArgumentValue<string>(0);
|
||||||
|
|
||||||
var item = GetItemByName(request.Name, type, _libraryManager).Result;
|
var item = GetItemByName(request.Name, type, _libraryManager);
|
||||||
|
|
||||||
return GetImage(request, item);
|
return GetImage(request, item);
|
||||||
}
|
}
|
||||||
|
@ -563,7 +563,7 @@ namespace MediaBrowser.Api.Images
|
||||||
|
|
||||||
request.Type = (ImageType)Enum.Parse(typeof(ImageType), pathInfo.GetArgumentValue<string>(3), true);
|
request.Type = (ImageType)Enum.Parse(typeof(ImageType), pathInfo.GetArgumentValue<string>(3), true);
|
||||||
|
|
||||||
var item = GetItemByName(name, type, _libraryManager).Result;
|
var item = GetItemByName(name, type, _libraryManager);
|
||||||
|
|
||||||
var task = PostImage(item, request.RequestStream, request.Type, RequestContext.ContentType);
|
var task = PostImage(item, request.RequestStream, request.Type, RequestContext.ContentType);
|
||||||
|
|
||||||
|
@ -623,7 +623,7 @@ namespace MediaBrowser.Api.Images
|
||||||
var pathInfo = PathInfo.Parse(RequestContext.PathInfo);
|
var pathInfo = PathInfo.Parse(RequestContext.PathInfo);
|
||||||
var type = pathInfo.GetArgumentValue<string>(0);
|
var type = pathInfo.GetArgumentValue<string>(0);
|
||||||
|
|
||||||
var item = GetItemByName(request.Name, type, _libraryManager).Result;
|
var item = GetItemByName(request.Name, type, _libraryManager);
|
||||||
|
|
||||||
var task = item.DeleteImage(request.Type, request.Index);
|
var task = item.DeleteImage(request.Type, request.Index);
|
||||||
|
|
||||||
|
@ -652,7 +652,7 @@ namespace MediaBrowser.Api.Images
|
||||||
var pathInfo = PathInfo.Parse(RequestContext.PathInfo);
|
var pathInfo = PathInfo.Parse(RequestContext.PathInfo);
|
||||||
var type = pathInfo.GetArgumentValue<string>(0);
|
var type = pathInfo.GetArgumentValue<string>(0);
|
||||||
|
|
||||||
var item = GetItemByName(request.Name, type, _libraryManager).Result;
|
var item = GetItemByName(request.Name, type, _libraryManager);
|
||||||
|
|
||||||
var task = UpdateItemIndex(item, request.Type, request.Index, request.NewIndex);
|
var task = UpdateItemIndex(item, request.Type, request.Index, request.NewIndex);
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ namespace MediaBrowser.Api
|
||||||
|
|
||||||
public object Get(GetInstantMixFromMusicGenre request)
|
public object Get(GetInstantMixFromMusicGenre request)
|
||||||
{
|
{
|
||||||
var genre = GetMusicGenre(request.Name, _libraryManager).Result;
|
var genre = GetMusicGenre(request.Name, _libraryManager);
|
||||||
|
|
||||||
var result = GetInstantMixResult(request, new[] { genre.Name }).Result;
|
var result = GetInstantMixResult(request, new[] { genre.Name }).Result;
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ namespace MediaBrowser.Api
|
||||||
|
|
||||||
public object Get(GetInstantMixFromArtist request)
|
public object Get(GetInstantMixFromArtist request)
|
||||||
{
|
{
|
||||||
var artist = GetArtist(request.Name, _libraryManager).Result;
|
var artist = GetArtist(request.Name, _libraryManager);
|
||||||
|
|
||||||
var genres = _libraryManager.RootFolder
|
var genres = _libraryManager.RootFolder
|
||||||
.RecursiveChildren
|
.RecursiveChildren
|
||||||
|
|
|
@ -110,7 +110,7 @@ namespace MediaBrowser.Api
|
||||||
|
|
||||||
private async Task RefreshArtist(RefreshArtist request)
|
private async Task RefreshArtist(RefreshArtist request)
|
||||||
{
|
{
|
||||||
var item = await GetArtist(request.Name, _libraryManager).ConfigureAwait(false);
|
var item = GetArtist(request.Name, _libraryManager);
|
||||||
|
|
||||||
var cancellationToken = CancellationToken.None;
|
var cancellationToken = CancellationToken.None;
|
||||||
|
|
||||||
|
@ -148,7 +148,7 @@ namespace MediaBrowser.Api
|
||||||
|
|
||||||
private async Task RefreshGenre(RefreshGenre request)
|
private async Task RefreshGenre(RefreshGenre request)
|
||||||
{
|
{
|
||||||
var item = await GetGenre(request.Name, _libraryManager).ConfigureAwait(false);
|
var item = GetGenre(request.Name, _libraryManager);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -169,7 +169,7 @@ namespace MediaBrowser.Api
|
||||||
|
|
||||||
private async Task RefreshMusicGenre(RefreshMusicGenre request)
|
private async Task RefreshMusicGenre(RefreshMusicGenre request)
|
||||||
{
|
{
|
||||||
var item = await GetMusicGenre(request.Name, _libraryManager).ConfigureAwait(false);
|
var item = GetMusicGenre(request.Name, _libraryManager);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -190,7 +190,7 @@ namespace MediaBrowser.Api
|
||||||
|
|
||||||
private async Task RefreshGameGenre(RefreshGameGenre request)
|
private async Task RefreshGameGenre(RefreshGameGenre request)
|
||||||
{
|
{
|
||||||
var item = await GetGameGenre(request.Name, _libraryManager).ConfigureAwait(false);
|
var item = GetGameGenre(request.Name, _libraryManager);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -211,7 +211,7 @@ namespace MediaBrowser.Api
|
||||||
|
|
||||||
private async Task RefreshPerson(RefreshPerson request)
|
private async Task RefreshPerson(RefreshPerson request)
|
||||||
{
|
{
|
||||||
var item = await GetPerson(request.Name, _libraryManager).ConfigureAwait(false);
|
var item = GetPerson(request.Name, _libraryManager);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -232,7 +232,7 @@ namespace MediaBrowser.Api
|
||||||
|
|
||||||
private async Task RefreshStudio(RefreshStudio request)
|
private async Task RefreshStudio(RefreshStudio request)
|
||||||
{
|
{
|
||||||
var item = await GetStudio(request.Name, _libraryManager).ConfigureAwait(false);
|
var item = GetStudio(request.Name, _libraryManager);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
|
@ -105,7 +105,7 @@ namespace MediaBrowser.Api
|
||||||
|
|
||||||
private async Task UpdateItem(UpdatePerson request)
|
private async Task UpdateItem(UpdatePerson request)
|
||||||
{
|
{
|
||||||
var item = await GetPerson(request.PersonName, _libraryManager).ConfigureAwait(false);
|
var item = GetPerson(request.PersonName, _libraryManager);
|
||||||
|
|
||||||
UpdateItem(request, item);
|
UpdateItem(request, item);
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ namespace MediaBrowser.Api
|
||||||
|
|
||||||
private async Task UpdateItem(UpdateArtist request)
|
private async Task UpdateItem(UpdateArtist request)
|
||||||
{
|
{
|
||||||
var item = await GetArtist(request.ArtistName, _libraryManager).ConfigureAwait(false);
|
var item = GetArtist(request.ArtistName, _libraryManager);
|
||||||
|
|
||||||
UpdateItem(request, item);
|
UpdateItem(request, item);
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ namespace MediaBrowser.Api
|
||||||
|
|
||||||
private async Task UpdateItem(UpdateStudio request)
|
private async Task UpdateItem(UpdateStudio request)
|
||||||
{
|
{
|
||||||
var item = await GetStudio(request.StudioName, _libraryManager).ConfigureAwait(false);
|
var item = GetStudio(request.StudioName, _libraryManager);
|
||||||
|
|
||||||
UpdateItem(request, item);
|
UpdateItem(request, item);
|
||||||
|
|
||||||
|
@ -153,7 +153,7 @@ namespace MediaBrowser.Api
|
||||||
|
|
||||||
private async Task UpdateItem(UpdateMusicGenre request)
|
private async Task UpdateItem(UpdateMusicGenre request)
|
||||||
{
|
{
|
||||||
var item = await GetMusicGenre(request.GenreName, _libraryManager).ConfigureAwait(false);
|
var item = GetMusicGenre(request.GenreName, _libraryManager);
|
||||||
|
|
||||||
UpdateItem(request, item);
|
UpdateItem(request, item);
|
||||||
|
|
||||||
|
@ -169,7 +169,7 @@ namespace MediaBrowser.Api
|
||||||
|
|
||||||
private async Task UpdateItem(UpdateGameGenre request)
|
private async Task UpdateItem(UpdateGameGenre request)
|
||||||
{
|
{
|
||||||
var item = await GetGameGenre(request.GenreName, _libraryManager).ConfigureAwait(false);
|
var item = GetGameGenre(request.GenreName, _libraryManager);
|
||||||
|
|
||||||
UpdateItem(request, item);
|
UpdateItem(request, item);
|
||||||
|
|
||||||
|
@ -185,7 +185,7 @@ namespace MediaBrowser.Api
|
||||||
|
|
||||||
private async Task UpdateItem(UpdateGenre request)
|
private async Task UpdateItem(UpdateGenre request)
|
||||||
{
|
{
|
||||||
var item = await GetGenre(request.GenreName, _libraryManager).ConfigureAwait(false);
|
var item = GetGenre(request.GenreName, _libraryManager);
|
||||||
|
|
||||||
UpdateItem(request, item);
|
UpdateItem(request, item);
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,7 @@ namespace MediaBrowser.Api.UserLibrary
|
||||||
/// <returns>Task{BaseItemDto}.</returns>
|
/// <returns>Task{BaseItemDto}.</returns>
|
||||||
private async Task<BaseItemDto> GetItem(GetArtist request)
|
private async Task<BaseItemDto> GetItem(GetArtist request)
|
||||||
{
|
{
|
||||||
var item = await GetArtist(request.Name, LibraryManager).ConfigureAwait(false);
|
var item = GetArtist(request.Name, LibraryManager);
|
||||||
|
|
||||||
// Get everything
|
// Get everything
|
||||||
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true));
|
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true));
|
||||||
|
@ -110,7 +110,7 @@ namespace MediaBrowser.Api.UserLibrary
|
||||||
/// <param name="request">The request.</param>
|
/// <param name="request">The request.</param>
|
||||||
/// <param name="items">The items.</param>
|
/// <param name="items">The items.</param>
|
||||||
/// <returns>IEnumerable{Tuple{System.StringFunc{System.Int32}}}.</returns>
|
/// <returns>IEnumerable{Tuple{System.StringFunc{System.Int32}}}.</returns>
|
||||||
protected override IEnumerable<Task<Artist>> GetAllItems(GetItemsByName request, IEnumerable<BaseItem> items)
|
protected override IEnumerable<Artist> GetAllItems(GetItemsByName request, IEnumerable<BaseItem> items)
|
||||||
{
|
{
|
||||||
var itemsList = items.OfType<Audio>().ToList();
|
var itemsList = items.OfType<Audio>().ToList();
|
||||||
|
|
||||||
|
@ -130,15 +130,5 @@ namespace MediaBrowser.Api.UserLibrary
|
||||||
.Distinct(StringComparer.OrdinalIgnoreCase)
|
.Distinct(StringComparer.OrdinalIgnoreCase)
|
||||||
.Select(name => LibraryManager.GetArtist(name));
|
.Select(name => LibraryManager.GetArtist(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the entity.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="name">The name.</param>
|
|
||||||
/// <returns>Task{Artist}.</returns>
|
|
||||||
protected Task<Artist> GetEntity(string name)
|
|
||||||
{
|
|
||||||
return LibraryManager.GetArtist(name);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,8 +90,7 @@ namespace MediaBrowser.Api.UserLibrary
|
||||||
|
|
||||||
items = FilterItems(request, items);
|
items = FilterItems(request, items);
|
||||||
|
|
||||||
var ibnItemTasks = GetAllItems(request, items);
|
var extractedItems = GetAllItems(request, items);
|
||||||
var extractedItems = await Task.WhenAll(ibnItemTasks).ConfigureAwait(false);
|
|
||||||
|
|
||||||
var filteredItems = FilterItems(request, extractedItems, user);
|
var filteredItems = FilterItems(request, extractedItems, user);
|
||||||
|
|
||||||
|
@ -245,7 +244,7 @@ namespace MediaBrowser.Api.UserLibrary
|
||||||
/// <param name="request">The request.</param>
|
/// <param name="request">The request.</param>
|
||||||
/// <param name="items">The items.</param>
|
/// <param name="items">The items.</param>
|
||||||
/// <returns>IEnumerable{Task{`0}}.</returns>
|
/// <returns>IEnumerable{Task{`0}}.</returns>
|
||||||
protected abstract IEnumerable<Task<TItemType>> GetAllItems(GetItemsByName request, IEnumerable<BaseItem> items);
|
protected abstract IEnumerable<TItemType> GetAllItems(GetItemsByName request, IEnumerable<BaseItem> items);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the dto.
|
/// Gets the dto.
|
||||||
|
|
|
@ -68,7 +68,7 @@ namespace MediaBrowser.Api.UserLibrary
|
||||||
/// <returns>Task{BaseItemDto}.</returns>
|
/// <returns>Task{BaseItemDto}.</returns>
|
||||||
private async Task<BaseItemDto> GetItem(GetGameGenre request)
|
private async Task<BaseItemDto> GetItem(GetGameGenre request)
|
||||||
{
|
{
|
||||||
var item = await GetGameGenre(request.Name, LibraryManager).ConfigureAwait(false);
|
var item = GetGameGenre(request.Name, LibraryManager);
|
||||||
|
|
||||||
// Get everything
|
// Get everything
|
||||||
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true));
|
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true));
|
||||||
|
@ -101,7 +101,7 @@ namespace MediaBrowser.Api.UserLibrary
|
||||||
/// <param name="request">The request.</param>
|
/// <param name="request">The request.</param>
|
||||||
/// <param name="items">The items.</param>
|
/// <param name="items">The items.</param>
|
||||||
/// <returns>IEnumerable{Tuple{System.StringFunc{System.Int32}}}.</returns>
|
/// <returns>IEnumerable{Tuple{System.StringFunc{System.Int32}}}.</returns>
|
||||||
protected override IEnumerable<Task<GameGenre>> GetAllItems(GetItemsByName request, IEnumerable<BaseItem> items)
|
protected override IEnumerable<GameGenre> GetAllItems(GetItemsByName request, IEnumerable<BaseItem> items)
|
||||||
{
|
{
|
||||||
var itemsList = items.Where(i => i.Genres != null).ToList();
|
var itemsList = items.Where(i => i.Genres != null).ToList();
|
||||||
|
|
||||||
|
@ -110,15 +110,5 @@ namespace MediaBrowser.Api.UserLibrary
|
||||||
.Distinct(StringComparer.OrdinalIgnoreCase)
|
.Distinct(StringComparer.OrdinalIgnoreCase)
|
||||||
.Select(name => LibraryManager.GetGameGenre(name));
|
.Select(name => LibraryManager.GetGameGenre(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the entity.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="name">The name.</param>
|
|
||||||
/// <returns>Task{Genre}.</returns>
|
|
||||||
protected Task<GameGenre> GetEntity(string name)
|
|
||||||
{
|
|
||||||
return LibraryManager.GetGameGenre(name);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,7 @@ namespace MediaBrowser.Api.UserLibrary
|
||||||
/// <returns>Task{BaseItemDto}.</returns>
|
/// <returns>Task{BaseItemDto}.</returns>
|
||||||
private async Task<BaseItemDto> GetItem(GetGenre request)
|
private async Task<BaseItemDto> GetItem(GetGenre request)
|
||||||
{
|
{
|
||||||
var item = await GetGenre(request.Name, LibraryManager).ConfigureAwait(false);
|
var item = GetGenre(request.Name, LibraryManager);
|
||||||
|
|
||||||
// Get everything
|
// Get everything
|
||||||
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true));
|
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true));
|
||||||
|
@ -105,7 +105,7 @@ namespace MediaBrowser.Api.UserLibrary
|
||||||
/// <param name="request">The request.</param>
|
/// <param name="request">The request.</param>
|
||||||
/// <param name="items">The items.</param>
|
/// <param name="items">The items.</param>
|
||||||
/// <returns>IEnumerable{Tuple{System.StringFunc{System.Int32}}}.</returns>
|
/// <returns>IEnumerable{Tuple{System.StringFunc{System.Int32}}}.</returns>
|
||||||
protected override IEnumerable<Task<Genre>> GetAllItems(GetItemsByName request, IEnumerable<BaseItem> items)
|
protected override IEnumerable<Genre> GetAllItems(GetItemsByName request, IEnumerable<BaseItem> items)
|
||||||
{
|
{
|
||||||
var itemsList = items.Where(i => i.Genres != null).ToList();
|
var itemsList = items.Where(i => i.Genres != null).ToList();
|
||||||
|
|
||||||
|
@ -114,15 +114,5 @@ namespace MediaBrowser.Api.UserLibrary
|
||||||
.Distinct(StringComparer.OrdinalIgnoreCase)
|
.Distinct(StringComparer.OrdinalIgnoreCase)
|
||||||
.Select(name => LibraryManager.GetGenre(name));
|
.Select(name => LibraryManager.GetGenre(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the entity.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="name">The name.</param>
|
|
||||||
/// <returns>Task{Genre}.</returns>
|
|
||||||
protected Task<Genre> GetEntity(string name)
|
|
||||||
{
|
|
||||||
return LibraryManager.GetGenre(name);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -218,7 +218,7 @@ namespace MediaBrowser.Api.UserLibrary
|
||||||
/// <returns>Task.</returns>
|
/// <returns>Task.</returns>
|
||||||
protected async Task<UserItemDataDto> MarkFavorite(Guid userId, string type, string name, bool isFavorite)
|
protected async Task<UserItemDataDto> MarkFavorite(Guid userId, string type, string name, bool isFavorite)
|
||||||
{
|
{
|
||||||
var item = await GetItemByName(name, type, LibraryManager).ConfigureAwait(false);
|
var item = GetItemByName(name, type, LibraryManager);
|
||||||
|
|
||||||
var key = item.GetUserDataKey();
|
var key = item.GetUserDataKey();
|
||||||
|
|
||||||
|
@ -245,7 +245,7 @@ namespace MediaBrowser.Api.UserLibrary
|
||||||
/// <returns>Task.</returns>
|
/// <returns>Task.</returns>
|
||||||
protected async Task<UserItemDataDto> MarkLike(Guid userId, string type, string name, bool? likes)
|
protected async Task<UserItemDataDto> MarkLike(Guid userId, string type, string name, bool? likes)
|
||||||
{
|
{
|
||||||
var item = await GetItemByName(name, type, LibraryManager).ConfigureAwait(false);
|
var item = GetItemByName(name, type, LibraryManager);
|
||||||
|
|
||||||
var key = item.GetUserDataKey();
|
var key = item.GetUserDataKey();
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ namespace MediaBrowser.Api.UserLibrary
|
||||||
{
|
{
|
||||||
public GetMusicGenres()
|
public GetMusicGenres()
|
||||||
{
|
{
|
||||||
IncludeItemTypes = typeof (Audio).Name;
|
IncludeItemTypes = typeof(Audio).Name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ namespace MediaBrowser.Api.UserLibrary
|
||||||
/// <returns>Task{BaseItemDto}.</returns>
|
/// <returns>Task{BaseItemDto}.</returns>
|
||||||
private async Task<BaseItemDto> GetItem(GetMusicGenre request)
|
private async Task<BaseItemDto> GetItem(GetMusicGenre request)
|
||||||
{
|
{
|
||||||
var item = await GetMusicGenre(request.Name, LibraryManager).ConfigureAwait(false);
|
var item = GetMusicGenre(request.Name, LibraryManager);
|
||||||
|
|
||||||
// Get everything
|
// Get everything
|
||||||
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true));
|
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true));
|
||||||
|
@ -101,7 +101,7 @@ namespace MediaBrowser.Api.UserLibrary
|
||||||
/// <param name="request">The request.</param>
|
/// <param name="request">The request.</param>
|
||||||
/// <param name="items">The items.</param>
|
/// <param name="items">The items.</param>
|
||||||
/// <returns>IEnumerable{Tuple{System.StringFunc{System.Int32}}}.</returns>
|
/// <returns>IEnumerable{Tuple{System.StringFunc{System.Int32}}}.</returns>
|
||||||
protected override IEnumerable<Task<MusicGenre>> GetAllItems(GetItemsByName request, IEnumerable<BaseItem> items)
|
protected override IEnumerable<MusicGenre> GetAllItems(GetItemsByName request, IEnumerable<BaseItem> items)
|
||||||
{
|
{
|
||||||
var itemsList = items.ToList();
|
var itemsList = items.ToList();
|
||||||
|
|
||||||
|
@ -110,15 +110,5 @@ namespace MediaBrowser.Api.UserLibrary
|
||||||
.Distinct(StringComparer.OrdinalIgnoreCase)
|
.Distinct(StringComparer.OrdinalIgnoreCase)
|
||||||
.Select(name => LibraryManager.GetMusicGenre(name));
|
.Select(name => LibraryManager.GetMusicGenre(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the entity.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="name">The name.</param>
|
|
||||||
/// <returns>Task{Genre}.</returns>
|
|
||||||
protected Task<MusicGenre> GetEntity(string name)
|
|
||||||
{
|
|
||||||
return LibraryManager.GetMusicGenre(name);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,7 +84,7 @@ namespace MediaBrowser.Api.UserLibrary
|
||||||
/// <returns>Task{BaseItemDto}.</returns>
|
/// <returns>Task{BaseItemDto}.</returns>
|
||||||
private async Task<BaseItemDto> GetItem(GetPerson request)
|
private async Task<BaseItemDto> GetItem(GetPerson request)
|
||||||
{
|
{
|
||||||
var item = await GetPerson(request.Name, LibraryManager).ConfigureAwait(false);
|
var item = GetPerson(request.Name, LibraryManager);
|
||||||
|
|
||||||
// Get everything
|
// Get everything
|
||||||
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true));
|
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true));
|
||||||
|
@ -117,7 +117,7 @@ namespace MediaBrowser.Api.UserLibrary
|
||||||
/// <param name="request">The request.</param>
|
/// <param name="request">The request.</param>
|
||||||
/// <param name="items">The items.</param>
|
/// <param name="items">The items.</param>
|
||||||
/// <returns>IEnumerable{Tuple{System.StringFunc{System.Int32}}}.</returns>
|
/// <returns>IEnumerable{Tuple{System.StringFunc{System.Int32}}}.</returns>
|
||||||
protected override IEnumerable<Task<Person>> GetAllItems(GetItemsByName request, IEnumerable<BaseItem> items)
|
protected override IEnumerable<Person> GetAllItems(GetItemsByName request, IEnumerable<BaseItem> items)
|
||||||
{
|
{
|
||||||
var inputPersonTypes = ((GetPersons)request).PersonTypes;
|
var inputPersonTypes = ((GetPersons)request).PersonTypes;
|
||||||
var personTypes = string.IsNullOrEmpty(inputPersonTypes) ? new string[] { } : inputPersonTypes.Split(',');
|
var personTypes = string.IsNullOrEmpty(inputPersonTypes) ? new string[] { } : inputPersonTypes.Split(',');
|
||||||
|
@ -151,15 +151,5 @@ namespace MediaBrowser.Api.UserLibrary
|
||||||
|
|
||||||
people.Where(p => personTypes.Contains(p.Type ?? string.Empty, StringComparer.OrdinalIgnoreCase) || personTypes.Contains(p.Role ?? string.Empty, StringComparer.OrdinalIgnoreCase));
|
people.Where(p => personTypes.Contains(p.Type ?? string.Empty, StringComparer.OrdinalIgnoreCase) || personTypes.Contains(p.Role ?? string.Empty, StringComparer.OrdinalIgnoreCase));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the entity.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="name">The name.</param>
|
|
||||||
/// <returns>Task{Genre}.</returns>
|
|
||||||
protected Task<Person> GetEntity(string name)
|
|
||||||
{
|
|
||||||
return LibraryManager.GetPerson(name);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,7 @@ namespace MediaBrowser.Api.UserLibrary
|
||||||
/// <returns>Task{BaseItemDto}.</returns>
|
/// <returns>Task{BaseItemDto}.</returns>
|
||||||
private async Task<BaseItemDto> GetItem(GetStudio request)
|
private async Task<BaseItemDto> GetItem(GetStudio request)
|
||||||
{
|
{
|
||||||
var item = await GetStudio(request.Name, LibraryManager).ConfigureAwait(false);
|
var item = GetStudio(request.Name, LibraryManager);
|
||||||
|
|
||||||
// Get everything
|
// Get everything
|
||||||
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true));
|
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true));
|
||||||
|
@ -105,7 +105,7 @@ namespace MediaBrowser.Api.UserLibrary
|
||||||
/// <param name="request">The request.</param>
|
/// <param name="request">The request.</param>
|
||||||
/// <param name="items">The items.</param>
|
/// <param name="items">The items.</param>
|
||||||
/// <returns>IEnumerable{Tuple{System.StringFunc{System.Int32}}}.</returns>
|
/// <returns>IEnumerable{Tuple{System.StringFunc{System.Int32}}}.</returns>
|
||||||
protected override IEnumerable<Task<Studio>> GetAllItems(GetItemsByName request, IEnumerable<BaseItem> items)
|
protected override IEnumerable<Studio> GetAllItems(GetItemsByName request, IEnumerable<BaseItem> items)
|
||||||
{
|
{
|
||||||
var itemsList = items.Where(i => i.Studios != null).ToList();
|
var itemsList = items.Where(i => i.Studios != null).ToList();
|
||||||
|
|
||||||
|
@ -114,15 +114,5 @@ namespace MediaBrowser.Api.UserLibrary
|
||||||
.Distinct(StringComparer.OrdinalIgnoreCase)
|
.Distinct(StringComparer.OrdinalIgnoreCase)
|
||||||
.Select(name => LibraryManager.GetStudio(name));
|
.Select(name => LibraryManager.GetStudio(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the entity.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="name">The name.</param>
|
|
||||||
/// <returns>Task{Studio}.</returns>
|
|
||||||
protected Task<Studio> GetEntity(string name)
|
|
||||||
{
|
|
||||||
return LibraryManager.GetStudio(name);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,7 +78,7 @@ namespace MediaBrowser.Api.UserLibrary
|
||||||
/// <returns>Task{BaseItemDto}.</returns>
|
/// <returns>Task{BaseItemDto}.</returns>
|
||||||
private async Task<BaseItemDto> GetItem(GetYear request)
|
private async Task<BaseItemDto> GetItem(GetYear request)
|
||||||
{
|
{
|
||||||
var item = await LibraryManager.GetYear(request.Year).ConfigureAwait(false);
|
var item = LibraryManager.GetYear(request.Year);
|
||||||
|
|
||||||
// Get everything
|
// Get everything
|
||||||
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true));
|
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true));
|
||||||
|
@ -111,7 +111,7 @@ namespace MediaBrowser.Api.UserLibrary
|
||||||
/// <param name="request">The request.</param>
|
/// <param name="request">The request.</param>
|
||||||
/// <param name="items">The items.</param>
|
/// <param name="items">The items.</param>
|
||||||
/// <returns>IEnumerable{Tuple{System.StringFunc{System.Int32}}}.</returns>
|
/// <returns>IEnumerable{Tuple{System.StringFunc{System.Int32}}}.</returns>
|
||||||
protected override IEnumerable<Task<Year>> GetAllItems(GetItemsByName request, IEnumerable<BaseItem> items)
|
protected override IEnumerable<Year> GetAllItems(GetItemsByName request, IEnumerable<BaseItem> items)
|
||||||
{
|
{
|
||||||
var itemsList = items.Where(i => i.ProductionYear != null).ToList();
|
var itemsList = items.Where(i => i.ProductionYear != null).ToList();
|
||||||
|
|
||||||
|
@ -120,15 +120,5 @@ namespace MediaBrowser.Api.UserLibrary
|
||||||
.Distinct()
|
.Distinct()
|
||||||
.Select(year => LibraryManager.GetYear(year));
|
.Select(year => LibraryManager.GetYear(year));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the entity.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="name">The name.</param>
|
|
||||||
/// <returns>Task{Studio}.</returns>
|
|
||||||
protected Task<Year> GetEntity(string name)
|
|
||||||
{
|
|
||||||
return LibraryManager.GetYear(int.Parse(name, UsCulture));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using MediaBrowser.Common.Extensions;
|
using System.Runtime.InteropServices;
|
||||||
|
using MediaBrowser.Common.Extensions;
|
||||||
using MediaBrowser.Controller.Configuration;
|
using MediaBrowser.Controller.Configuration;
|
||||||
using MediaBrowser.Controller.IO;
|
using MediaBrowser.Controller.IO;
|
||||||
using MediaBrowser.Controller.Library;
|
using MediaBrowser.Controller.Library;
|
||||||
|
|
|
@ -235,7 +235,7 @@ namespace MediaBrowser.Controller.Entities
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return LibraryManager.GetPerson(i).Result;
|
return LibraryManager.GetPerson(i);
|
||||||
}
|
}
|
||||||
catch (IOException ex)
|
catch (IOException ex)
|
||||||
{
|
{
|
||||||
|
@ -263,7 +263,7 @@ namespace MediaBrowser.Controller.Entities
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return LibraryManager.GetArtist(i).Result;
|
return LibraryManager.GetArtist(i);
|
||||||
}
|
}
|
||||||
catch (IOException ex)
|
catch (IOException ex)
|
||||||
{
|
{
|
||||||
|
@ -307,7 +307,7 @@ namespace MediaBrowser.Controller.Entities
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return LibraryManager.GetStudio(i).Result;
|
return LibraryManager.GetStudio(i);
|
||||||
}
|
}
|
||||||
catch (IOException ex)
|
catch (IOException ex)
|
||||||
{
|
{
|
||||||
|
@ -347,7 +347,7 @@ namespace MediaBrowser.Controller.Entities
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return LibraryManager.GetGenre(i).Result;
|
return LibraryManager.GetGenre(i);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -383,7 +383,7 @@ namespace MediaBrowser.Controller.Entities
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return LibraryManager.GetYear(i).Result;
|
return LibraryManager.GetYear(i);
|
||||||
}
|
}
|
||||||
catch (IOException ex)
|
catch (IOException ex)
|
||||||
{
|
{
|
||||||
|
|
|
@ -54,58 +54,51 @@ namespace MediaBrowser.Controller.Library
|
||||||
/// Gets a Person
|
/// Gets a Person
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="name">The name.</param>
|
/// <param name="name">The name.</param>
|
||||||
/// <param name="allowSlowProviders">if set to <c>true</c> [allow slow providers].</param>
|
|
||||||
/// <returns>Task{Person}.</returns>
|
/// <returns>Task{Person}.</returns>
|
||||||
Task<Person> GetPerson(string name, bool allowSlowProviders = false);
|
Person GetPerson(string name);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the artist.
|
/// Gets the artist.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="name">The name.</param>
|
/// <param name="name">The name.</param>
|
||||||
/// <param name="allowSlowProviders">if set to <c>true</c> [allow slow providers].</param>
|
|
||||||
/// <returns>Task{Artist}.</returns>
|
/// <returns>Task{Artist}.</returns>
|
||||||
Task<Artist> GetArtist(string name, bool allowSlowProviders = false);
|
Artist GetArtist(string name);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a Studio
|
/// Gets a Studio
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="name">The name.</param>
|
/// <param name="name">The name.</param>
|
||||||
/// <param name="allowSlowProviders">if set to <c>true</c> [allow slow providers].</param>
|
|
||||||
/// <returns>Task{Studio}.</returns>
|
/// <returns>Task{Studio}.</returns>
|
||||||
Task<Studio> GetStudio(string name, bool allowSlowProviders = false);
|
Studio GetStudio(string name);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a Genre
|
/// Gets a Genre
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="name">The name.</param>
|
/// <param name="name">The name.</param>
|
||||||
/// <param name="allowSlowProviders">if set to <c>true</c> [allow slow providers].</param>
|
|
||||||
/// <returns>Task{Genre}.</returns>
|
/// <returns>Task{Genre}.</returns>
|
||||||
Task<Genre> GetGenre(string name, bool allowSlowProviders = false);
|
Genre GetGenre(string name);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the genre.
|
/// Gets the genre.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="name">The name.</param>
|
/// <param name="name">The name.</param>
|
||||||
/// <param name="allowSlowProviders">if set to <c>true</c> [allow slow providers].</param>
|
|
||||||
/// <returns>Task{MusicGenre}.</returns>
|
/// <returns>Task{MusicGenre}.</returns>
|
||||||
Task<MusicGenre> GetMusicGenre(string name, bool allowSlowProviders = false);
|
MusicGenre GetMusicGenre(string name);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the game genre.
|
/// Gets the game genre.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="name">The name.</param>
|
/// <param name="name">The name.</param>
|
||||||
/// <param name="allowSlowProviders">if set to <c>true</c> [allow slow providers].</param>
|
|
||||||
/// <returns>Task{GameGenre}.</returns>
|
/// <returns>Task{GameGenre}.</returns>
|
||||||
Task<GameGenre> GetGameGenre(string name, bool allowSlowProviders = false);
|
GameGenre GetGameGenre(string name);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a Year
|
/// Gets a Year
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="value">The value.</param>
|
/// <param name="value">The value.</param>
|
||||||
/// <param name="allowSlowProviders">if set to <c>true</c> [allow slow providers].</param>
|
|
||||||
/// <returns>Task{Year}.</returns>
|
/// <returns>Task{Year}.</returns>
|
||||||
/// <exception cref="System.ArgumentOutOfRangeException"></exception>
|
/// <exception cref="System.ArgumentOutOfRangeException"></exception>
|
||||||
Task<Year> GetYear(int value, bool allowSlowProviders = false);
|
Year GetYear(int value);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Validate and refresh the People sub-set of the IBN.
|
/// Validate and refresh the People sub-set of the IBN.
|
||||||
|
|
|
@ -63,16 +63,9 @@ namespace MediaBrowser.Server.Implementations.Dto
|
||||||
|
|
||||||
var dto = new BaseItemDto();
|
var dto = new BaseItemDto();
|
||||||
|
|
||||||
var tasks = new List<Task>();
|
|
||||||
|
|
||||||
if (fields.Contains(ItemFields.Studios))
|
|
||||||
{
|
|
||||||
tasks.Add(AttachStudios(dto, item));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fields.Contains(ItemFields.People))
|
if (fields.Contains(ItemFields.People))
|
||||||
{
|
{
|
||||||
tasks.Add(AttachPeople(dto, item));
|
AttachPeople(dto, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fields.Contains(ItemFields.PrimaryImageAspectRatio))
|
if (fields.Contains(ItemFields.PrimaryImageAspectRatio))
|
||||||
|
@ -98,6 +91,11 @@ namespace MediaBrowser.Server.Implementations.Dto
|
||||||
AttachUserSpecificInfo(dto, item, user, fields);
|
AttachUserSpecificInfo(dto, item, user, fields);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fields.Contains(ItemFields.Studios))
|
||||||
|
{
|
||||||
|
AttachStudios(dto, item);
|
||||||
|
}
|
||||||
|
|
||||||
AttachBasicFields(dto, item, owner, fields);
|
AttachBasicFields(dto, item, owner, fields);
|
||||||
|
|
||||||
if (fields.Contains(ItemFields.SoundtrackIds))
|
if (fields.Contains(ItemFields.SoundtrackIds))
|
||||||
|
@ -116,12 +114,6 @@ namespace MediaBrowser.Server.Implementations.Dto
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure all the tasks we kicked off have completed.
|
|
||||||
if (tasks.Count > 0)
|
|
||||||
{
|
|
||||||
await Task.WhenAll(tasks).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
return dto;
|
return dto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -433,7 +425,7 @@ namespace MediaBrowser.Server.Implementations.Dto
|
||||||
/// <param name="dto">The dto.</param>
|
/// <param name="dto">The dto.</param>
|
||||||
/// <param name="item">The item.</param>
|
/// <param name="item">The item.</param>
|
||||||
/// <returns>Task.</returns>
|
/// <returns>Task.</returns>
|
||||||
private async Task AttachPeople(BaseItemDto dto, BaseItem item)
|
private void AttachPeople(BaseItemDto dto, BaseItem item)
|
||||||
{
|
{
|
||||||
// Ordering by person type to ensure actors and artists are at the front.
|
// Ordering by person type to ensure actors and artists are at the front.
|
||||||
// This is taking advantage of the fact that they both begin with A
|
// This is taking advantage of the fact that they both begin with A
|
||||||
|
@ -443,24 +435,20 @@ namespace MediaBrowser.Server.Implementations.Dto
|
||||||
// Attach People by transforming them into BaseItemPerson (DTO)
|
// Attach People by transforming them into BaseItemPerson (DTO)
|
||||||
dto.People = new BaseItemPerson[people.Count];
|
dto.People = new BaseItemPerson[people.Count];
|
||||||
|
|
||||||
var entities = await Task.WhenAll(people.Select(p => p.Name)
|
var dictionary = people.Select(p => p.Name)
|
||||||
.Distinct(StringComparer.OrdinalIgnoreCase).Select(c =>
|
.Distinct(StringComparer.OrdinalIgnoreCase).Select(c =>
|
||||||
Task.Run(async () =>
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
try
|
return _libraryManager.GetPerson(c);
|
||||||
{
|
}
|
||||||
return await _libraryManager.GetPerson(c).ConfigureAwait(false);
|
catch (IOException ex)
|
||||||
}
|
{
|
||||||
catch (IOException ex)
|
_logger.ErrorException("Error getting person {0}", ex, c);
|
||||||
{
|
return null;
|
||||||
_logger.ErrorException("Error getting person {0}", ex, c);
|
}
|
||||||
return null;
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
)).ConfigureAwait(false);
|
}).Where(i => i != null)
|
||||||
|
|
||||||
var dictionary = entities.Where(i => i != null)
|
|
||||||
.DistinctBy(i => i.Name)
|
.DistinctBy(i => i.Name)
|
||||||
.ToDictionary(i => i.Name, StringComparer.OrdinalIgnoreCase);
|
.ToDictionary(i => i.Name, StringComparer.OrdinalIgnoreCase);
|
||||||
|
|
||||||
|
@ -497,32 +485,26 @@ namespace MediaBrowser.Server.Implementations.Dto
|
||||||
/// <param name="dto">The dto.</param>
|
/// <param name="dto">The dto.</param>
|
||||||
/// <param name="item">The item.</param>
|
/// <param name="item">The item.</param>
|
||||||
/// <returns>Task.</returns>
|
/// <returns>Task.</returns>
|
||||||
private async Task AttachStudios(BaseItemDto dto, BaseItem item)
|
private void AttachStudios(BaseItemDto dto, BaseItem item)
|
||||||
{
|
{
|
||||||
var studios = item.Studios.ToList();
|
var studios = item.Studios.ToList();
|
||||||
|
|
||||||
dto.Studios = new StudioDto[studios.Count];
|
dto.Studios = new StudioDto[studios.Count];
|
||||||
|
|
||||||
var entities = await Task.WhenAll(studios.Distinct(StringComparer.OrdinalIgnoreCase).Select(c =>
|
var dictionary = studios.Distinct(StringComparer.OrdinalIgnoreCase).Select(name =>
|
||||||
|
{
|
||||||
Task.Run(async () =>
|
try
|
||||||
{
|
{
|
||||||
try
|
return _libraryManager.GetStudio(name);
|
||||||
{
|
}
|
||||||
return await _libraryManager.GetStudio(c).ConfigureAwait(false);
|
catch (IOException ex)
|
||||||
}
|
{
|
||||||
catch (IOException ex)
|
_logger.ErrorException("Error getting studio {0}", ex, name);
|
||||||
{
|
return null;
|
||||||
_logger.ErrorException("Error getting studio {0}", ex, c);
|
}
|
||||||
return null;
|
})
|
||||||
}
|
.Where(i => i != null)
|
||||||
})
|
.ToDictionary(i => i.Name, StringComparer.OrdinalIgnoreCase);
|
||||||
|
|
||||||
)).ConfigureAwait(false);
|
|
||||||
|
|
||||||
var dictionary = entities
|
|
||||||
.Where(i => i != null)
|
|
||||||
.ToDictionary(i => i.Name, StringComparer.OrdinalIgnoreCase);
|
|
||||||
|
|
||||||
for (var i = 0; i < studios.Count; i++)
|
for (var i = 0; i < studios.Count; i++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -590,144 +590,60 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||||
/// Gets a Person
|
/// Gets a Person
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="name">The name.</param>
|
/// <param name="name">The name.</param>
|
||||||
/// <param name="allowSlowProviders">if set to <c>true</c> [allow slow providers].</param>
|
|
||||||
/// <returns>Task{Person}.</returns>
|
/// <returns>Task{Person}.</returns>
|
||||||
public Task<Person> GetPerson(string name, bool allowSlowProviders = false)
|
public Person GetPerson(string name)
|
||||||
{
|
{
|
||||||
return GetPerson(name, CancellationToken.None, allowSlowProviders);
|
return GetItemByName<Person>(ConfigurationManager.ApplicationPaths.PeoplePath, name);
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets a Person
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="name">The name.</param>
|
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
|
||||||
/// <param name="allowSlowProviders">if set to <c>true</c> [allow slow providers].</param>
|
|
||||||
/// <param name="refreshMetadata">if set to <c>true</c> [force creation].</param>
|
|
||||||
/// <returns>Task{Person}.</returns>
|
|
||||||
private Task<Person> GetPerson(string name, CancellationToken cancellationToken, bool allowSlowProviders = false, bool refreshMetadata = false)
|
|
||||||
{
|
|
||||||
return GetItemByName<Person>(ConfigurationManager.ApplicationPaths.PeoplePath, name, cancellationToken, allowSlowProviders, refreshMetadata);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a Studio
|
/// Gets a Studio
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="name">The name.</param>
|
/// <param name="name">The name.</param>
|
||||||
/// <param name="allowSlowProviders">if set to <c>true</c> [allow slow providers].</param>
|
|
||||||
/// <returns>Task{Studio}.</returns>
|
/// <returns>Task{Studio}.</returns>
|
||||||
public Task<Studio> GetStudio(string name, bool allowSlowProviders = false)
|
public Studio GetStudio(string name)
|
||||||
{
|
{
|
||||||
return GetStudio(name, CancellationToken.None, allowSlowProviders);
|
return GetItemByName<Studio>(ConfigurationManager.ApplicationPaths.StudioPath, name);
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the studio.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="name">The name.</param>
|
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
|
||||||
/// <param name="allowSlowProviders">if set to <c>true</c> [allow slow providers].</param>
|
|
||||||
/// <param name="refreshMetadata">if set to <c>true</c> [refresh metadata].</param>
|
|
||||||
/// <returns>Task{Studio}.</returns>
|
|
||||||
internal Task<Studio> GetStudio(string name, CancellationToken cancellationToken, bool allowSlowProviders = false, bool refreshMetadata = false)
|
|
||||||
{
|
|
||||||
return GetItemByName<Studio>(ConfigurationManager.ApplicationPaths.StudioPath, name, cancellationToken, allowSlowProviders, refreshMetadata);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a Genre
|
/// Gets a Genre
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="name">The name.</param>
|
/// <param name="name">The name.</param>
|
||||||
/// <param name="allowSlowProviders">if set to <c>true</c> [allow slow providers].</param>
|
|
||||||
/// <returns>Task{Genre}.</returns>
|
/// <returns>Task{Genre}.</returns>
|
||||||
public Task<Genre> GetGenre(string name, bool allowSlowProviders = false)
|
public Genre GetGenre(string name)
|
||||||
{
|
{
|
||||||
return GetGenre(name, CancellationToken.None, allowSlowProviders);
|
return GetItemByName<Genre>(ConfigurationManager.ApplicationPaths.GenrePath, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the genre.
|
/// Gets the genre.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="name">The name.</param>
|
/// <param name="name">The name.</param>
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
|
||||||
/// <param name="allowSlowProviders">if set to <c>true</c> [allow slow providers].</param>
|
|
||||||
/// <param name="refreshMetadata">if set to <c>true</c> [refresh metadata].</param>
|
|
||||||
/// <returns>Task{Genre}.</returns>
|
|
||||||
internal Task<Genre> GetGenre(string name, CancellationToken cancellationToken, bool allowSlowProviders = false, bool refreshMetadata = false)
|
|
||||||
{
|
|
||||||
return GetItemByName<Genre>(ConfigurationManager.ApplicationPaths.GenrePath, name, cancellationToken, allowSlowProviders, refreshMetadata);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the genre.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="name">The name.</param>
|
|
||||||
/// <param name="allowSlowProviders">if set to <c>true</c> [allow slow providers].</param>
|
|
||||||
/// <returns>Task{MusicGenre}.</returns>
|
/// <returns>Task{MusicGenre}.</returns>
|
||||||
public Task<MusicGenre> GetMusicGenre(string name, bool allowSlowProviders = false)
|
public MusicGenre GetMusicGenre(string name)
|
||||||
{
|
{
|
||||||
return GetMusicGenre(name, CancellationToken.None, allowSlowProviders);
|
return GetItemByName<MusicGenre>(ConfigurationManager.ApplicationPaths.MusicGenrePath, name);
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the music genre.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="name">The name.</param>
|
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
|
||||||
/// <param name="allowSlowProviders">if set to <c>true</c> [allow slow providers].</param>
|
|
||||||
/// <param name="refreshMetadata">if set to <c>true</c> [refresh metadata].</param>
|
|
||||||
/// <returns>Task{MusicGenre}.</returns>
|
|
||||||
internal Task<MusicGenre> GetMusicGenre(string name, CancellationToken cancellationToken, bool allowSlowProviders = false, bool refreshMetadata = false)
|
|
||||||
{
|
|
||||||
return GetItemByName<MusicGenre>(ConfigurationManager.ApplicationPaths.MusicGenrePath, name, cancellationToken, allowSlowProviders, refreshMetadata);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the game genre.
|
/// Gets the game genre.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="name">The name.</param>
|
/// <param name="name">The name.</param>
|
||||||
/// <param name="allowSlowProviders">if set to <c>true</c> [allow slow providers].</param>
|
|
||||||
/// <returns>Task{GameGenre}.</returns>
|
/// <returns>Task{GameGenre}.</returns>
|
||||||
public Task<GameGenre> GetGameGenre(string name, bool allowSlowProviders = false)
|
public GameGenre GetGameGenre(string name)
|
||||||
{
|
{
|
||||||
return GetGameGenre(name, CancellationToken.None, allowSlowProviders);
|
return GetItemByName<GameGenre>(ConfigurationManager.ApplicationPaths.GameGenrePath, name);
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the game genre.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="name">The name.</param>
|
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
|
||||||
/// <param name="allowSlowProviders">if set to <c>true</c> [allow slow providers].</param>
|
|
||||||
/// <param name="refreshMetadata">if set to <c>true</c> [refresh metadata].</param>
|
|
||||||
/// <returns>Task{GameGenre}.</returns>
|
|
||||||
internal Task<GameGenre> GetGameGenre(string name, CancellationToken cancellationToken, bool allowSlowProviders = false, bool refreshMetadata = false)
|
|
||||||
{
|
|
||||||
return GetItemByName<GameGenre>(ConfigurationManager.ApplicationPaths.GameGenrePath, name, cancellationToken, allowSlowProviders, refreshMetadata);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a Genre
|
/// Gets a Genre
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="name">The name.</param>
|
/// <param name="name">The name.</param>
|
||||||
/// <param name="allowSlowProviders">if set to <c>true</c> [allow slow providers].</param>
|
|
||||||
/// <returns>Task{Genre}.</returns>
|
/// <returns>Task{Genre}.</returns>
|
||||||
public Task<Artist> GetArtist(string name, bool allowSlowProviders = false)
|
public Artist GetArtist(string name)
|
||||||
{
|
{
|
||||||
return GetArtist(name, CancellationToken.None, allowSlowProviders);
|
return GetItemByName<Artist>(ConfigurationManager.ApplicationPaths.ArtistsPath, name);
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the artist.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="name">The name.</param>
|
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
|
||||||
/// <param name="allowSlowProviders">if set to <c>true</c> [allow slow providers].</param>
|
|
||||||
/// <param name="refreshMetadata">if set to <c>true</c> [force creation].</param>
|
|
||||||
/// <returns>Task{Artist}.</returns>
|
|
||||||
internal Task<Artist> GetArtist(string name, CancellationToken cancellationToken, bool allowSlowProviders = false, bool refreshMetadata = false)
|
|
||||||
{
|
|
||||||
return GetItemByName<Artist>(ConfigurationManager.ApplicationPaths.ArtistsPath, name, cancellationToken, allowSlowProviders, refreshMetadata);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -739,17 +655,16 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||||
/// Gets a Year
|
/// Gets a Year
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="value">The value.</param>
|
/// <param name="value">The value.</param>
|
||||||
/// <param name="allowSlowProviders">if set to <c>true</c> [allow slow providers].</param>
|
|
||||||
/// <returns>Task{Year}.</returns>
|
/// <returns>Task{Year}.</returns>
|
||||||
/// <exception cref="System.ArgumentOutOfRangeException"></exception>
|
/// <exception cref="System.ArgumentOutOfRangeException"></exception>
|
||||||
public Task<Year> GetYear(int value, bool allowSlowProviders = false)
|
public Year GetYear(int value)
|
||||||
{
|
{
|
||||||
if (value <= 0)
|
if (value <= 0)
|
||||||
{
|
{
|
||||||
throw new ArgumentOutOfRangeException();
|
throw new ArgumentOutOfRangeException();
|
||||||
}
|
}
|
||||||
|
|
||||||
return GetItemByName<Year>(ConfigurationManager.ApplicationPaths.YearPath, value.ToString(UsCulture), CancellationToken.None, allowSlowProviders);
|
return GetItemByName<Year>(ConfigurationManager.ApplicationPaths.YearPath, value.ToString(UsCulture));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -940,7 +855,9 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await GetPerson(currentPerson.Name, cancellationToken, true, true).ConfigureAwait(false);
|
var item = GetPerson(currentPerson.Name);
|
||||||
|
|
||||||
|
await item.RefreshMetadata(cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (IOException ex)
|
catch (IOException ex)
|
||||||
{
|
{
|
||||||
|
@ -964,6 +881,10 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||||
progress.Report(100);
|
progress.Report(100);
|
||||||
|
|
||||||
_logger.Info("People validation complete");
|
_logger.Info("People validation complete");
|
||||||
|
|
||||||
|
// Bad practice, i know. But we keep a lot in memory, unfortunately.
|
||||||
|
GC.Collect(2, GCCollectionMode.Forced, true);
|
||||||
|
GC.Collect(2, GCCollectionMode.Forced, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -97,7 +97,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||||
/// <param name="searchTerm">The search term.</param>
|
/// <param name="searchTerm">The search term.</param>
|
||||||
/// <returns>IEnumerable{SearchHintResult}.</returns>
|
/// <returns>IEnumerable{SearchHintResult}.</returns>
|
||||||
/// <exception cref="System.ArgumentNullException">searchTerm</exception>
|
/// <exception cref="System.ArgumentNullException">searchTerm</exception>
|
||||||
public async Task<IEnumerable<SearchHintInfo>> GetSearchHints(IEnumerable<BaseItem> inputItems, string searchTerm)
|
public Task<IEnumerable<SearchHintInfo>> GetSearchHints(IEnumerable<BaseItem> inputItems, string searchTerm)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(searchTerm))
|
if (string.IsNullOrEmpty(searchTerm))
|
||||||
{
|
{
|
||||||
|
@ -143,7 +143,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var artist = await _libraryManager.GetArtist(item).ConfigureAwait(false);
|
var artist = _libraryManager.GetArtist(item);
|
||||||
|
|
||||||
hints.Add(new Tuple<BaseItem, string, int>(artist, index.Item1, index.Item2));
|
hints.Add(new Tuple<BaseItem, string, int>(artist, index.Item1, index.Item2));
|
||||||
}
|
}
|
||||||
|
@ -169,7 +169,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var genre = await _libraryManager.GetGenre(item).ConfigureAwait(false);
|
var genre = _libraryManager.GetGenre(item);
|
||||||
|
|
||||||
hints.Add(new Tuple<BaseItem, string, int>(genre, index.Item1, index.Item2));
|
hints.Add(new Tuple<BaseItem, string, int>(genre, index.Item1, index.Item2));
|
||||||
}
|
}
|
||||||
|
@ -195,7 +195,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var genre = await _libraryManager.GetMusicGenre(item).ConfigureAwait(false);
|
var genre = _libraryManager.GetMusicGenre(item);
|
||||||
|
|
||||||
hints.Add(new Tuple<BaseItem, string, int>(genre, index.Item1, index.Item2));
|
hints.Add(new Tuple<BaseItem, string, int>(genre, index.Item1, index.Item2));
|
||||||
}
|
}
|
||||||
|
@ -221,7 +221,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var genre = await _libraryManager.GetGameGenre(item).ConfigureAwait(false);
|
var genre = _libraryManager.GetGameGenre(item);
|
||||||
|
|
||||||
hints.Add(new Tuple<BaseItem, string, int>(genre, index.Item1, index.Item2));
|
hints.Add(new Tuple<BaseItem, string, int>(genre, index.Item1, index.Item2));
|
||||||
}
|
}
|
||||||
|
@ -246,7 +246,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var studio = await _libraryManager.GetStudio(item).ConfigureAwait(false);
|
var studio = _libraryManager.GetStudio(item);
|
||||||
|
|
||||||
hints.Add(new Tuple<BaseItem, string, int>(studio, index.Item1, index.Item2));
|
hints.Add(new Tuple<BaseItem, string, int>(studio, index.Item1, index.Item2));
|
||||||
}
|
}
|
||||||
|
@ -272,7 +272,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var person = await _libraryManager.GetPerson(item).ConfigureAwait(false);
|
var person = _libraryManager.GetPerson(item);
|
||||||
|
|
||||||
hints.Add(new Tuple<BaseItem, string, int>(person, index.Item1, index.Item2));
|
hints.Add(new Tuple<BaseItem, string, int>(person, index.Item1, index.Item2));
|
||||||
}
|
}
|
||||||
|
@ -283,11 +283,13 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return hints.Where(i => i.Item3 >= 0).OrderBy(i => i.Item3).Select(i => new SearchHintInfo
|
var returnValue = hints.Where(i => i.Item3 >= 0).OrderBy(i => i.Item3).Select(i => new SearchHintInfo
|
||||||
{
|
{
|
||||||
Item = i.Item1,
|
Item = i.Item1,
|
||||||
MatchedTerm = i.Item2
|
MatchedTerm = i.Item2
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return Task.FromResult(returnValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -24,7 +24,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The _library manager
|
/// The _library manager
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly LibraryManager _libraryManager;
|
private readonly ILibraryManager _libraryManager;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The _user manager
|
/// The _user manager
|
||||||
|
@ -42,7 +42,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||||
/// <param name="libraryManager">The library manager.</param>
|
/// <param name="libraryManager">The library manager.</param>
|
||||||
/// <param name="userManager">The user manager.</param>
|
/// <param name="userManager">The user manager.</param>
|
||||||
/// <param name="logger">The logger.</param>
|
/// <param name="logger">The logger.</param>
|
||||||
public ArtistsValidator(LibraryManager libraryManager, IUserManager userManager, ILogger logger)
|
public ArtistsValidator(ILibraryManager libraryManager, IUserManager userManager, ILogger logger)
|
||||||
{
|
{
|
||||||
_libraryManager = libraryManager;
|
_libraryManager = libraryManager;
|
||||||
_userManager = userManager;
|
_userManager = userManager;
|
||||||
|
@ -230,8 +230,9 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var artistItem = await _libraryManager.GetArtist(currentArtist, cancellationToken, true, true)
|
var artistItem = _libraryManager.GetArtist(currentArtist);
|
||||||
.ConfigureAwait(false);
|
|
||||||
|
await artistItem.RefreshMetadata(cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
returnArtists.Add(artistItem);
|
returnArtists.Add(artistItem);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The _library manager
|
/// The _library manager
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly LibraryManager _libraryManager;
|
private readonly ILibraryManager _libraryManager;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The _user manager
|
/// The _user manager
|
||||||
|
@ -26,7 +26,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
public GameGenresValidator(LibraryManager libraryManager, IUserManager userManager, ILogger logger)
|
public GameGenresValidator(ILibraryManager libraryManager, IUserManager userManager, ILogger logger)
|
||||||
{
|
{
|
||||||
_libraryManager = libraryManager;
|
_libraryManager = libraryManager;
|
||||||
_userManager = userManager;
|
_userManager = userManager;
|
||||||
|
@ -47,8 +47,6 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||||
.Select(i => new Tuple<Guid, List<Game>>(i.Id, i.RootFolder.GetRecursiveChildren(i).OfType<Game>().ToList()))
|
.Select(i => new Tuple<Guid, List<Game>>(i.Id, i.RootFolder.GetRecursiveChildren(i).OfType<Game>().ToList()))
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
var allLibraryItems = allItems;
|
|
||||||
|
|
||||||
var masterDictionary = new Dictionary<string, Dictionary<Guid, Dictionary<CountType, int>>>(StringComparer.OrdinalIgnoreCase);
|
var masterDictionary = new Dictionary<string, Dictionary<Guid, Dictionary<CountType, int>>>(StringComparer.OrdinalIgnoreCase);
|
||||||
|
|
||||||
// Populate counts of items
|
// Populate counts of items
|
||||||
|
@ -99,7 +97,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||||
|
|
||||||
private async Task UpdateItemByNameCounts(string name, CancellationToken cancellationToken, Dictionary<Guid, Dictionary<CountType, int>> counts)
|
private async Task UpdateItemByNameCounts(string name, CancellationToken cancellationToken, Dictionary<Guid, Dictionary<CountType, int>> counts)
|
||||||
{
|
{
|
||||||
var itemByName = await _libraryManager.GetGameGenre(name, cancellationToken, true, true).ConfigureAwait(false);
|
var itemByName = _libraryManager.GetGameGenre(name);
|
||||||
|
|
||||||
foreach (var libraryId in counts.Keys)
|
foreach (var libraryId in counts.Keys)
|
||||||
{
|
{
|
||||||
|
@ -107,6 +105,8 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||||
|
|
||||||
itemByName.UserItemCounts[libraryId] = itemCounts;
|
itemByName.UserItemCounts[libraryId] = itemCounts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await itemByName.RefreshMetadata(cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetItemCounts(Guid userId, IEnumerable<BaseItem> allItems, Dictionary<string, Dictionary<Guid, Dictionary<CountType, int>>> masterDictionary)
|
private void SetItemCounts(Guid userId, IEnumerable<BaseItem> allItems, Dictionary<string, Dictionary<Guid, Dictionary<CountType, int>>> masterDictionary)
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The _library manager
|
/// The _library manager
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly LibraryManager _libraryManager;
|
private readonly ILibraryManager _libraryManager;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The _user manager
|
/// The _user manager
|
||||||
|
@ -27,7 +27,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
public GenresValidator(LibraryManager libraryManager, IUserManager userManager, ILogger logger)
|
public GenresValidator(ILibraryManager libraryManager, IUserManager userManager, ILogger logger)
|
||||||
{
|
{
|
||||||
_libraryManager = libraryManager;
|
_libraryManager = libraryManager;
|
||||||
_userManager = userManager;
|
_userManager = userManager;
|
||||||
|
@ -102,7 +102,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||||
|
|
||||||
private async Task UpdateItemByNameCounts(string name, CancellationToken cancellationToken, Dictionary<Guid, Dictionary<CountType, int>> counts)
|
private async Task UpdateItemByNameCounts(string name, CancellationToken cancellationToken, Dictionary<Guid, Dictionary<CountType, int>> counts)
|
||||||
{
|
{
|
||||||
var itemByName = await _libraryManager.GetGenre(name, cancellationToken, true, true).ConfigureAwait(false);
|
var itemByName = _libraryManager.GetGenre(name);
|
||||||
|
|
||||||
foreach (var libraryId in counts.Keys)
|
foreach (var libraryId in counts.Keys)
|
||||||
{
|
{
|
||||||
|
@ -110,6 +110,8 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||||
|
|
||||||
itemByName.UserItemCounts[libraryId] = itemCounts;
|
itemByName.UserItemCounts[libraryId] = itemCounts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await itemByName.RefreshMetadata(cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetItemCounts(Guid userId, IEnumerable<BaseItem> allItems, Dictionary<string, Dictionary<Guid, Dictionary<CountType, int>>> masterDictionary)
|
private void SetItemCounts(Guid userId, IEnumerable<BaseItem> allItems, Dictionary<string, Dictionary<Guid, Dictionary<CountType, int>>> masterDictionary)
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The _library manager
|
/// The _library manager
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly LibraryManager _libraryManager;
|
private readonly ILibraryManager _libraryManager;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The _user manager
|
/// The _user manager
|
||||||
|
@ -27,7 +27,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
public MusicGenresValidator(LibraryManager libraryManager, IUserManager userManager, ILogger logger)
|
public MusicGenresValidator(ILibraryManager libraryManager, IUserManager userManager, ILogger logger)
|
||||||
{
|
{
|
||||||
_libraryManager = libraryManager;
|
_libraryManager = libraryManager;
|
||||||
_userManager = userManager;
|
_userManager = userManager;
|
||||||
|
@ -102,7 +102,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||||
|
|
||||||
private async Task UpdateItemByNameCounts(string name, CancellationToken cancellationToken, Dictionary<Guid, Dictionary<CountType, int>> counts)
|
private async Task UpdateItemByNameCounts(string name, CancellationToken cancellationToken, Dictionary<Guid, Dictionary<CountType, int>> counts)
|
||||||
{
|
{
|
||||||
var itemByName = await _libraryManager.GetMusicGenre(name, cancellationToken, true, true).ConfigureAwait(false);
|
var itemByName = _libraryManager.GetMusicGenre(name);
|
||||||
|
|
||||||
foreach (var libraryId in counts.Keys)
|
foreach (var libraryId in counts.Keys)
|
||||||
{
|
{
|
||||||
|
@ -110,6 +110,8 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||||
|
|
||||||
itemByName.UserItemCounts[libraryId] = itemCounts;
|
itemByName.UserItemCounts[libraryId] = itemCounts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await itemByName.RefreshMetadata(cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetItemCounts(Guid userId, IEnumerable<BaseItem> allItems, Dictionary<string, Dictionary<Guid, Dictionary<CountType, int>>> masterDictionary)
|
private void SetItemCounts(Guid userId, IEnumerable<BaseItem> allItems, Dictionary<string, Dictionary<Guid, Dictionary<CountType, int>>> masterDictionary)
|
||||||
|
|
|
@ -41,11 +41,10 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||||
/// <returns>Task.</returns>
|
/// <returns>Task.</returns>
|
||||||
public Task Run(IProgress<double> progress, CancellationToken cancellationToken)
|
public Task Run(IProgress<double> progress, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
return RunInternal(progress, cancellationToken);
|
return Task.Run(() => RunInternal(progress, cancellationToken));
|
||||||
//return Task.Run(() => RunInternal(progress, cancellationToken));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task RunInternal(IProgress<double> progress, CancellationToken cancellationToken)
|
private void RunInternal(IProgress<double> progress, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var allItems = _libraryManager.RootFolder.RecursiveChildren.ToList();
|
var allItems = _libraryManager.RootFolder.RecursiveChildren.ToList();
|
||||||
|
|
||||||
|
@ -91,7 +90,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||||
{
|
{
|
||||||
var counts = masterDictionary[name];
|
var counts = masterDictionary[name];
|
||||||
|
|
||||||
var itemByName = await _libraryManager.GetPerson(name).ConfigureAwait(false);
|
var itemByName = _libraryManager.GetPerson(name);
|
||||||
|
|
||||||
foreach (var libraryId in counts.Keys)
|
foreach (var libraryId in counts.Keys)
|
||||||
{
|
{
|
||||||
|
|
|
@ -14,7 +14,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The _library manager
|
/// The _library manager
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly LibraryManager _libraryManager;
|
private readonly ILibraryManager _libraryManager;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The _user manager
|
/// The _user manager
|
||||||
|
@ -26,7 +26,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
public StudiosValidator(LibraryManager libraryManager, IUserManager userManager, ILogger logger)
|
public StudiosValidator(ILibraryManager libraryManager, IUserManager userManager, ILogger logger)
|
||||||
{
|
{
|
||||||
_libraryManager = libraryManager;
|
_libraryManager = libraryManager;
|
||||||
_userManager = userManager;
|
_userManager = userManager;
|
||||||
|
@ -99,7 +99,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||||
|
|
||||||
private async Task UpdateItemByNameCounts(string name, CancellationToken cancellationToken, Dictionary<Guid, Dictionary<CountType, int>> counts)
|
private async Task UpdateItemByNameCounts(string name, CancellationToken cancellationToken, Dictionary<Guid, Dictionary<CountType, int>> counts)
|
||||||
{
|
{
|
||||||
var itemByName = await _libraryManager.GetStudio(name, cancellationToken, true, true).ConfigureAwait(false);
|
var itemByName = _libraryManager.GetStudio(name);
|
||||||
|
|
||||||
foreach (var libraryId in counts.Keys)
|
foreach (var libraryId in counts.Keys)
|
||||||
{
|
{
|
||||||
|
@ -107,6 +107,8 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||||
|
|
||||||
itemByName.UserItemCounts[libraryId] = itemCounts;
|
itemByName.UserItemCounts[libraryId] = itemCounts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await itemByName.RefreshMetadata(cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetItemCounts(Guid userId, IEnumerable<BaseItem> allItems, Dictionary<string, Dictionary<Guid, Dictionary<CountType, int>>> masterDictionary)
|
private void SetItemCounts(Guid userId, IEnumerable<BaseItem> allItems, Dictionary<string, Dictionary<Guid, Dictionary<CountType, int>>> masterDictionary)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user