From dab5003d6bba57c27f4111653b36d39862b5b6fd Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 12 Jul 2013 15:56:40 -0400 Subject: [PATCH] added collection type --- MediaBrowser.Api/Library/LibraryHelpers.cs | 10 +++- .../Library/LibraryStructureService.cs | 10 +++- .../UserLibrary/ArtistsService.cs | 26 +++++++- MediaBrowser.Controller/Dto/DtoBuilder.cs | 13 ++++ MediaBrowser.Controller/Entities/BaseItem.cs | 20 ++++++- .../Entities/CollectionFolder.cs | 10 ++-- MediaBrowser.Controller/Entities/Folder.cs | 4 +- MediaBrowser.Controller/IO/FileData.cs | 15 ++--- .../Library/ILibraryManager.cs | 7 +++ MediaBrowser.Model/ApiClient/IApiClient.cs | 7 +++ MediaBrowser.Model/Entities/CollectionType.cs | 20 +++++++ .../Entities/VirtualFolderInfo.cs | 6 ++ MediaBrowser.Model/MediaBrowser.Model.csproj | 1 + .../Savers/MovieXmlSaver.cs | 4 +- .../IO/DirectoryWatchers.cs | 2 +- .../Library/LibraryManager.cs | 59 ++++++++++++++++++- .../Library/Resolvers/FolderResolver.cs | 16 ++++- .../Library/Resolvers/Movies/MovieResolver.cs | 29 +++++---- MediaBrowser.WebDashboard/ApiClient.js | 10 +++- MediaBrowser.WebDashboard/packages.config | 2 +- 20 files changed, 233 insertions(+), 38 deletions(-) create mode 100644 MediaBrowser.Model/Entities/CollectionType.cs diff --git a/MediaBrowser.Api/Library/LibraryHelpers.cs b/MediaBrowser.Api/Library/LibraryHelpers.cs index ab7449273d..72cff4560a 100644 --- a/MediaBrowser.Api/Library/LibraryHelpers.cs +++ b/MediaBrowser.Api/Library/LibraryHelpers.cs @@ -16,10 +16,11 @@ namespace MediaBrowser.Api.Library /// Adds the virtual folder. /// /// The name. + /// Type of the collection. /// The user. /// The app paths. /// There is already a media collection with the name + name + . - public static void AddVirtualFolder(string name, User user, IServerApplicationPaths appPaths) + public static void AddVirtualFolder(string name, string collectionType, User user, IServerApplicationPaths appPaths) { name = FileSystem.GetValidFilename(name); @@ -32,6 +33,13 @@ namespace MediaBrowser.Api.Library } Directory.CreateDirectory(virtualFolderPath); + + if (!string.IsNullOrEmpty(collectionType)) + { + var path = Path.Combine(virtualFolderPath, collectionType + ".collection"); + + File.Create(path); + } } /// diff --git a/MediaBrowser.Api/Library/LibraryStructureService.cs b/MediaBrowser.Api/Library/LibraryStructureService.cs index 88fc8b0af1..91018168b2 100644 --- a/MediaBrowser.Api/Library/LibraryStructureService.cs +++ b/MediaBrowser.Api/Library/LibraryStructureService.cs @@ -38,6 +38,12 @@ namespace MediaBrowser.Api.Library /// /// The name. public string Name { get; set; } + + /// + /// Gets or sets the type of the collection. + /// + /// The type of the collection. + public string CollectionType { get; set; } } [Route("/Library/VirtualFolders/{Name}", "DELETE")] @@ -196,13 +202,13 @@ namespace MediaBrowser.Api.Library { if (string.IsNullOrEmpty(request.UserId)) { - LibraryHelpers.AddVirtualFolder(request.Name, null, _appPaths); + LibraryHelpers.AddVirtualFolder(request.Name, request.CollectionType, null, _appPaths); } else { var user = _userManager.GetUserById(new Guid(request.UserId)); - LibraryHelpers.AddVirtualFolder(request.Name, user, _appPaths); + LibraryHelpers.AddVirtualFolder(request.Name, request.CollectionType, user, _appPaths); } _libraryManager.ValidateMediaLibrary(new Progress(), CancellationToken.None); diff --git a/MediaBrowser.Api/UserLibrary/ArtistsService.cs b/MediaBrowser.Api/UserLibrary/ArtistsService.cs index 7a027a0527..f65de2e69c 100644 --- a/MediaBrowser.Api/UserLibrary/ArtistsService.cs +++ b/MediaBrowser.Api/UserLibrary/ArtistsService.cs @@ -125,15 +125,35 @@ namespace MediaBrowser.Api.UserLibrary { var name = DeSlugArtistName(request.Name, LibraryManager); - var items = GetItems(request.UserId).OfType