diff --git a/MediaBrowser.Api/Images/ImageService.cs b/MediaBrowser.Api/Images/ImageService.cs index 07bbaff74..1f69183cc 100644 --- a/MediaBrowser.Api/Images/ImageService.cs +++ b/MediaBrowser.Api/Images/ImageService.cs @@ -293,7 +293,7 @@ namespace MediaBrowser.Api.Images if (string.IsNullOrEmpty(imagePath)) { - throw new ResourceNotFoundException(); + throw new ResourceNotFoundException(string.Format("{0} does not have an image of type {1}", item.Name, request.Type)); } // See if we can avoid a file system lookup by looking for the file in ResolveArgs diff --git a/MediaBrowser.Controller/Dto/DtoBuilder.cs b/MediaBrowser.Controller/Dto/DtoBuilder.cs index 0c47013bf..84f9f8827 100644 --- a/MediaBrowser.Controller/Dto/DtoBuilder.cs +++ b/MediaBrowser.Controller/Dto/DtoBuilder.cs @@ -566,29 +566,33 @@ namespace MediaBrowser.Controller.Dto return; } - // Attach People by transforming them into BaseItemPerson (DTO) - dto.People = new BaseItemPerson[item.People.Count]; - // 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 should be improved in the future - var entities = await Task.WhenAll(item.People.OrderBy(i => i.Type).Select(c => + var people = item.People.OrderBy(i => i.Type).ToList(); + + // Attach People by transforming them into BaseItemPerson (DTO) + dto.People = new BaseItemPerson[people.Count]; + + var entities = await Task.WhenAll(people.Select(p => p.Name).Distinct(StringComparer.OrdinalIgnoreCase).Select(c => Task.Run(async () => { try { - return await _libraryManager.GetPerson(c.Name).ConfigureAwait(false); + return await _libraryManager.GetPerson(c).ConfigureAwait(false); } catch (IOException ex) { - _logger.ErrorException("Error getting person {0}", ex, c.Name); + _logger.ErrorException("Error getting person {0}", ex, c); return null; } }) )).ConfigureAwait(false); + var dictionary = entities.ToDictionary(i => i.Name, StringComparer.OrdinalIgnoreCase); + for (var i = 0; i < item.People.Count; i++) { var person = item.People[i]; @@ -600,15 +604,15 @@ namespace MediaBrowser.Controller.Dto Type = person.Type }; - var ibnObject = entities[i]; + Person entity; - if (ibnObject != null) + if (dictionary.TryGetValue(person.Name, out entity)) { - var primaryImagePath = ibnObject.PrimaryImagePath; + var primaryImagePath = entity.PrimaryImagePath; if (!string.IsNullOrEmpty(primaryImagePath)) { - baseItemPerson.PrimaryImageTag = Kernel.Instance.ImageManager.GetImageCacheTag(ibnObject, ImageType.Primary, primaryImagePath); + baseItemPerson.PrimaryImageTag = Kernel.Instance.ImageManager.GetImageCacheTag(entity, ImageType.Primary, primaryImagePath); } } diff --git a/MediaBrowser.Server.Implementations/Providers/ProviderManager.cs b/MediaBrowser.Server.Implementations/Providers/ProviderManager.cs index ff7222e7c..58bb232a2 100644 --- a/MediaBrowser.Server.Implementations/Providers/ProviderManager.cs +++ b/MediaBrowser.Server.Implementations/Providers/ProviderManager.cs @@ -237,7 +237,7 @@ namespace MediaBrowser.Server.Implementations.Providers } catch (OperationCanceledException ex) { - _logger.Debug("{0} cancelled for {1}", provider.GetType().Name, item.Name); + _logger.Debug("{0} canceled for {1}", provider.GetType().Name, item.Name); // If the outer cancellation token is the one that caused the cancellation, throw it if (cancellationToken.IsCancellationRequested && ex.CancellationToken == cancellationToken)