diff --git a/MediaBrowser.Api/Images/RemoteImageService.cs b/MediaBrowser.Api/Images/RemoteImageService.cs index 06b99e175..235f18296 100644 --- a/MediaBrowser.Api/Images/RemoteImageService.cs +++ b/MediaBrowser.Api/Images/RemoteImageService.cs @@ -199,21 +199,21 @@ namespace MediaBrowser.Api.Images return _providerManager.GetRemoteImageProviderInfo(item).ToList(); } - public object Get(GetRemoteImages request) + public async Task Get(GetRemoteImages request) { var item = _libraryManager.GetItemById(request.Id); - return GetRemoteImageResult(item, request); + return await GetRemoteImageResult(item, request).ConfigureAwait(false); } - public object Get(GetItemByNameRemoteImages request) + public async Task Get(GetItemByNameRemoteImages request) { var pathInfo = PathInfo.Parse(Request.PathInfo); var type = pathInfo.GetArgumentValue(0); var item = GetItemByName(request.Name, type, _libraryManager); - return GetRemoteImageResult(item, request); + return await GetRemoteImageResult(item, request).ConfigureAwait(false); } private async Task GetRemoteImageResult(BaseItem item, BaseRemoteImageRequest request) @@ -304,7 +304,12 @@ namespace MediaBrowser.Api.Images /// /// The request. /// System.Object. - public async Task Get(GetRemoteImage request) + public object Get(GetRemoteImage request) + { + return GetAsync(request).Result; + } + + public async Task GetAsync(GetRemoteImage request) { var urlHash = request.ImageUrl.GetMD5(); var pointerCachePath = GetFullCachePath(urlHash.ToString()); @@ -342,7 +347,7 @@ namespace MediaBrowser.Api.Images return ToStaticFileResult(contentPath); } - + /// /// Downloads the image. /// diff --git a/MediaBrowser.Api/Session/SessionsService.cs b/MediaBrowser.Api/Session/SessionsService.cs index 8e97e2f3e..e2c10c0c8 100644 --- a/MediaBrowser.Api/Session/SessionsService.cs +++ b/MediaBrowser.Api/Session/SessionsService.cs @@ -297,9 +297,9 @@ namespace MediaBrowser.Api.Session Task.WaitAll(task); } - public Task Post(CreateKey request) + public void Post(CreateKey request) { - return _authRepo.Create(new AuthenticationInfo + var task = _authRepo.Create(new AuthenticationInfo { AppName = request.App, IsActive = true, @@ -307,6 +307,8 @@ namespace MediaBrowser.Api.Session DateCreated = DateTime.UtcNow }, CancellationToken.None); + + Task.WaitAll(task); } public void Post(ReportSessionEnded request) @@ -355,7 +357,7 @@ namespace MediaBrowser.Api.Session return ToOptimizedResult(result.Select(_sessionManager.GetSessionInfoDto).ToList()); } - public Task Post(SendPlaystateCommand request) + public void Post(SendPlaystateCommand request) { var command = new PlaystateRequest { @@ -363,14 +365,16 @@ namespace MediaBrowser.Api.Session SeekPositionTicks = request.SeekPositionTicks }; - return _sessionManager.SendPlaystateCommand(GetSession().Id, request.Id, command, CancellationToken.None); + var task = _sessionManager.SendPlaystateCommand(GetSession().Id, request.Id, command, CancellationToken.None); + + Task.WaitAll(task); } /// /// Posts the specified request. /// /// The request. - public Task Post(DisplayContent request) + public void Post(DisplayContent request) { var command = new BrowseRequest { @@ -379,14 +383,16 @@ namespace MediaBrowser.Api.Session ItemType = request.ItemType }; - return _sessionManager.SendBrowseCommand(GetSession().Id, request.Id, command, CancellationToken.None); + var task = _sessionManager.SendBrowseCommand(GetSession().Id, request.Id, command, CancellationToken.None); + + Task.WaitAll(task); } /// /// Posts the specified request. /// /// The request. - public Task Post(SendSystemCommand request) + public void Post(SendSystemCommand request) { GeneralCommandType commandType; var name = request.Command; @@ -404,14 +410,16 @@ namespace MediaBrowser.Api.Session ControllingUserId = currentSession.UserId.HasValue ? currentSession.UserId.Value.ToString("N") : null }; - return _sessionManager.SendGeneralCommand(currentSession.Id, request.Id, command, CancellationToken.None); + var task = _sessionManager.SendGeneralCommand(currentSession.Id, request.Id, command, CancellationToken.None); + + Task.WaitAll(task); } /// /// Posts the specified request. /// /// The request. - public Task Post(SendMessageCommand request) + public void Post(SendMessageCommand request) { var command = new MessageCommand { @@ -420,14 +428,16 @@ namespace MediaBrowser.Api.Session Text = request.Text }; - return _sessionManager.SendMessageCommand(GetSession().Id, request.Id, command, CancellationToken.None); + var task = _sessionManager.SendMessageCommand(GetSession().Id, request.Id, command, CancellationToken.None); + + Task.WaitAll(task); } /// /// Posts the specified request. /// /// The request. - public Task Post(Play request) + public void Post(Play request) { var command = new PlayRequest { @@ -437,10 +447,12 @@ namespace MediaBrowser.Api.Session StartPositionTicks = request.StartPositionTicks }; - return _sessionManager.SendPlayCommand(GetSession().Id, request.Id, command, CancellationToken.None); + var task = _sessionManager.SendPlayCommand(GetSession().Id, request.Id, command, CancellationToken.None); + + Task.WaitAll(task); } - public Task Post(SendGeneralCommand request) + public void Post(SendGeneralCommand request) { var currentSession = GetSession(); @@ -450,16 +462,20 @@ namespace MediaBrowser.Api.Session ControllingUserId = currentSession.UserId.HasValue ? currentSession.UserId.Value.ToString("N") : null }; - return _sessionManager.SendGeneralCommand(currentSession.Id, request.Id, command, CancellationToken.None); + var task = _sessionManager.SendGeneralCommand(currentSession.Id, request.Id, command, CancellationToken.None); + + Task.WaitAll(task); } - public Task Post(SendFullGeneralCommand request) + public void Post(SendFullGeneralCommand request) { var currentSession = GetSession(); request.ControllingUserId = currentSession.UserId.HasValue ? currentSession.UserId.Value.ToString("N") : null; - return _sessionManager.SendGeneralCommand(currentSession.Id, request.Id, request, CancellationToken.None); + var task = _sessionManager.SendGeneralCommand(currentSession.Id, request.Id, request, CancellationToken.None); + + Task.WaitAll(task); } public void Post(AddUserToSession request) diff --git a/MediaBrowser.Api/UserLibrary/UserLibraryService.cs b/MediaBrowser.Api/UserLibrary/UserLibraryService.cs index 16ed0ee29..44b5b0e9b 100644 --- a/MediaBrowser.Api/UserLibrary/UserLibraryService.cs +++ b/MediaBrowser.Api/UserLibrary/UserLibraryService.cs @@ -420,8 +420,7 @@ namespace MediaBrowser.Api.UserLibrary var folders = await _userViewManager.GetUserViews(query, CancellationToken.None).ConfigureAwait(false); - var dtos = folders.OrderBy(i => i.SortName) - .Select(i => _dtoService.GetBaseItemDto(i, fields, user)) + var dtos = folders.Select(i => _dtoService.GetBaseItemDto(i, fields, user)) .ToArray(); var result = new QueryResult diff --git a/MediaBrowser.Controller/Playlists/Playlist.cs b/MediaBrowser.Controller/Playlists/Playlist.cs index 05a894223..84fcbb91a 100644 --- a/MediaBrowser.Controller/Playlists/Playlist.cs +++ b/MediaBrowser.Controller/Playlists/Playlist.cs @@ -1,4 +1,5 @@ using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Entities.Audio; using MediaBrowser.Model.Entities; using MediaBrowser.Model.Querying; using System; @@ -47,32 +48,54 @@ namespace MediaBrowser.Controller.Playlists inputItems = inputItems.Where(i => i.IsVisible(user)); } - inputItems = inputItems.SelectMany(i => + return inputItems.SelectMany(i => GetPlaylistItems(i, user)) + .Where(m => string.Equals(m.MediaType, playlistMediaType, StringComparison.OrdinalIgnoreCase)); + } + + private static IEnumerable GetPlaylistItems(BaseItem i, User user) + { + var musicGenre = i as MusicGenre; + if (musicGenre != null) { - var folder = i as Folder; + var songs = user.RootFolder + .GetRecursiveChildren(user) + .OfType