diff --git a/MediaBrowser.Api/Library/LibraryService.cs b/MediaBrowser.Api/Library/LibraryService.cs index f0633c4b62..9d1df4ccba 100644 --- a/MediaBrowser.Api/Library/LibraryService.cs +++ b/MediaBrowser.Api/Library/LibraryService.cs @@ -134,7 +134,7 @@ namespace MediaBrowser.Api.Library // Get everything var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true)); - var result = new DtoBuilder(Logger).GetBaseItemDto(item, fields.ToList(), _libraryManager).Result; + var result = new DtoBuilder(Logger, _libraryManager).GetBaseItemDto(item, fields.ToList()).Result; return ToOptimizedResult(result); } @@ -151,7 +151,7 @@ namespace MediaBrowser.Api.Library // Get everything var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true)); - var result = new DtoBuilder(Logger).GetBaseItemDto(item, fields.ToList(), _libraryManager).Result; + var result = new DtoBuilder(Logger, _libraryManager).GetBaseItemDto(item, fields.ToList()).Result; return ToOptimizedResult(result); } @@ -168,7 +168,7 @@ namespace MediaBrowser.Api.Library // Get everything var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true)); - var result = new DtoBuilder(Logger).GetBaseItemDto(item, fields.ToList(), _libraryManager).Result; + var result = new DtoBuilder(Logger, _libraryManager).GetBaseItemDto(item, fields.ToList()).Result; return ToOptimizedResult(result); } @@ -185,7 +185,7 @@ namespace MediaBrowser.Api.Library // Get everything var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true)); - var result = new DtoBuilder(Logger).GetBaseItemDto(item, fields.ToList(), _libraryManager).Result; + var result = new DtoBuilder(Logger, _libraryManager).GetBaseItemDto(item, fields.ToList()).Result; return ToOptimizedResult(result); } diff --git a/MediaBrowser.Api/UserLibrary/BaseItemsByNameService.cs b/MediaBrowser.Api/UserLibrary/BaseItemsByNameService.cs index 5fb2097cd2..0a013e90a8 100644 --- a/MediaBrowser.Api/UserLibrary/BaseItemsByNameService.cs +++ b/MediaBrowser.Api/UserLibrary/BaseItemsByNameService.cs @@ -150,7 +150,7 @@ namespace MediaBrowser.Api.UserLibrary return null; } - var dto = await new DtoBuilder(Logger).GetBaseItemDto(item, user, fields, LibraryManager).ConfigureAwait(false); + var dto = await new DtoBuilder(Logger, LibraryManager).GetBaseItemDto(item, user, fields).ConfigureAwait(false); dto.ChildCount = stub.Item2(); diff --git a/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs b/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs index ed1beab6fe..c348bf5f51 100644 --- a/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs +++ b/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs @@ -52,7 +52,7 @@ namespace MediaBrowser.Api.UserLibrary /// Fields to return within the items, in addition to basic information /// /// The fields. - [ApiMember(Name = "Fields", Description = "Optional. Specify additional fields of information to return in the output. This allows multiple, comma delimeted. Options: AudioInfo, Chapters, DateCreated, DisplayMediaType, DisplayPreferences, Genres, ItemCounts, IndexOptions, MediaStreams, Overview, ParentId, Path, People, ProviderIds, PrimaryImageAspectRatio, SeriesInfo, SortName, Studios, Taglines, TrailerUrls, UserData", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)] + [ApiMember(Name = "Fields", Description = "Optional. Specify additional fields of information to return in the output. This allows multiple, comma delimeted. Options: AudioInfo, Chapters, DateCreated, DisplayMediaType, DisplayPreferences, Genres, ItemCounts, IndexOptions, MediaStreams, Overview, OverviewHtml, ParentId, Path, People, ProviderIds, PrimaryImageAspectRatio, SeriesInfo, SortName, Studios, Taglines, TrailerUrls, UserData", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)] public string Fields { get; set; } } } diff --git a/MediaBrowser.Api/UserLibrary/ItemsService.cs b/MediaBrowser.Api/UserLibrary/ItemsService.cs index 13996be19d..9ed6279999 100644 --- a/MediaBrowser.Api/UserLibrary/ItemsService.cs +++ b/MediaBrowser.Api/UserLibrary/ItemsService.cs @@ -169,9 +169,9 @@ namespace MediaBrowser.Api.UserLibrary var fields = GetItemFields(request).ToList(); - var dtoBuilder = new DtoBuilder(Logger); + var dtoBuilder = new DtoBuilder(Logger, _libraryManager); - var returnItems = await Task.WhenAll(pagedItems.Select(i => dtoBuilder.GetBaseItemDto(i, user, fields, _libraryManager))).ConfigureAwait(false); + var returnItems = await Task.WhenAll(pagedItems.Select(i => dtoBuilder.GetBaseItemDto(i, user, fields))).ConfigureAwait(false); return new ItemsResult { diff --git a/MediaBrowser.Api/UserLibrary/UserLibraryService.cs b/MediaBrowser.Api/UserLibrary/UserLibraryService.cs index 88b7dc57c3..9e2d54448c 100644 --- a/MediaBrowser.Api/UserLibrary/UserLibraryService.cs +++ b/MediaBrowser.Api/UserLibrary/UserLibraryService.cs @@ -383,9 +383,9 @@ namespace MediaBrowser.Api.UserLibrary var movie = (Movie)item; - var dtoBuilder = new DtoBuilder(Logger); + var dtoBuilder = new DtoBuilder(Logger, _libraryManager); - var items = movie.SpecialFeatures.Select(i => dtoBuilder.GetBaseItemDto(i, user, fields, _libraryManager)).AsParallel().Select(t => t.Result).ToList(); + var items = movie.SpecialFeatures.Select(i => dtoBuilder.GetBaseItemDto(i, user, fields)).AsParallel().Select(t => t.Result).ToList(); return ToOptimizedResult(items); } @@ -404,9 +404,9 @@ namespace MediaBrowser.Api.UserLibrary // Get everything var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true)).ToList(); - var dtoBuilder = new DtoBuilder(Logger); + var dtoBuilder = new DtoBuilder(Logger, _libraryManager); - var items = item.LocalTrailers.Select(i => dtoBuilder.GetBaseItemDto(i, user, fields, _libraryManager)).AsParallel().Select(t => t.Result).ToList(); + var items = item.LocalTrailers.Select(i => dtoBuilder.GetBaseItemDto(i, user, fields)).AsParallel().Select(t => t.Result).ToList(); return ToOptimizedResult(items); } @@ -425,9 +425,9 @@ namespace MediaBrowser.Api.UserLibrary // Get everything var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true)).ToList(); - var dtoBuilder = new DtoBuilder(Logger); + var dtoBuilder = new DtoBuilder(Logger, _libraryManager); - var result = dtoBuilder.GetBaseItemDto(item, user, fields, _libraryManager).Result; + var result = dtoBuilder.GetBaseItemDto(item, user, fields).Result; return ToOptimizedResult(result); } @@ -441,9 +441,9 @@ namespace MediaBrowser.Api.UserLibrary // Get everything var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true)).ToList(); - var dtoBuilder = new DtoBuilder(Logger); + var dtoBuilder = new DtoBuilder(Logger, _libraryManager); - var result = dtoBuilder.GetBaseItemDto(item, user, fields, _libraryManager).Result; + var result = dtoBuilder.GetBaseItemDto(item, user, fields).Result; return ToOptimizedResult(result); } diff --git a/MediaBrowser.Api/UserService.cs b/MediaBrowser.Api/UserService.cs index b44c38b30f..62958fe118 100644 --- a/MediaBrowser.Api/UserService.cs +++ b/MediaBrowser.Api/UserService.cs @@ -137,13 +137,14 @@ namespace MediaBrowser.Api /// The _user manager /// private readonly IUserManager _userManager; - + private readonly ILibraryManager _libraryManager; + /// /// Initializes a new instance of the class. /// /// The XML serializer. /// xmlSerializer - public UserService(IXmlSerializer xmlSerializer, IUserManager userManager) + public UserService(IXmlSerializer xmlSerializer, IUserManager userManager, ILibraryManager libraryManager) : base() { if (xmlSerializer == null) @@ -153,6 +154,7 @@ namespace MediaBrowser.Api _xmlSerializer = xmlSerializer; _userManager = userManager; + _libraryManager = libraryManager; } /// @@ -162,7 +164,7 @@ namespace MediaBrowser.Api /// System.Object. public object Get(GetUsers request) { - var dtoBuilder = new DtoBuilder(Logger); + var dtoBuilder = new DtoBuilder(Logger, _libraryManager); var tasks = _userManager.Users.OrderBy(u => u.Name).Select(dtoBuilder.GetUserDto).ToArray(); @@ -185,7 +187,7 @@ namespace MediaBrowser.Api throw new ResourceNotFoundException("User not found"); } - var result = new DtoBuilder(Logger).GetUserDto(user).Result; + var result = new DtoBuilder(Logger, _libraryManager).GetUserDto(user).Result; return ToOptimizedResult(result); } @@ -298,8 +300,8 @@ namespace MediaBrowser.Api var newUser = _userManager.CreateUser(dtoUser.Name).Result; newUser.UpdateConfiguration(dtoUser.Configuration, _xmlSerializer); - - var result = new DtoBuilder(Logger).GetUserDto(newUser).Result; + + var result = new DtoBuilder(Logger, _libraryManager).GetUserDto(newUser).Result; return ToOptimizedResult(result); } diff --git a/MediaBrowser.Common/Extensions/BaseExtensions.cs b/MediaBrowser.Common/Extensions/BaseExtensions.cs index de96901408..f91ddfbd5d 100644 --- a/MediaBrowser.Common/Extensions/BaseExtensions.cs +++ b/MediaBrowser.Common/Extensions/BaseExtensions.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Security.Cryptography; using System.Text; +using System.Text.RegularExpressions; namespace MediaBrowser.Common.Extensions { @@ -43,6 +44,18 @@ namespace MediaBrowser.Common.Extensions return val.Split(new[] { separator }, options); } + /// + /// Strips the HTML. + /// + /// The HTML string. + /// System.String. + public static string StripHtml(this string htmlString) + { + // http://stackoverflow.com/questions/1349023/how-can-i-strip-html-from-text-in-net + const string pattern = @"<(.|\n)*?>"; + return Regex.Replace(htmlString, pattern, string.Empty); + } + /// /// Shuffles an IEnumerable /// diff --git a/MediaBrowser.Controller/Library/DtoBuilder.cs b/MediaBrowser.Controller/Library/DtoBuilder.cs index fcd3e68aa3..22e260547e 100644 --- a/MediaBrowser.Controller/Library/DtoBuilder.cs +++ b/MediaBrowser.Controller/Library/DtoBuilder.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Controller.Entities; +using MediaBrowser.Common.Extensions; +using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.Audio; using MediaBrowser.Controller.Entities.Movies; using MediaBrowser.Controller.Entities.TV; @@ -6,12 +7,12 @@ using MediaBrowser.Model.Drawing; using MediaBrowser.Model.Dto; using MediaBrowser.Model.Entities; using MediaBrowser.Model.Logging; +using MediaBrowser.Model.Querying; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Threading.Tasks; -using MediaBrowser.Model.Querying; namespace MediaBrowser.Controller.Library { @@ -26,10 +27,12 @@ namespace MediaBrowser.Controller.Library const string IndexFolderDelimeter = "-index-"; private readonly ILogger _logger; + private readonly ILibraryManager _libraryManager; - public DtoBuilder(ILogger logger) + public DtoBuilder(ILogger logger, ILibraryManager libraryManager) { _logger = logger; + _libraryManager = libraryManager; } /// @@ -39,7 +42,7 @@ namespace MediaBrowser.Controller.Library /// The fields. /// Task{DtoBaseItem}. /// item - public async Task GetBaseItemDto(BaseItem item, List fields, ILibraryManager libraryManager) + public async Task GetBaseItemDto(BaseItem item, List fields) { if (item == null) { @@ -74,7 +77,7 @@ namespace MediaBrowser.Controller.Library if (fields.Contains(ItemFields.People)) { - tasks.Add(AttachPeople(dto, item, libraryManager)); + tasks.Add(AttachPeople(dto, item)); } AttachBasicFields(dto, item, fields); @@ -94,10 +97,9 @@ namespace MediaBrowser.Controller.Library /// The item. /// The user. /// The fields. - /// The library manager. /// Task{DtoBaseItem}. /// item - public async Task GetBaseItemDto(BaseItem item, User user, List fields, ILibraryManager libraryManager) + public async Task GetBaseItemDto(BaseItem item, User user, List fields) { if (item == null) { @@ -136,7 +138,7 @@ namespace MediaBrowser.Controller.Library if (fields.Contains(ItemFields.People)) { - tasks.Add(AttachPeople(dto, item, libraryManager)); + tasks.Add(AttachPeople(dto, item)); } AttachBasicFields(dto, item, fields); @@ -296,6 +298,11 @@ namespace MediaBrowser.Controller.Library dto.Overview = item.Overview; } + if (fields.Contains(ItemFields.OverviewHtml)) + { + dto.OverviewHtml = string.IsNullOrEmpty(item.Overview) ? item.Overview : item.Overview.StripHtml(); + } + // If there are no backdrops, indicate what parent has them in case the Ui wants to allow inheritance if (dto.BackdropImageTags.Count == 0) { @@ -515,7 +522,7 @@ namespace MediaBrowser.Controller.Library /// The item. /// The library manager. /// Task. - private async Task AttachPeople(BaseItemDto dto, BaseItem item, ILibraryManager libraryManager) + private async Task AttachPeople(BaseItemDto dto, BaseItem item) { if (item.People == null) { @@ -531,7 +538,7 @@ namespace MediaBrowser.Controller.Library { try { - return await libraryManager.GetPerson(c.Name).ConfigureAwait(false); + return await _libraryManager.GetPerson(c.Name).ConfigureAwait(false); } catch (IOException ex) { diff --git a/MediaBrowser.Controller/Providers/MediaInfo/BaseFFProbeProvider.cs b/MediaBrowser.Controller/Providers/MediaInfo/BaseFFProbeProvider.cs index c9f184fcf0..e616118288 100644 --- a/MediaBrowser.Controller/Providers/MediaInfo/BaseFFProbeProvider.cs +++ b/MediaBrowser.Controller/Providers/MediaInfo/BaseFFProbeProvider.cs @@ -2,14 +2,13 @@ using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.MediaInfo; -using MediaBrowser.Controller.Persistence; using MediaBrowser.Model.Entities; +using MediaBrowser.Model.Logging; using System; using System.Collections.Generic; using System.IO; using System.Threading; using System.Threading.Tasks; -using MediaBrowser.Model.Logging; namespace MediaBrowser.Controller.Providers.MediaInfo { diff --git a/MediaBrowser.Controller/Providers/Music/LastfmBaseProvider.cs b/MediaBrowser.Controller/Providers/Music/LastfmBaseProvider.cs index c3ff411ef9..97bfa45703 100644 --- a/MediaBrowser.Controller/Providers/Music/LastfmBaseProvider.cs +++ b/MediaBrowser.Controller/Providers/Music/LastfmBaseProvider.cs @@ -54,7 +54,7 @@ namespace MediaBrowser.Controller.Providers.Music { get { - return "3-12-13.2"; + return "3-12-13.3"; } } diff --git a/MediaBrowser.Controller/Providers/Music/LastfmHelper.cs b/MediaBrowser.Controller/Providers/Music/LastfmHelper.cs index 8c80b4ef15..2ffdbdc6b8 100644 --- a/MediaBrowser.Controller/Providers/Music/LastfmHelper.cs +++ b/MediaBrowser.Controller/Providers/Music/LastfmHelper.cs @@ -1,11 +1,7 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.RegularExpressions; -using System.Threading.Tasks; +using MediaBrowser.Common.Extensions; using MediaBrowser.Controller.Entities; using MediaBrowser.Model.Entities; +using System; namespace MediaBrowser.Controller.Providers.Music { @@ -18,11 +14,6 @@ namespace MediaBrowser.Controller.Providers.Music { var overview = data.bio != null ? data.bio.content : null; - if (!string.IsNullOrEmpty(overview)) - { - overview = StripHtml(overview); - } - artist.Overview = overview; var yearFormed = 0; @@ -53,11 +44,6 @@ namespace MediaBrowser.Controller.Providers.Music var overview = data.wiki != null ? data.wiki.content : null; - if (!string.IsNullOrEmpty(overview)) - { - overview = StripHtml(overview); - } - item.Overview = overview; var release = DateTime.MinValue; @@ -70,13 +56,6 @@ namespace MediaBrowser.Controller.Providers.Music } } - private static string StripHtml(string htmlString) - { - // http://stackoverflow.com/questions/1349023/how-can-i-strip-html-from-text-in-net - const string pattern = @"<(.|\n)*?>"; - return Regex.Replace(htmlString, pattern, string.Empty); - } - private static void AddGenres(BaseItem item, LastfmTags tags) { foreach (var tag in tags.tag) diff --git a/MediaBrowser.Model/DTO/BaseItemDto.cs b/MediaBrowser.Model/DTO/BaseItemDto.cs index 5b63f588cb..b4d6aecd9b 100644 --- a/MediaBrowser.Model/DTO/BaseItemDto.cs +++ b/MediaBrowser.Model/DTO/BaseItemDto.cs @@ -426,6 +426,13 @@ namespace MediaBrowser.Model.Dto [ProtoMember(69)] public string MediaType { get; set; } + /// + /// Gets or sets the overview HTML. + /// + /// The overview HTML. + [ProtoMember(70)] + public string OverviewHtml { get; set; } + /// /// Gets a value indicating whether this instance can resume. /// diff --git a/MediaBrowser.Model/Querying/ItemFields.cs b/MediaBrowser.Model/Querying/ItemFields.cs index 8cf9796c0e..7e57f8f905 100644 --- a/MediaBrowser.Model/Querying/ItemFields.cs +++ b/MediaBrowser.Model/Querying/ItemFields.cs @@ -51,6 +51,11 @@ namespace MediaBrowser.Model.Querying /// Overview, + /// + /// The overview HTML + /// + OverviewHtml, + /// /// The id of the item's parent /// diff --git a/MediaBrowser.ServerApplication/EntryPoints/WebSocketEvents.cs b/MediaBrowser.ServerApplication/EntryPoints/WebSocketEvents.cs index b498a6fe4c..2ee3193dc9 100644 --- a/MediaBrowser.ServerApplication/EntryPoints/WebSocketEvents.cs +++ b/MediaBrowser.ServerApplication/EntryPoints/WebSocketEvents.cs @@ -174,7 +174,7 @@ namespace MediaBrowser.ServerApplication.EntryPoints /// The e. async void userManager_UserUpdated(object sender, GenericEventArgs e) { - var dto = await new DtoBuilder(_logger).GetUserDto(e.Argument).ConfigureAwait(false); + var dto = await new DtoBuilder(_logger, _libraryManager).GetUserDto(e.Argument).ConfigureAwait(false); _serverManager.SendWebSocketMessage("UserUpdated", dto); } diff --git a/MediaBrowser.WebDashboard/Api/DashboardInfoWebSocketListener.cs b/MediaBrowser.WebDashboard/Api/DashboardInfoWebSocketListener.cs index 38d5d32a80..5fc1f75c5d 100644 --- a/MediaBrowser.WebDashboard/Api/DashboardInfoWebSocketListener.cs +++ b/MediaBrowser.WebDashboard/Api/DashboardInfoWebSocketListener.cs @@ -35,6 +35,7 @@ namespace MediaBrowser.WebDashboard.Api /// The _user manager /// private readonly IUserManager _userManager; + private readonly ILibraryManager _libraryManager; /// /// Initializes a new instance of the class. @@ -57,7 +58,7 @@ namespace MediaBrowser.WebDashboard.Api /// Task{IEnumerable{TaskInfo}}. protected override Task GetDataToSend(object state) { - return DashboardService.GetDashboardInfo(_appHost, Logger, _taskManager, _userManager); + return DashboardService.GetDashboardInfo(_appHost, Logger, _taskManager, _userManager, _libraryManager); } } } diff --git a/MediaBrowser.WebDashboard/Api/DashboardService.cs b/MediaBrowser.WebDashboard/Api/DashboardService.cs index 4c861c61bd..150341b885 100644 --- a/MediaBrowser.WebDashboard/Api/DashboardService.cs +++ b/MediaBrowser.WebDashboard/Api/DashboardService.cs @@ -91,17 +91,19 @@ namespace MediaBrowser.WebDashboard.Api private readonly IUserManager _userManager; private readonly IServerApplicationHost _appHost; + private readonly ILibraryManager _libraryManager; /// /// Initializes a new instance of the class. /// /// The task manager. /// The user manager. - public DashboardService(ITaskManager taskManager, IUserManager userManager, IServerApplicationHost appHost) + public DashboardService(ITaskManager taskManager, IUserManager userManager, IServerApplicationHost appHost, ILibraryManager libraryManager) { _taskManager = taskManager; _userManager = userManager; _appHost = appHost; + _libraryManager = libraryManager; } /// @@ -111,7 +113,7 @@ namespace MediaBrowser.WebDashboard.Api /// System.Object. public object Get(GetDashboardInfo request) { - return GetDashboardInfo(_appHost, Logger, _taskManager, _userManager).Result; + return GetDashboardInfo(_appHost, Logger, _taskManager, _userManager, _libraryManager).Result; } /// @@ -121,11 +123,11 @@ namespace MediaBrowser.WebDashboard.Api /// The task manager. /// The user manager. /// DashboardInfo. - public static async Task GetDashboardInfo(IServerApplicationHost appHost, ILogger logger, ITaskManager taskManager, IUserManager userManager) + public static async Task GetDashboardInfo(IServerApplicationHost appHost, ILogger logger, ITaskManager taskManager, IUserManager userManager, ILibraryManager libraryManager) { var connections = userManager.ConnectedUsers.ToArray(); - var dtoBuilder = new DtoBuilder(logger); + var dtoBuilder = new DtoBuilder(logger, libraryManager); var tasks = userManager.Users.Where(u => connections.Any(c => c.UserId == u.Id)).Select(dtoBuilder.GetUserDto); var users = await Task.WhenAll(tasks).ConfigureAwait(false); diff --git a/MediaBrowser.sln b/MediaBrowser.sln index 16caa617d6..c13ad6f819 100644 --- a/MediaBrowser.sln +++ b/MediaBrowser.sln @@ -237,4 +237,7 @@ Global GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(Performance) = preSolution + HasPerformanceSessions = true + EndGlobalSection EndGlobal