diff options
Diffstat (limited to 'MediaBrowser.Controller')
5 files changed, 49 insertions, 41 deletions
diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index 79c96dd5e4..356f2b6034 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -6,7 +6,6 @@ using MediaBrowser.Controller.Localization; using MediaBrowser.Controller.Providers; using MediaBrowser.Model.Dto; using MediaBrowser.Model.Entities; -using MoreLinq; using System; using System.Collections; using System.Collections.Generic; @@ -15,6 +14,7 @@ using System.Linq; using System.Runtime.Serialization; using System.Threading; using System.Threading.Tasks; +using MoreLinq; namespace MediaBrowser.Controller.Entities { diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj index d12c36fba5..66c6d39eea 100644 --- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj +++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj @@ -48,6 +48,9 @@ <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> </PropertyGroup> <ItemGroup> + <Reference Include="MoreLinq"> + <HintPath>..\packages\morelinq.1.0.16006\lib\net35\MoreLinq.dll</HintPath> + </Reference> <Reference Include="System" /> <Reference Include="System.Core" /> <Reference Include="System.Data" /> @@ -57,9 +60,6 @@ <Reference Include="Microsoft.CSharp" /> <Reference Include="System.Xml" /> <Reference Include="System.Xml.Linq" /> - <Reference Include="MoreLinq"> - <HintPath>..\packages\morelinq.1.0.16006\lib\net35\MoreLinq.dll</HintPath> - </Reference> <Reference Include="ServiceStack.Interfaces"> <HintPath>..\ThirdParty\ServiceStack\ServiceStack.Interfaces.dll</HintPath> </Reference> @@ -222,7 +222,6 @@ <Compile Include="Persistence\MediaStreamQuery.cs" /> <Compile Include="Playlists\IPlaylistManager.cs" /> <Compile Include="Playlists\Playlist.cs" /> - <Compile Include="Playlists\PlaylistCreationOptions.cs" /> <Compile Include="Providers\DirectoryService.cs" /> <Compile Include="Providers\ICustomMetadataProvider.cs" /> <Compile Include="Providers\IExternalId.cs" /> diff --git a/MediaBrowser.Controller/Playlists/IPlaylistManager.cs b/MediaBrowser.Controller/Playlists/IPlaylistManager.cs index f5939ad969..cbe0b97a4e 100644 --- a/MediaBrowser.Controller/Playlists/IPlaylistManager.cs +++ b/MediaBrowser.Controller/Playlists/IPlaylistManager.cs @@ -1,4 +1,5 @@ using MediaBrowser.Controller.Entities; +using MediaBrowser.Model.Playlists; using System.Collections.Generic; using System.Threading.Tasks; @@ -18,15 +19,16 @@ namespace MediaBrowser.Controller.Playlists /// </summary> /// <param name="options">The options.</param> /// <returns>Task<Playlist>.</returns> - Task<Playlist> CreatePlaylist(PlaylistCreationOptions options); + Task<PlaylistCreationResult> CreatePlaylist(PlaylistCreationRequest options); /// <summary> /// Adds to playlist. /// </summary> /// <param name="playlistId">The playlist identifier.</param> /// <param name="itemIds">The item ids.</param> + /// <param name="userId">The user identifier.</param> /// <returns>Task.</returns> - Task AddToPlaylist(string playlistId, IEnumerable<string> itemIds); + Task AddToPlaylist(string playlistId, IEnumerable<string> itemIds, string userId); /// <summary> /// Removes from playlist. diff --git a/MediaBrowser.Controller/Playlists/Playlist.cs b/MediaBrowser.Controller/Playlists/Playlist.cs index 84fcbb91a3..5da810a91b 100644 --- a/MediaBrowser.Controller/Playlists/Playlist.cs +++ b/MediaBrowser.Controller/Playlists/Playlist.cs @@ -1,5 +1,7 @@ using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.Audio; +using MediaBrowser.Controller.Entities.Movies; +using MediaBrowser.Controller.Entities.TV; using MediaBrowser.Model.Entities; using MediaBrowser.Model.Querying; using System; @@ -49,7 +51,7 @@ namespace MediaBrowser.Controller.Playlists } return inputItems.SelectMany(i => GetPlaylistItems(i, user)) - .Where(m => string.Equals(m.MediaType, playlistMediaType, StringComparison.OrdinalIgnoreCase)); + .Where(m => string.Equals(m.MediaType, playlistMediaType, StringComparison.OrdinalIgnoreCase)); } private static IEnumerable<BaseItem> GetPlaylistItems(BaseItem i, User user) @@ -57,25 +59,55 @@ namespace MediaBrowser.Controller.Playlists var musicGenre = i as MusicGenre; if (musicGenre != null) { - var songs = user.RootFolder - .GetRecursiveChildren(user) + var items = user == null + ? LibraryManager.RootFolder.GetRecursiveChildren() + : user.RootFolder.GetRecursiveChildren(user, true); + + var songs = items .OfType<Audio>() .Where(a => a.Genres.Contains(musicGenre.Name, StringComparer.OrdinalIgnoreCase)); - return LibraryManager.Sort(songs, user, new[] { ItemSortBy.SortName }, SortOrder.Ascending); + return LibraryManager.Sort(songs, user, new[] { ItemSortBy.AlbumArtist, ItemSortBy.Album, ItemSortBy.SortName }, SortOrder.Ascending); } var musicArtist = i as MusicArtist; if (musicArtist != null) { - var songs = user.RootFolder - .GetRecursiveChildren(user) + var items = user == null + ? LibraryManager.RootFolder.GetRecursiveChildren() + : user.RootFolder.GetRecursiveChildren(user, true); + + var songs = items .OfType<Audio>() .Where(a => a.HasArtist(musicArtist.Name)); - return LibraryManager.Sort(songs, user, new[] { ItemSortBy.SortName }, SortOrder.Ascending); + return LibraryManager.Sort(songs, user, new[] { ItemSortBy.AlbumArtist, ItemSortBy.Album, ItemSortBy.SortName }, SortOrder.Ascending); + } + + // Grab these explicitly to avoid the sorting that will happen below + var collection = i as BoxSet; + if (collection != null) + { + var items = user == null + ? collection.Children + : collection.GetChildren(user, true); + + return items + .Where(m => !m.IsFolder); } - + + // Grab these explicitly to avoid the sorting that will happen below + var season = i as Season; + if (season != null) + { + var items = user == null + ? season.Children + : season.GetChildren(user, true); + + return items + .Where(m => !m.IsFolder); + } + var folder = i as Folder; if (folder != null) @@ -87,12 +119,7 @@ namespace MediaBrowser.Controller.Playlists items = items .Where(m => !m.IsFolder); - if (!folder.IsPreSorted) - { - items = LibraryManager.Sort(items, user, new[] { ItemSortBy.SortName }, SortOrder.Ascending); - } - - return items; + return LibraryManager.Sort(items, user, new[] { ItemSortBy.SortName }, SortOrder.Ascending); } return new[] { i }; diff --git a/MediaBrowser.Controller/Playlists/PlaylistCreationOptions.cs b/MediaBrowser.Controller/Playlists/PlaylistCreationOptions.cs deleted file mode 100644 index 1766ba75ca..0000000000 --- a/MediaBrowser.Controller/Playlists/PlaylistCreationOptions.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System.Collections.Generic; - -namespace MediaBrowser.Controller.Playlists -{ - public class PlaylistCreationOptions - { - public string Name { get; set; } - - public List<string> ItemIdList { get; set; } - - public string MediaType { get; set; } - - public string UserId { get; set; } - - public PlaylistCreationOptions() - { - ItemIdList = new List<string>(); - } - } -} |
