made dtoservice synchronous
This commit is contained in:
parent
1007f24200
commit
85d7eb917f
|
@ -101,12 +101,12 @@ namespace MediaBrowser.Api.DefaultTheme
|
|||
var eligibleSpotlightItems = itemsWithBackdrops
|
||||
.Where(i => i is Game || i is Movie || i is Series || i is MusicArtist);
|
||||
|
||||
var spotlightItemTasks = FilterItemsForBackdropDisplay(eligibleSpotlightItems)
|
||||
var dtos = FilterItemsForBackdropDisplay(eligibleSpotlightItems)
|
||||
.OrderBy(i => Guid.NewGuid())
|
||||
.Take(50)
|
||||
.Select(i => _dtoService.GetBaseItemDto(i, fields, user));
|
||||
|
||||
view.SpotlightItems = await Task.WhenAll(spotlightItemTasks).ConfigureAwait(false);
|
||||
view.SpotlightItems = dtos.ToArray();
|
||||
|
||||
return view;
|
||||
}
|
||||
|
@ -132,13 +132,13 @@ namespace MediaBrowser.Api.DefaultTheme
|
|||
|
||||
var fields = new List<ItemFields>();
|
||||
|
||||
var spotlightItemTasks = itemsWithBackdrops
|
||||
var dtos = itemsWithBackdrops
|
||||
.OfType<Game>()
|
||||
.OrderBy(i => Guid.NewGuid())
|
||||
.Take(50)
|
||||
.Select(i => _dtoService.GetBaseItemDto(i, fields, user));
|
||||
|
||||
view.SpotlightItems = await Task.WhenAll(spotlightItemTasks).ConfigureAwait(false);
|
||||
view.SpotlightItems = dtos.ToArray();
|
||||
|
||||
return view;
|
||||
}
|
||||
|
@ -171,12 +171,12 @@ namespace MediaBrowser.Api.DefaultTheme
|
|||
|
||||
var fields = new List<ItemFields>();
|
||||
|
||||
var spotlightItemTasks = FilterItemsForBackdropDisplay(seriesWithBackdrops)
|
||||
var dtos = FilterItemsForBackdropDisplay(seriesWithBackdrops)
|
||||
.OrderBy(i => Guid.NewGuid())
|
||||
.Take(50)
|
||||
.Select(i => _dtoService.GetBaseItemDto(i, fields, user));
|
||||
|
||||
view.SpotlightItems = await Task.WhenAll(spotlightItemTasks).ConfigureAwait(false);
|
||||
view.SpotlightItems = dtos.ToArray();
|
||||
|
||||
view.ShowsItems = series
|
||||
.Where(i => i.BackdropImagePaths.Count > 0)
|
||||
|
@ -245,12 +245,12 @@ namespace MediaBrowser.Api.DefaultTheme
|
|||
|
||||
var fields = new List<ItemFields>();
|
||||
|
||||
var spotlightItemTasks = FilterItemsForBackdropDisplay(itemsWithBackdrops)
|
||||
var dtos = FilterItemsForBackdropDisplay(itemsWithBackdrops)
|
||||
.OrderBy(i => Guid.NewGuid())
|
||||
.Take(50)
|
||||
.Select(i => _dtoService.GetBaseItemDto(i, fields, user));
|
||||
|
||||
view.SpotlightItems = await Task.WhenAll(spotlightItemTasks).ConfigureAwait(false);
|
||||
view.SpotlightItems = dtos.ToArray();
|
||||
|
||||
view.MovieItems = moviesWithBackdrops
|
||||
.OrderBy(i => Guid.NewGuid())
|
||||
|
@ -350,7 +350,7 @@ namespace MediaBrowser.Api.DefaultTheme
|
|||
{
|
||||
var date = Kernel.Instance.ImageManager.GetImageDateModified(item, path);
|
||||
|
||||
var size = Kernel.Instance.ImageManager.GetImageSize(path, date).Result;
|
||||
var size = Kernel.Instance.ImageManager.GetImageSize(path, date);
|
||||
|
||||
return size.Width;
|
||||
}
|
||||
|
|
|
@ -361,14 +361,14 @@ namespace MediaBrowser.Api.Images
|
|||
{
|
||||
var item = _dtoService.GetItemByDtoId(request.Id);
|
||||
|
||||
var result = GetItemImageInfos(item).Result;
|
||||
var result = GetItemImageInfos(item);
|
||||
|
||||
return ToOptimizedResult(result);
|
||||
}
|
||||
|
||||
public object Get(GetItemByNameImageInfos request)
|
||||
{
|
||||
var result = GetItemByNameImageInfos(request).Result;
|
||||
var result = GetItemByNameImageInfos(request);
|
||||
|
||||
return ToOptimizedResult(result);
|
||||
}
|
||||
|
@ -378,7 +378,7 @@ namespace MediaBrowser.Api.Images
|
|||
/// </summary>
|
||||
/// <param name="request">The request.</param>
|
||||
/// <returns>Task{List{ImageInfo}}.</returns>
|
||||
public Task<List<ImageInfo>> GetItemByNameImageInfos(GetItemByNameImageInfos request)
|
||||
private List<ImageInfo> GetItemByNameImageInfos(GetItemByNameImageInfos request)
|
||||
{
|
||||
var pathInfo = PathInfo.Parse(RequestContext.PathInfo);
|
||||
var type = pathInfo.GetArgumentValue<string>(0);
|
||||
|
@ -393,7 +393,7 @@ namespace MediaBrowser.Api.Images
|
|||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <returns>Task{List{ImageInfo}}.</returns>
|
||||
public async Task<List<ImageInfo>> GetItemImageInfos(BaseItem item)
|
||||
public List<ImageInfo> GetItemImageInfos(BaseItem item)
|
||||
{
|
||||
var list = new List<ImageInfo>();
|
||||
|
||||
|
@ -405,7 +405,7 @@ namespace MediaBrowser.Api.Images
|
|||
|
||||
var dateModified = Kernel.Instance.ImageManager.GetImageDateModified(item, path);
|
||||
|
||||
var size = await Kernel.Instance.ImageManager.GetImageSize(path, dateModified).ConfigureAwait(false);
|
||||
var size = Kernel.Instance.ImageManager.GetImageSize(path, dateModified);
|
||||
|
||||
list.Add(new ImageInfo
|
||||
{
|
||||
|
@ -426,7 +426,7 @@ namespace MediaBrowser.Api.Images
|
|||
|
||||
var dateModified = Kernel.Instance.ImageManager.GetImageDateModified(item, image);
|
||||
|
||||
var size = await Kernel.Instance.ImageManager.GetImageSize(image, dateModified).ConfigureAwait(false);
|
||||
var size = Kernel.Instance.ImageManager.GetImageSize(image, dateModified);
|
||||
|
||||
list.Add(new ImageInfo
|
||||
{
|
||||
|
@ -450,7 +450,7 @@ namespace MediaBrowser.Api.Images
|
|||
|
||||
var dateModified = Kernel.Instance.ImageManager.GetImageDateModified(item, image);
|
||||
|
||||
var size = await Kernel.Instance.ImageManager.GetImageSize(image, dateModified).ConfigureAwait(false);
|
||||
var size = Kernel.Instance.ImageManager.GetImageSize(image, dateModified);
|
||||
|
||||
list.Add(new ImageInfo
|
||||
{
|
||||
|
@ -482,7 +482,7 @@ namespace MediaBrowser.Api.Images
|
|||
|
||||
var dateModified = Kernel.Instance.ImageManager.GetImageDateModified(item, image);
|
||||
|
||||
var size = await Kernel.Instance.ImageManager.GetImageSize(image, dateModified).ConfigureAwait(false);
|
||||
var size = Kernel.Instance.ImageManager.GetImageSize(image, dateModified);
|
||||
|
||||
list.Add(new ImageInfo
|
||||
{
|
||||
|
|
|
@ -6,7 +6,6 @@ using ServiceStack.ServiceHost;
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MediaBrowser.Api
|
||||
{
|
||||
|
@ -56,7 +55,7 @@ namespace MediaBrowser.Api
|
|||
{
|
||||
var item = _dtoService.GetItemByDtoId(request.Id);
|
||||
|
||||
var result = GetInstantMixResult(request, item.Genres).Result;
|
||||
var result = GetInstantMixResult(request, item.Genres);
|
||||
|
||||
return ToOptimizedResult(result);
|
||||
}
|
||||
|
@ -72,7 +71,7 @@ namespace MediaBrowser.Api
|
|||
.Concat(album.Genres)
|
||||
.Distinct(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
var result = GetInstantMixResult(request, genres).Result;
|
||||
var result = GetInstantMixResult(request, genres);
|
||||
|
||||
return ToOptimizedResult(result);
|
||||
}
|
||||
|
@ -81,7 +80,7 @@ namespace MediaBrowser.Api
|
|||
{
|
||||
var genre = GetMusicGenre(request.Name, _libraryManager);
|
||||
|
||||
var result = GetInstantMixResult(request, new[] { genre.Name }).Result;
|
||||
var result = GetInstantMixResult(request, new[] { genre.Name });
|
||||
|
||||
return ToOptimizedResult(result);
|
||||
}
|
||||
|
@ -98,12 +97,12 @@ namespace MediaBrowser.Api
|
|||
.Concat(artist.Genres)
|
||||
.Distinct(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
var result = GetInstantMixResult(request, genres).Result;
|
||||
var result = GetInstantMixResult(request, genres);
|
||||
|
||||
return ToOptimizedResult(result);
|
||||
}
|
||||
|
||||
private async Task<ItemsResult> GetInstantMixResult(BaseGetSimilarItems request, IEnumerable<string> genres)
|
||||
private ItemsResult GetInstantMixResult(BaseGetSimilarItems request, IEnumerable<string> genres)
|
||||
{
|
||||
var user = request.UserId.HasValue ? _userManager.GetUserById(request.UserId.Value) : null;
|
||||
|
||||
|
@ -132,10 +131,10 @@ namespace MediaBrowser.Api
|
|||
TotalRecordCount = items.Length
|
||||
};
|
||||
|
||||
var tasks = items.Take(request.Limit ?? items.Length)
|
||||
var dtos = items.Take(request.Limit ?? items.Length)
|
||||
.Select(i => _dtoService.GetBaseItemDto(i, fields, user));
|
||||
|
||||
result.Items = await Task.WhenAll(tasks).ConfigureAwait(false);
|
||||
result.Items = dtos.ToArray();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -225,7 +225,7 @@ namespace MediaBrowser.Api
|
|||
/// <returns>System.Object.</returns>
|
||||
public object Get(GetAncestors request)
|
||||
{
|
||||
var result = GetAncestors(request).Result;
|
||||
var result = GetAncestors(request);
|
||||
|
||||
return ToOptimizedResult(result);
|
||||
}
|
||||
|
@ -235,11 +235,11 @@ namespace MediaBrowser.Api
|
|||
/// </summary>
|
||||
/// <param name="request">The request.</param>
|
||||
/// <returns>Task{BaseItemDto[]}.</returns>
|
||||
public async Task<BaseItemDto[]> GetAncestors(GetAncestors request)
|
||||
public BaseItemDto[] GetAncestors(GetAncestors request)
|
||||
{
|
||||
var item = _dtoService.GetItemByDtoId(request.Id);
|
||||
|
||||
var tasks = new List<Task<BaseItemDto>>();
|
||||
var baseItemDtos = new List<BaseItemDto>();
|
||||
|
||||
var user = request.UserId.HasValue ? _userManager.GetUserById(request.UserId.Value) : null;
|
||||
|
||||
|
@ -257,7 +257,7 @@ namespace MediaBrowser.Api
|
|||
parent = TranslateParentItem(parent, user);
|
||||
}
|
||||
|
||||
tasks.Add(_dtoService.GetBaseItemDto(parent, fields, user));
|
||||
baseItemDtos.Add(_dtoService.GetBaseItemDto(parent, fields, user));
|
||||
|
||||
if (parent is UserRootFolder)
|
||||
{
|
||||
|
@ -267,7 +267,7 @@ namespace MediaBrowser.Api
|
|||
parent = parent.Parent;
|
||||
}
|
||||
|
||||
return await Task.WhenAll(tasks).ConfigureAwait(false);
|
||||
return baseItemDtos.ToArray();
|
||||
}
|
||||
|
||||
private BaseItem TranslateParentItem(BaseItem item, User user)
|
||||
|
@ -512,11 +512,11 @@ namespace MediaBrowser.Api
|
|||
.Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true))
|
||||
.ToList();
|
||||
|
||||
var tasks = item.ThemeSongIds.Select(_itemRepo.RetrieveItem)
|
||||
var dtos = item.ThemeSongIds.Select(_itemRepo.RetrieveItem)
|
||||
.OrderBy(i => i.SortName)
|
||||
.Select(i => _dtoService.GetBaseItemDto(i, fields, user, item));
|
||||
|
||||
var items = await Task.WhenAll(tasks).ConfigureAwait(false);
|
||||
var items = dtos.ToArray();
|
||||
|
||||
return new ThemeMediaResult
|
||||
{
|
||||
|
@ -559,11 +559,11 @@ namespace MediaBrowser.Api
|
|||
.Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true))
|
||||
.ToList();
|
||||
|
||||
var tasks = item.ThemeVideoIds.Select(_itemRepo.RetrieveItem)
|
||||
var dtos = item.ThemeVideoIds.Select(_itemRepo.RetrieveItem)
|
||||
.OrderBy(i => i.SortName)
|
||||
.Select(i => _dtoService.GetBaseItemDto(i, fields, user, item));
|
||||
|
||||
var items = await Task.WhenAll(tasks).ConfigureAwait(false);
|
||||
var items = dtos.ToArray();
|
||||
|
||||
return new ThemeMediaResult
|
||||
{
|
||||
|
|
|
@ -74,7 +74,7 @@ namespace MediaBrowser.Api
|
|||
}).Where(i => i.HasValue).Select(i => i.Value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Class SimilarItemsHelper
|
||||
/// </summary>
|
||||
|
@ -112,7 +112,7 @@ namespace MediaBrowser.Api
|
|||
|
||||
var result = new ItemsResult
|
||||
{
|
||||
Items = items.Take(request.Limit ?? items.Length).Select(i => dtoService.GetBaseItemDto(i, fields, user)).Select(t => t.Result).ToArray(),
|
||||
Items = items.Take(request.Limit ?? items.Length).Select(i => dtoService.GetBaseItemDto(i, fields, user)).ToArray(),
|
||||
|
||||
TotalRecordCount = items.Length
|
||||
};
|
||||
|
|
|
@ -191,7 +191,7 @@ namespace MediaBrowser.Api
|
|||
|
||||
var fields = request.GetItemFields().ToList();
|
||||
|
||||
var returnItems = await GetItemDtos(pagedItems, user, fields).ConfigureAwait(false);
|
||||
var returnItems = pagedItems.Select(i => _dtoService.GetBaseItemDto(i, fields, user)).ToArray();
|
||||
|
||||
return new ItemsResult
|
||||
{
|
||||
|
@ -247,18 +247,6 @@ namespace MediaBrowser.Api
|
|||
return new Tuple<Episode, DateTime>(null, lastWatchedDate);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the item dtos.
|
||||
/// </summary>
|
||||
/// <param name="pagedItems">The paged items.</param>
|
||||
/// <param name="user">The user.</param>
|
||||
/// <param name="fields">The fields.</param>
|
||||
/// <returns>Task.</returns>
|
||||
private Task<BaseItemDto[]> GetItemDtos(IEnumerable<BaseItem> pagedItems, User user, List<ItemFields> fields)
|
||||
{
|
||||
return Task.WhenAll(pagedItems.Select(i => _dtoService.GetBaseItemDto(i, fields, user)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Applies the paging.
|
||||
/// </summary>
|
||||
|
|
|
@ -9,7 +9,6 @@ using ServiceStack.ServiceHost;
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MediaBrowser.Api.UserLibrary
|
||||
{
|
||||
|
@ -65,7 +64,7 @@ namespace MediaBrowser.Api.UserLibrary
|
|||
/// <returns>System.Object.</returns>
|
||||
public object Get(GetArtist request)
|
||||
{
|
||||
var result = GetItem(request).Result;
|
||||
var result = GetItem(request);
|
||||
|
||||
return ToOptimizedResult(result);
|
||||
}
|
||||
|
@ -75,7 +74,7 @@ namespace MediaBrowser.Api.UserLibrary
|
|||
/// </summary>
|
||||
/// <param name="request">The request.</param>
|
||||
/// <returns>Task{BaseItemDto}.</returns>
|
||||
private async Task<BaseItemDto> GetItem(GetArtist request)
|
||||
private BaseItemDto GetItem(GetArtist request)
|
||||
{
|
||||
var item = GetArtist(request.Name, LibraryManager);
|
||||
|
||||
|
@ -86,10 +85,10 @@ namespace MediaBrowser.Api.UserLibrary
|
|||
{
|
||||
var user = UserManager.GetUserById(request.UserId.Value);
|
||||
|
||||
return await DtoService.GetBaseItemDto(item, fields.ToList(), user).ConfigureAwait(false);
|
||||
return DtoService.GetBaseItemDto(item, fields.ToList(), user);
|
||||
}
|
||||
|
||||
return await DtoService.GetBaseItemDto(item, fields.ToList()).ConfigureAwait(false);
|
||||
return DtoService.GetBaseItemDto(item, fields.ToList());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -121,11 +121,9 @@ namespace MediaBrowser.Api.UserLibrary
|
|||
|
||||
var fields = request.GetItemFields().ToList();
|
||||
|
||||
var tasks = ibnItems.Select(i => GetDto(i, user, fields));
|
||||
var dtos = ibnItems.Select(i => GetDto(i, user, fields));
|
||||
|
||||
var resultItems = await Task.WhenAll(tasks).ConfigureAwait(false);
|
||||
|
||||
result.Items = resultItems.Where(i => i != null).ToArray();
|
||||
result.Items = dtos.Where(i => i != null).ToArray();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -253,10 +251,10 @@ namespace MediaBrowser.Api.UserLibrary
|
|||
/// <param name="user">The user.</param>
|
||||
/// <param name="fields">The fields.</param>
|
||||
/// <returns>Task{DtoBaseItem}.</returns>
|
||||
private async Task<BaseItemDto> GetDto(TItemType item, User user, List<ItemFields> fields)
|
||||
private BaseItemDto GetDto(TItemType item, User user, List<ItemFields> fields)
|
||||
{
|
||||
var dto = user == null ? await DtoService.GetBaseItemDto(item, fields).ConfigureAwait(false) :
|
||||
await DtoService.GetBaseItemDto(item, fields, user).ConfigureAwait(false);
|
||||
var dto = user == null ? DtoService.GetBaseItemDto(item, fields) :
|
||||
DtoService.GetBaseItemDto(item, fields, user);
|
||||
|
||||
return dto;
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ using ServiceStack.ServiceHost;
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MediaBrowser.Api.UserLibrary
|
||||
{
|
||||
|
@ -56,7 +55,7 @@ namespace MediaBrowser.Api.UserLibrary
|
|||
/// <returns>System.Object.</returns>
|
||||
public object Get(GetGameGenre request)
|
||||
{
|
||||
var result = GetItem(request).Result;
|
||||
var result = GetItem(request);
|
||||
|
||||
return ToOptimizedResult(result);
|
||||
}
|
||||
|
@ -66,7 +65,7 @@ namespace MediaBrowser.Api.UserLibrary
|
|||
/// </summary>
|
||||
/// <param name="request">The request.</param>
|
||||
/// <returns>Task{BaseItemDto}.</returns>
|
||||
private async Task<BaseItemDto> GetItem(GetGameGenre request)
|
||||
private BaseItemDto GetItem(GetGameGenre request)
|
||||
{
|
||||
var item = GetGameGenre(request.Name, LibraryManager);
|
||||
|
||||
|
@ -77,10 +76,10 @@ namespace MediaBrowser.Api.UserLibrary
|
|||
{
|
||||
var user = UserManager.GetUserById(request.UserId.Value);
|
||||
|
||||
return await DtoService.GetBaseItemDto(item, fields.ToList(), user).ConfigureAwait(false);
|
||||
return DtoService.GetBaseItemDto(item, fields.ToList(), user);
|
||||
}
|
||||
|
||||
return await DtoService.GetBaseItemDto(item, fields.ToList()).ConfigureAwait(false);
|
||||
return DtoService.GetBaseItemDto(item, fields.ToList());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -8,7 +8,6 @@ using ServiceStack.ServiceHost;
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MediaBrowser.Api.UserLibrary
|
||||
{
|
||||
|
@ -60,7 +59,7 @@ namespace MediaBrowser.Api.UserLibrary
|
|||
/// <returns>System.Object.</returns>
|
||||
public object Get(GetGenre request)
|
||||
{
|
||||
var result = GetItem(request).Result;
|
||||
var result = GetItem(request);
|
||||
|
||||
return ToOptimizedResult(result);
|
||||
}
|
||||
|
@ -70,7 +69,7 @@ namespace MediaBrowser.Api.UserLibrary
|
|||
/// </summary>
|
||||
/// <param name="request">The request.</param>
|
||||
/// <returns>Task{BaseItemDto}.</returns>
|
||||
private async Task<BaseItemDto> GetItem(GetGenre request)
|
||||
private BaseItemDto GetItem(GetGenre request)
|
||||
{
|
||||
var item = GetGenre(request.Name, LibraryManager);
|
||||
|
||||
|
@ -81,10 +80,10 @@ namespace MediaBrowser.Api.UserLibrary
|
|||
{
|
||||
var user = UserManager.GetUserById(request.UserId.Value);
|
||||
|
||||
return await DtoService.GetBaseItemDto(item, fields.ToList(), user).ConfigureAwait(false);
|
||||
return DtoService.GetBaseItemDto(item, fields.ToList(), user);
|
||||
}
|
||||
|
||||
return await DtoService.GetBaseItemDto(item, fields.ToList()).ConfigureAwait(false);
|
||||
return DtoService.GetBaseItemDto(item, fields.ToList());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -260,7 +260,7 @@ namespace MediaBrowser.Api.UserLibrary
|
|||
|
||||
var fields = request.GetItemFields().ToList();
|
||||
|
||||
var returnItems = await Task.WhenAll(pagedItems.Select(i => _dtoService.GetBaseItemDto(i, fields, user))).ConfigureAwait(false);
|
||||
var returnItems = pagedItems.Select(i => _dtoService.GetBaseItemDto(i, fields, user)).ToArray();
|
||||
|
||||
return new ItemsResult
|
||||
{
|
||||
|
|
|
@ -9,7 +9,6 @@ using ServiceStack.ServiceHost;
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MediaBrowser.Api.UserLibrary
|
||||
{
|
||||
|
@ -56,7 +55,7 @@ namespace MediaBrowser.Api.UserLibrary
|
|||
/// <returns>System.Object.</returns>
|
||||
public object Get(GetMusicGenre request)
|
||||
{
|
||||
var result = GetItem(request).Result;
|
||||
var result = GetItem(request);
|
||||
|
||||
return ToOptimizedResult(result);
|
||||
}
|
||||
|
@ -66,7 +65,7 @@ namespace MediaBrowser.Api.UserLibrary
|
|||
/// </summary>
|
||||
/// <param name="request">The request.</param>
|
||||
/// <returns>Task{BaseItemDto}.</returns>
|
||||
private async Task<BaseItemDto> GetItem(GetMusicGenre request)
|
||||
private BaseItemDto GetItem(GetMusicGenre request)
|
||||
{
|
||||
var item = GetMusicGenre(request.Name, LibraryManager);
|
||||
|
||||
|
@ -77,10 +76,10 @@ namespace MediaBrowser.Api.UserLibrary
|
|||
{
|
||||
var user = UserManager.GetUserById(request.UserId.Value);
|
||||
|
||||
return await DtoService.GetBaseItemDto(item, fields.ToList(), user).ConfigureAwait(false);
|
||||
return DtoService.GetBaseItemDto(item, fields.ToList(), user);
|
||||
}
|
||||
|
||||
return await DtoService.GetBaseItemDto(item, fields.ToList()).ConfigureAwait(false);
|
||||
return DtoService.GetBaseItemDto(item, fields.ToList());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -8,7 +8,6 @@ using ServiceStack.ServiceHost;
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MediaBrowser.Api.UserLibrary
|
||||
{
|
||||
|
@ -72,7 +71,7 @@ namespace MediaBrowser.Api.UserLibrary
|
|||
/// <returns>System.Object.</returns>
|
||||
public object Get(GetPerson request)
|
||||
{
|
||||
var result = GetItem(request).Result;
|
||||
var result = GetItem(request);
|
||||
|
||||
return ToOptimizedResult(result);
|
||||
}
|
||||
|
@ -82,7 +81,7 @@ namespace MediaBrowser.Api.UserLibrary
|
|||
/// </summary>
|
||||
/// <param name="request">The request.</param>
|
||||
/// <returns>Task{BaseItemDto}.</returns>
|
||||
private async Task<BaseItemDto> GetItem(GetPerson request)
|
||||
private BaseItemDto GetItem(GetPerson request)
|
||||
{
|
||||
var item = GetPerson(request.Name, LibraryManager);
|
||||
|
||||
|
@ -93,10 +92,10 @@ namespace MediaBrowser.Api.UserLibrary
|
|||
{
|
||||
var user = UserManager.GetUserById(request.UserId.Value);
|
||||
|
||||
return await DtoService.GetBaseItemDto(item, fields.ToList(), user).ConfigureAwait(false);
|
||||
return DtoService.GetBaseItemDto(item, fields.ToList(), user);
|
||||
}
|
||||
|
||||
return await DtoService.GetBaseItemDto(item, fields.ToList()).ConfigureAwait(false);
|
||||
return DtoService.GetBaseItemDto(item, fields.ToList());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -60,7 +60,7 @@ namespace MediaBrowser.Api.UserLibrary
|
|||
/// <returns>System.Object.</returns>
|
||||
public object Get(GetStudio request)
|
||||
{
|
||||
var result = GetItem(request).Result;
|
||||
var result = GetItem(request);
|
||||
|
||||
return ToOptimizedResult(result);
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ namespace MediaBrowser.Api.UserLibrary
|
|||
/// </summary>
|
||||
/// <param name="request">The request.</param>
|
||||
/// <returns>Task{BaseItemDto}.</returns>
|
||||
private async Task<BaseItemDto> GetItem(GetStudio request)
|
||||
private BaseItemDto GetItem(GetStudio request)
|
||||
{
|
||||
var item = GetStudio(request.Name, LibraryManager);
|
||||
|
||||
|
@ -81,10 +81,10 @@ namespace MediaBrowser.Api.UserLibrary
|
|||
{
|
||||
var user = UserManager.GetUserById(request.UserId.Value);
|
||||
|
||||
return await DtoService.GetBaseItemDto(item, fields.ToList(), user).ConfigureAwait(false);
|
||||
return DtoService.GetBaseItemDto(item, fields.ToList(), user);
|
||||
}
|
||||
|
||||
return await DtoService.GetBaseItemDto(item, fields.ToList()).ConfigureAwait(false);
|
||||
return DtoService.GetBaseItemDto(item, fields.ToList());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -393,12 +393,12 @@ namespace MediaBrowser.Api.UserLibrary
|
|||
/// <returns>System.Object.</returns>
|
||||
public object Get(GetSpecialFeatures request)
|
||||
{
|
||||
var result = GetAsync(request).Result;
|
||||
var result = GetAsync(request);
|
||||
|
||||
return ToOptimizedResult(result);
|
||||
}
|
||||
|
||||
private Task<BaseItemDto[]> GetAsync(GetSpecialFeatures request)
|
||||
private BaseItemDto[] GetAsync(GetSpecialFeatures request)
|
||||
{
|
||||
var user = _userManager.GetUserById(request.UserId);
|
||||
|
||||
|
@ -415,12 +415,12 @@ namespace MediaBrowser.Api.UserLibrary
|
|||
// Avoid implicitly captured closure
|
||||
var movie1 = movie;
|
||||
|
||||
var tasks = movie.SpecialFeatureIds
|
||||
var dtos = movie.SpecialFeatureIds
|
||||
.Select(_itemRepo.RetrieveItem)
|
||||
.OrderBy(i => i.SortName)
|
||||
.Select(i => _dtoService.GetBaseItemDto(i, fields, user, movie1));
|
||||
|
||||
return Task.WhenAll(tasks);
|
||||
return dtos.ToArray();
|
||||
}
|
||||
|
||||
var series = item as Series;
|
||||
|
@ -428,7 +428,7 @@ namespace MediaBrowser.Api.UserLibrary
|
|||
// Get them from the child tree
|
||||
if (series != null)
|
||||
{
|
||||
var tasks = series
|
||||
var dtos = series
|
||||
.RecursiveChildren
|
||||
.OfType<Episode>()
|
||||
.Where(i => i.ParentIndexNumber.HasValue && i.ParentIndexNumber.Value == 0)
|
||||
|
@ -448,7 +448,7 @@ namespace MediaBrowser.Api.UserLibrary
|
|||
.ThenBy(i => i.SortName)
|
||||
.Select(i => _dtoService.GetBaseItemDto(i, fields, user));
|
||||
|
||||
return Task.WhenAll(tasks);
|
||||
return dtos.ToArray();
|
||||
}
|
||||
|
||||
throw new ArgumentException("The item does not support special features");
|
||||
|
@ -461,12 +461,12 @@ namespace MediaBrowser.Api.UserLibrary
|
|||
/// <returns>System.Object.</returns>
|
||||
public object Get(GetLocalTrailers request)
|
||||
{
|
||||
var result = GetAsync(request).Result;
|
||||
var result = GetAsync(request);
|
||||
|
||||
return ToOptimizedResult(result);
|
||||
}
|
||||
|
||||
private Task<BaseItemDto[]> GetAsync(GetLocalTrailers request)
|
||||
private BaseItemDto[] GetAsync(GetLocalTrailers request)
|
||||
{
|
||||
var user = _userManager.GetUserById(request.UserId);
|
||||
|
||||
|
@ -475,12 +475,12 @@ namespace MediaBrowser.Api.UserLibrary
|
|||
// Get everything
|
||||
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true)).ToList();
|
||||
|
||||
var tasks = item.LocalTrailerIds
|
||||
var dtos = item.LocalTrailerIds
|
||||
.Select(_itemRepo.RetrieveItem)
|
||||
.OrderBy(i => i.SortName)
|
||||
.Select(i => _dtoService.GetBaseItemDto(i, fields, user, item));
|
||||
|
||||
return Task.WhenAll(tasks);
|
||||
return dtos.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -497,7 +497,7 @@ namespace MediaBrowser.Api.UserLibrary
|
|||
// Get everything
|
||||
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true)).ToList();
|
||||
|
||||
var result = _dtoService.GetBaseItemDto(item, fields, user).Result;
|
||||
var result = _dtoService.GetBaseItemDto(item, fields, user);
|
||||
|
||||
return ToOptimizedResult(result);
|
||||
}
|
||||
|
@ -516,7 +516,7 @@ namespace MediaBrowser.Api.UserLibrary
|
|||
// Get everything
|
||||
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true)).ToList();
|
||||
|
||||
var result = _dtoService.GetBaseItemDto(item, fields, user).Result;
|
||||
var result = _dtoService.GetBaseItemDto(item, fields, user);
|
||||
|
||||
return ToOptimizedResult(result);
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MediaBrowser.Api.UserLibrary
|
||||
{
|
||||
|
@ -66,7 +65,7 @@ namespace MediaBrowser.Api.UserLibrary
|
|||
/// <returns>System.Object.</returns>
|
||||
public object Get(GetYear request)
|
||||
{
|
||||
var result = GetItem(request).Result;
|
||||
var result = GetItem(request);
|
||||
|
||||
return ToOptimizedResult(result);
|
||||
}
|
||||
|
@ -76,7 +75,7 @@ namespace MediaBrowser.Api.UserLibrary
|
|||
/// </summary>
|
||||
/// <param name="request">The request.</param>
|
||||
/// <returns>Task{BaseItemDto}.</returns>
|
||||
private async Task<BaseItemDto> GetItem(GetYear request)
|
||||
private BaseItemDto GetItem(GetYear request)
|
||||
{
|
||||
var item = LibraryManager.GetYear(request.Year);
|
||||
|
||||
|
@ -87,10 +86,10 @@ namespace MediaBrowser.Api.UserLibrary
|
|||
{
|
||||
var user = UserManager.GetUserById(request.UserId.Value);
|
||||
|
||||
return await DtoService.GetBaseItemDto(item, fields.ToList(), user).ConfigureAwait(false);
|
||||
return DtoService.GetBaseItemDto(item, fields.ToList(), user);
|
||||
}
|
||||
|
||||
return await DtoService.GetBaseItemDto(item, fields.ToList()).ConfigureAwait(false);
|
||||
return DtoService.GetBaseItemDto(item, fields.ToList());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace MediaBrowser.Api
|
|||
[Api(Description = "Gets a list of users")]
|
||||
public class GetUsers : IReturn<List<UserDto>>
|
||||
{
|
||||
[ApiMember(Name = "IsHidden", Description="Optional filter by IsHidden=true or false", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
|
||||
[ApiMember(Name = "IsHidden", Description = "Optional filter by IsHidden=true or false", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
|
||||
public bool? IsHidden { get; set; }
|
||||
|
||||
[ApiMember(Name = "IsDisabled", Description = "Optional filter by IsDisabled=true or false", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
|
||||
|
@ -32,7 +32,7 @@ namespace MediaBrowser.Api
|
|||
public class GetPublicUsers : IReturn<List<UserDto>>
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Class GetUser
|
||||
/// </summary>
|
||||
|
@ -220,9 +220,12 @@ namespace MediaBrowser.Api
|
|||
users = users.Where(i => i.Configuration.IsHidden == request.IsHidden.Value);
|
||||
}
|
||||
|
||||
var tasks = users.OrderBy(u => u.Name).Select(_dtoService.GetUserDto).Select(i => i.Result);
|
||||
var result = users
|
||||
.OrderBy(u => u.Name)
|
||||
.Select(_dtoService.GetUserDto)
|
||||
.ToList();
|
||||
|
||||
return ToOptimizedResult(tasks.ToList());
|
||||
return ToOptimizedResult(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -239,7 +242,7 @@ namespace MediaBrowser.Api
|
|||
throw new ResourceNotFoundException("User not found");
|
||||
}
|
||||
|
||||
var result = _dtoService.GetUserDto(user).Result;
|
||||
var result = _dtoService.GetUserDto(user);
|
||||
|
||||
return ToOptimizedResult(result);
|
||||
}
|
||||
|
@ -305,7 +308,7 @@ namespace MediaBrowser.Api
|
|||
|
||||
var result = new AuthenticationResult
|
||||
{
|
||||
User = await _dtoService.GetUserDto(user).ConfigureAwait(false)
|
||||
User = _dtoService.GetUserDto(user)
|
||||
};
|
||||
|
||||
return result;
|
||||
|
@ -404,7 +407,7 @@ namespace MediaBrowser.Api
|
|||
|
||||
newUser.UpdateConfiguration(dtoUser.Configuration, _xmlSerializer);
|
||||
|
||||
var result = _dtoService.GetUserDto(newUser).Result;
|
||||
var result = _dtoService.GetUserDto(newUser);
|
||||
|
||||
return ToOptimizedResult(result);
|
||||
}
|
||||
|
|
|
@ -65,7 +65,6 @@ namespace MediaBrowser.Api
|
|||
var items = video.AdditionalPartIds.Select(_itemRepo.RetrieveItem)
|
||||
.OrderBy(i => i.SortName)
|
||||
.Select(i => _dtoService.GetBaseItemDto(i, fields, user, video))
|
||||
.Select(t => t.Result)
|
||||
.ToArray();
|
||||
|
||||
var result = new ItemsResult
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Common.IO;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
|
@ -41,7 +39,7 @@ namespace MediaBrowser.Controller.Drawing
|
|||
/// <param name="logger">The logger.</param>
|
||||
/// <returns>The dimensions of the specified image.</returns>
|
||||
/// <exception cref="ArgumentException">The image was of an unrecognised format.</exception>
|
||||
public static async Task<Size> GetDimensions(string path, ILogger logger)
|
||||
public static Size GetDimensions(string path, ILogger logger)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -59,11 +57,11 @@ namespace MediaBrowser.Controller.Drawing
|
|||
}
|
||||
|
||||
// Buffer to memory stream to avoid image locking file
|
||||
using (var fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, StreamDefaults.DefaultFileStreamBufferSize, true))
|
||||
using (var fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||
{
|
||||
using (var memoryStream = new MemoryStream())
|
||||
{
|
||||
await fs.CopyToAsync(memoryStream).ConfigureAwait(false);
|
||||
fs.CopyTo(memoryStream);
|
||||
|
||||
// Co it the old fashioned way
|
||||
using (var b = Image.FromStream(memoryStream, true, false))
|
||||
|
|
|
@ -68,11 +68,6 @@ namespace MediaBrowser.Controller.Drawing
|
|||
|
||||
private readonly IItemRepository _itemRepo;
|
||||
|
||||
/// <summary>
|
||||
/// The _locks
|
||||
/// </summary>
|
||||
private readonly ConcurrentDictionary<string, SemaphoreSlim> _locks = new ConcurrentDictionary<string, SemaphoreSlim>();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ImageManager" /> class.
|
||||
/// </summary>
|
||||
|
@ -146,7 +141,7 @@ namespace MediaBrowser.Controller.Drawing
|
|||
}
|
||||
}
|
||||
|
||||
var originalImageSize = await GetImageSize(originalImagePath, dateModified).ConfigureAwait(false);
|
||||
var originalImageSize = GetImageSize(originalImagePath, dateModified);
|
||||
|
||||
// Determine the output size based on incoming parameters
|
||||
var newSize = DrawingUtils.Resize(originalImageSize, width, height, maxWidth, maxHeight);
|
||||
|
@ -304,7 +299,7 @@ namespace MediaBrowser.Controller.Drawing
|
|||
/// <param name="dateModified">The date modified.</param>
|
||||
/// <returns>Task{ImageSize}.</returns>
|
||||
/// <exception cref="System.ArgumentNullException">imagePath</exception>
|
||||
public async Task<ImageSize> GetImageSize(string imagePath, DateTime dateModified)
|
||||
public ImageSize GetImageSize(string imagePath, DateTime dateModified)
|
||||
{
|
||||
if (string.IsNullOrEmpty(imagePath))
|
||||
{
|
||||
|
@ -317,7 +312,7 @@ namespace MediaBrowser.Controller.Drawing
|
|||
|
||||
if (!_cachedImagedSizes.TryGetValue(name, out size))
|
||||
{
|
||||
size = await GetImageSize(name, imagePath).ConfigureAwait(false);
|
||||
size = GetImageSize(name, imagePath);
|
||||
|
||||
_cachedImagedSizes.AddOrUpdate(name, size, (keyName, oldValue) => size);
|
||||
}
|
||||
|
@ -333,7 +328,7 @@ namespace MediaBrowser.Controller.Drawing
|
|||
/// <param name="keyName">Name of the key.</param>
|
||||
/// <param name="imagePath">The image path.</param>
|
||||
/// <returns>ImageSize.</returns>
|
||||
private async Task<ImageSize> GetImageSize(string keyName, string imagePath)
|
||||
private ImageSize GetImageSize(string keyName, string imagePath)
|
||||
{
|
||||
// Now check the file system cache
|
||||
var fullCachePath = ImageSizeCache.GetResourcePath(keyName, ".txt");
|
||||
|
@ -349,34 +344,29 @@ namespace MediaBrowser.Controller.Drawing
|
|||
// Cache file doesn't exist or is currently being written to
|
||||
}
|
||||
|
||||
var semaphore = GetLock(fullCachePath);
|
||||
var syncLock = GetObjectLock(fullCachePath);
|
||||
|
||||
await semaphore.WaitAsync().ConfigureAwait(false);
|
||||
lock (syncLock)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = File.ReadAllText(fullCachePath)
|
||||
.Split('|')
|
||||
.Select(i => double.Parse(i, UsCulture))
|
||||
.ToArray();
|
||||
|
||||
try
|
||||
{
|
||||
var result = File.ReadAllText(fullCachePath).Split('|').Select(i => double.Parse(i, UsCulture)).ToArray();
|
||||
return new ImageSize { Width = result[0], Height = result[1] };
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
{
|
||||
// Cache file doesn't exist no biggie
|
||||
}
|
||||
catch (DirectoryNotFoundException)
|
||||
{
|
||||
// Cache file doesn't exist no biggie
|
||||
}
|
||||
|
||||
return new ImageSize { Width = result[0], Height = result[1] };
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
{
|
||||
// Cache file doesn't exist no biggie
|
||||
}
|
||||
catch (DirectoryNotFoundException)
|
||||
{
|
||||
// Cache file doesn't exist no biggie
|
||||
}
|
||||
catch
|
||||
{
|
||||
semaphore.Release();
|
||||
|
||||
throw;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var size = await ImageHeader.GetDimensions(imagePath, _logger).ConfigureAwait(false);
|
||||
var size = ImageHeader.GetDimensions(imagePath, _logger);
|
||||
|
||||
var parentPath = Path.GetDirectoryName(fullCachePath);
|
||||
|
||||
|
@ -390,10 +380,6 @@ namespace MediaBrowser.Controller.Drawing
|
|||
|
||||
return new ImageSize { Width = size.Width, Height = size.Height };
|
||||
}
|
||||
finally
|
||||
{
|
||||
semaphore.Release();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -600,7 +586,7 @@ namespace MediaBrowser.Controller.Drawing
|
|||
|
||||
return GetEnhancedImage(originalImagePath, dateModified, item, imageType, imageIndex, supportedImageEnhancers);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Runs an image through the image enhancers, caches the result, and returns the cached path
|
||||
/// </summary>
|
||||
|
@ -786,6 +772,11 @@ namespace MediaBrowser.Controller.Drawing
|
|||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The _semaphoreLocks
|
||||
/// </summary>
|
||||
private readonly ConcurrentDictionary<string, SemaphoreSlim> _semaphoreLocks = new ConcurrentDictionary<string, SemaphoreSlim>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the lock.
|
||||
/// </summary>
|
||||
|
@ -793,7 +784,22 @@ namespace MediaBrowser.Controller.Drawing
|
|||
/// <returns>System.Object.</returns>
|
||||
private SemaphoreSlim GetLock(string filename)
|
||||
{
|
||||
return _locks.GetOrAdd(filename, key => new SemaphoreSlim(1, 1));
|
||||
return _semaphoreLocks.GetOrAdd(filename, key => new SemaphoreSlim(1, 1));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The _semaphoreLocks
|
||||
/// </summary>
|
||||
private readonly ConcurrentDictionary<string, object> _locks = new ConcurrentDictionary<string, object>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the lock.
|
||||
/// </summary>
|
||||
/// <param name="filename">The filename.</param>
|
||||
/// <returns>System.Object.</returns>
|
||||
private object GetObjectLock(string filename)
|
||||
{
|
||||
return _locks.GetOrAdd(filename, key => new object());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ using MediaBrowser.Model.Querying;
|
|||
using MediaBrowser.Model.Session;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MediaBrowser.Controller.Dto
|
||||
{
|
||||
|
@ -19,8 +18,8 @@ namespace MediaBrowser.Controller.Dto
|
|||
/// Gets the user dto.
|
||||
/// </summary>
|
||||
/// <param name="user">The user.</param>
|
||||
/// <returns>Task{UserDto}.</returns>
|
||||
Task<UserDto> GetUserDto(User user);
|
||||
/// <returns>UserDto.</returns>
|
||||
UserDto GetUserDto(User user);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the session info dto.
|
||||
|
@ -66,6 +65,6 @@ namespace MediaBrowser.Controller.Dto
|
|||
/// <param name="user">The user.</param>
|
||||
/// <param name="owner">The owner.</param>
|
||||
/// <returns>Task{BaseItemDto}.</returns>
|
||||
Task<BaseItemDto> GetBaseItemDto(BaseItem item, List<ItemFields> fields, User user = null, BaseItem owner = null);
|
||||
BaseItemDto GetBaseItemDto(BaseItem item, List<ItemFields> fields, User user = null, BaseItem owner = null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using MediaBrowser.Common.Configuration;
|
||||
using System.Net;
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Common.IO;
|
||||
using MediaBrowser.Common.Net;
|
||||
|
@ -17,6 +18,7 @@ using System.Linq;
|
|||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml;
|
||||
using MediaBrowser.Model.Net;
|
||||
|
||||
namespace MediaBrowser.Providers.Music
|
||||
{
|
||||
|
@ -314,8 +316,19 @@ namespace MediaBrowser.Providers.Music
|
|||
path = node != null ? node.Value : null;
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
{
|
||||
await _providerManager.SaveImage(item, path, FanArtResourcePool, ImageType.Logo, null, cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
try
|
||||
{
|
||||
await _providerManager.SaveImage(item, path, FanArtResourcePool, ImageType.Logo, null, cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
catch (HttpException ex)
|
||||
{
|
||||
// Sometimes fanart has bad url's in their xml. Nothing we can do here but catch it
|
||||
if (!ex.StatusCode.HasValue || ex.StatusCode.Value != HttpStatusCode.NotFound)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
@ -332,10 +345,21 @@ namespace MediaBrowser.Providers.Music
|
|||
path = node.Value;
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
{
|
||||
await _providerManager.SaveImage(item, path, FanArtResourcePool, ImageType.Backdrop, numBackdrops, cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
numBackdrops++;
|
||||
if (numBackdrops >= ConfigurationManager.Configuration.MaxBackdrops) break;
|
||||
try
|
||||
{
|
||||
await _providerManager.SaveImage(item, path, FanArtResourcePool, ImageType.Backdrop, numBackdrops, cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
numBackdrops++;
|
||||
if (numBackdrops >= ConfigurationManager.Configuration.MaxBackdrops) break;
|
||||
}
|
||||
catch (HttpException ex)
|
||||
{
|
||||
// Sometimes fanart has bad url's in their xml. Nothing we can do here but catch it
|
||||
if (!ex.StatusCode.HasValue || ex.StatusCode.Value != HttpStatusCode.NotFound)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -353,8 +377,19 @@ namespace MediaBrowser.Providers.Music
|
|||
path = node != null ? node.Value : null;
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
{
|
||||
await _providerManager.SaveImage(item, path, FanArtResourcePool, ImageType.Art, null, cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
try
|
||||
{
|
||||
await _providerManager.SaveImage(item, path, FanArtResourcePool, ImageType.Art, null, cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
catch (HttpException ex)
|
||||
{
|
||||
// Sometimes fanart has bad url's in their xml. Nothing we can do here but catch it
|
||||
if (!ex.StatusCode.HasValue || ex.StatusCode.Value != HttpStatusCode.NotFound)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
@ -366,8 +401,19 @@ namespace MediaBrowser.Providers.Music
|
|||
path = node != null ? node.Value : null;
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
{
|
||||
await _providerManager.SaveImage(item, path, FanArtResourcePool, ImageType.Banner, null, cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
try
|
||||
{
|
||||
await _providerManager.SaveImage(item, path, FanArtResourcePool, ImageType.Banner, null, cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
catch (HttpException ex)
|
||||
{
|
||||
// Sometimes fanart has bad url's in their xml. Nothing we can do here but catch it
|
||||
if (!ex.StatusCode.HasValue || ex.StatusCode.Value != HttpStatusCode.NotFound)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -380,8 +426,19 @@ namespace MediaBrowser.Providers.Music
|
|||
path = node != null ? node.Value : null;
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
{
|
||||
await _providerManager.SaveImage(item, path, FanArtResourcePool, ImageType.Primary, null, cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
try
|
||||
{
|
||||
await _providerManager.SaveImage(item, path, FanArtResourcePool, ImageType.Primary, null, cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
catch (HttpException ex)
|
||||
{
|
||||
// Sometimes fanart has bad url's in their xml. Nothing we can do here but catch it
|
||||
if (!ex.StatusCode.HasValue || ex.StatusCode.Value != HttpStatusCode.NotFound)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MediaBrowser.Server.Implementations.Dto
|
||||
{
|
||||
|
@ -49,7 +48,7 @@ namespace MediaBrowser.Server.Implementations.Dto
|
|||
/// <param name="owner">The owner.</param>
|
||||
/// <returns>Task{DtoBaseItem}.</returns>
|
||||
/// <exception cref="System.ArgumentNullException">item</exception>
|
||||
public async Task<BaseItemDto> GetBaseItemDto(BaseItem item, List<ItemFields> fields, User user = null, BaseItem owner = null)
|
||||
public BaseItemDto GetBaseItemDto(BaseItem item, List<ItemFields> fields, User user = null, BaseItem owner = null)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
|
@ -72,7 +71,7 @@ namespace MediaBrowser.Server.Implementations.Dto
|
|||
{
|
||||
try
|
||||
{
|
||||
await AttachPrimaryImageAspectRatio(dto, item).ConfigureAwait(false);
|
||||
AttachPrimaryImageAspectRatio(dto, item);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -189,7 +188,7 @@ namespace MediaBrowser.Server.Implementations.Dto
|
|||
}
|
||||
}
|
||||
|
||||
public async Task<UserDto> GetUserDto(User user)
|
||||
public UserDto GetUserDto(User user)
|
||||
{
|
||||
if (user == null)
|
||||
{
|
||||
|
@ -214,7 +213,7 @@ namespace MediaBrowser.Server.Implementations.Dto
|
|||
|
||||
try
|
||||
{
|
||||
await AttachPrimaryImageAspectRatio(dto, user).ConfigureAwait(false);
|
||||
AttachPrimaryImageAspectRatio(dto, user);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -1132,9 +1131,8 @@ namespace MediaBrowser.Server.Implementations.Dto
|
|||
/// </summary>
|
||||
/// <param name="dto">The dto.</param>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="logger">The _logger.</param>
|
||||
/// <returns>Task.</returns>
|
||||
private async Task AttachPrimaryImageAspectRatio(IItemDto dto, BaseItem item)
|
||||
private void AttachPrimaryImageAspectRatio(IItemDto dto, BaseItem item)
|
||||
{
|
||||
var path = item.PrimaryImagePath;
|
||||
|
||||
|
@ -1152,7 +1150,7 @@ namespace MediaBrowser.Server.Implementations.Dto
|
|||
|
||||
try
|
||||
{
|
||||
size = await Kernel.Instance.ImageManager.GetImageSize(path, dateModified).ConfigureAwait(false);
|
||||
size = Kernel.Instance.ImageManager.GetImageSize(path, dateModified);
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
{
|
||||
|
|
|
@ -44,7 +44,7 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
|
|||
private readonly ITaskManager _taskManager;
|
||||
|
||||
private readonly IDtoService _dtoService;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="WebSocketEvents" /> class.
|
||||
/// </summary>
|
||||
|
@ -134,9 +134,9 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
|
|||
/// </summary>
|
||||
/// <param name="sender">The sender.</param>
|
||||
/// <param name="e">The e.</param>
|
||||
async void userManager_UserUpdated(object sender, GenericEventArgs<User> e)
|
||||
void userManager_UserUpdated(object sender, GenericEventArgs<User> e)
|
||||
{
|
||||
var dto = await _dtoService.GetUserDto(e.Argument).ConfigureAwait(false);
|
||||
var dto = _dtoService.GetUserDto(e.Argument);
|
||||
|
||||
_serverManager.SendWebSocketMessage("UserUpdated", dto);
|
||||
}
|
||||
|
|
|
@ -824,7 +824,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
|||
/// <returns>Task.</returns>
|
||||
public async Task ValidatePeople(CancellationToken cancellationToken, IProgress<double> progress)
|
||||
{
|
||||
const int maxTasks = 5;
|
||||
const int maxTasks = 3;
|
||||
|
||||
var tasks = new List<Task>();
|
||||
|
||||
|
|
|
@ -202,7 +202,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
|||
.Distinct(StringComparer.OrdinalIgnoreCase)
|
||||
.ToList();
|
||||
|
||||
const int maxTasks = 5;
|
||||
const int maxTasks = 3;
|
||||
|
||||
var tasks = new List<Task>();
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user