From 5c873d3ed17b9291ed437b80b8ef66d4a4f2f960 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 12 May 2013 11:27:56 -0400 Subject: [PATCH] fixes #232 - '/' in artist causes issues. --- MediaBrowser.Api/BaseApiService.cs | 128 +++++++++++++++++- MediaBrowser.Api/Images/ImageService.cs | 8 +- .../UserLibrary/ArtistsService.cs | 6 +- MediaBrowser.Api/UserLibrary/GenresService.cs | 6 +- .../UserLibrary/ItemByNameUserDataService.cs | 16 +-- .../UserLibrary/PersonsService.cs | 6 +- .../UserLibrary/StudiosService.cs | 6 +- .../MediaInfo/BaseFFProbeProvider.cs | 62 +-------- .../MediaInfo/FFProbeAudioInfoProvider.cs | 12 -- .../MediaInfo/FFProbeVideoInfoProvider.cs | 31 +---- MediaBrowser.WebDashboard/ApiClient.js | 4 + MediaBrowser.WebDashboard/packages.config | 2 +- 12 files changed, 163 insertions(+), 124 deletions(-) diff --git a/MediaBrowser.Api/BaseApiService.cs b/MediaBrowser.Api/BaseApiService.cs index 23d9b0126f..e8af6ab136 100644 --- a/MediaBrowser.Api/BaseApiService.cs +++ b/MediaBrowser.Api/BaseApiService.cs @@ -1,5 +1,8 @@ -using MediaBrowser.Common.Net; +using System.Linq; +using System.Threading.Tasks; +using MediaBrowser.Common.Net; using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Entities.Audio; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Session; using MediaBrowser.Model.Logging; @@ -33,7 +36,7 @@ namespace MediaBrowser.Api /// /// The request context. public IRequestContext RequestContext { get; set; } - + /// /// To the optimized result. /// @@ -88,6 +91,123 @@ namespace MediaBrowser.Api { return ResultFactory.GetStaticFileResult(RequestContext, path); } + + private readonly char[] _dashReplaceChars = new[] { '?', '/' }; + private const char SlugChar = '-'; + + protected Task GetArtist(string name, ILibraryManager libraryManager) + { + return libraryManager.GetArtist(DeSlugArtistName(name, libraryManager)); + } + + protected Task GetStudio(string name, ILibraryManager libraryManager) + { + return libraryManager.GetStudio(DeSlugStudioName(name, libraryManager)); + } + + protected Task GetGenre(string name, ILibraryManager libraryManager) + { + return libraryManager.GetGenre(DeSlugGenreName(name, libraryManager)); + } + + protected Task GetPerson(string name, ILibraryManager libraryManager) + { + return libraryManager.GetPerson(DeSlugPersonName(name, libraryManager)); + } + + /// + /// Deslugs an artist name by finding the correct entry in the library + /// + /// + /// + /// + protected string DeSlugArtistName(string name, ILibraryManager libraryManager) + { + if (name.IndexOf(SlugChar) == -1) + { + return name; + } + + return libraryManager.RootFolder.RecursiveChildren + .OfType