From a3ecf6c2b7760935de541568cfdfa3c1c09edda9 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 21 May 2013 23:42:25 -0400 Subject: localize library changed messages per user --- .../Library/LibraryManager.cs | 19 +++++++++-- .../ServerManager/ServerManager.cs | 38 +++++++++++++++++++--- 2 files changed, 50 insertions(+), 7 deletions(-) (limited to 'MediaBrowser.Server.Implementations') diff --git a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs index 2068ac0da6..72cf42c14c 100644 --- a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs +++ b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs @@ -32,7 +32,7 @@ namespace MediaBrowser.Server.Implementations.Library public class LibraryManager : ILibraryManager { private IEnumerable PrescanTasks { get; set; } - + /// /// Gets the intro providers. /// @@ -306,7 +306,20 @@ namespace MediaBrowser.Server.Implementations.Library /// BaseItem. public BaseItem ResolveItem(ItemResolveArgs args) { - var item = EntityResolvers.Select(r => r.ResolvePath(args)).FirstOrDefault(i => i != null); + var item = EntityResolvers.Select(r => + { + try + { + return r.ResolvePath(args); + } + catch (Exception ex) + { + _logger.ErrorException("Error in {0} resolving {1}", ex, r.GetType().Name, args.Path); + + return null; + } + + }).FirstOrDefault(i => i != null); if (item != null) { @@ -1028,7 +1041,7 @@ namespace MediaBrowser.Server.Implementations.Library await SaveItem(item, cancellationToken).ConfigureAwait(false); UpdateItemInLibraryCache(item); - + if (ItemAdded != null) { try diff --git a/MediaBrowser.Server.Implementations/ServerManager/ServerManager.cs b/MediaBrowser.Server.Implementations/ServerManager/ServerManager.cs index a45804f69c..f8e47434e2 100644 --- a/MediaBrowser.Server.Implementations/ServerManager/ServerManager.cs +++ b/MediaBrowser.Server.Implementations/ServerManager/ServerManager.cs @@ -36,6 +36,14 @@ namespace MediaBrowser.Server.Implementations.ServerManager /// The web socket connections /// private readonly List _webSocketConnections = new List(); + /// + /// Gets the web socket connections. + /// + /// The web socket connections. + public IEnumerable WebSocketConnections + { + get { return _webSocketConnections; } + } /// /// Gets or sets the external web socket server. @@ -83,6 +91,9 @@ namespace MediaBrowser.Server.Implementations.ServerManager /// The web socket listeners. private readonly List _webSocketListeners = new List(); + /// + /// The _kernel + /// private readonly Kernel _kernel; /// @@ -240,7 +251,26 @@ namespace MediaBrowser.Server.Implementations.ServerManager /// The cancellation token. /// Task. /// messageType - public async Task SendWebSocketMessageAsync(string messageType, Func dataFunction, CancellationToken cancellationToken) + public Task SendWebSocketMessageAsync(string messageType, Func dataFunction, CancellationToken cancellationToken) + { + return SendWebSocketMessageAsync(messageType, dataFunction, _webSocketConnections, cancellationToken); + } + + /// + /// Sends the web socket message async. + /// + /// + /// Type of the message. + /// The data function. + /// The connections. + /// The cancellation token. + /// Task. + /// messageType + /// or + /// dataFunction + /// or + /// cancellationToken + public async Task SendWebSocketMessageAsync(string messageType, Func dataFunction, IEnumerable connections, CancellationToken cancellationToken) { if (string.IsNullOrEmpty(messageType)) { @@ -259,16 +289,16 @@ namespace MediaBrowser.Server.Implementations.ServerManager cancellationToken.ThrowIfCancellationRequested(); - var connections = _webSocketConnections.Where(s => s.State == WebSocketState.Open).ToList(); + var connectionsList = connections.Where(s => s.State == WebSocketState.Open).ToList(); - if (connections.Count > 0) + if (connectionsList.Count > 0) { _logger.Info("Sending web socket message {0}", messageType); var message = new WebSocketMessage { MessageType = messageType, Data = dataFunction() }; var bytes = _jsonSerializer.SerializeToBytes(message); - var tasks = connections.Select(s => Task.Run(() => + var tasks = connectionsList.Select(s => Task.Run(() => { try { -- cgit v1.2.3 From b310c986568bf44f72a9ca42deab54966a1867f0 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 21 May 2013 23:59:55 -0400 Subject: updated nuget --- MediaBrowser.Controller/Dto/SessionInfoDtoBuilder.cs | 3 ++- MediaBrowser.Controller/Session/SessionInfo.cs | 8 +++++++- MediaBrowser.Model/Session/SessionInfoDto.cs | 8 +++++++- .../Session/SessionWebSocketListener.cs | 5 +++-- Nuget/MediaBrowser.Common.Internal.nuspec | 4 ++-- Nuget/MediaBrowser.Common.nuspec | 2 +- Nuget/MediaBrowser.Server.Core.nuspec | 4 ++-- 7 files changed, 24 insertions(+), 10 deletions(-) (limited to 'MediaBrowser.Server.Implementations') diff --git a/MediaBrowser.Controller/Dto/SessionInfoDtoBuilder.cs b/MediaBrowser.Controller/Dto/SessionInfoDtoBuilder.cs index 27a237ba7f..ce8e510b8c 100644 --- a/MediaBrowser.Controller/Dto/SessionInfoDtoBuilder.cs +++ b/MediaBrowser.Controller/Dto/SessionInfoDtoBuilder.cs @@ -26,7 +26,8 @@ namespace MediaBrowser.Controller.Dto SupportsRemoteControl = session.SupportsRemoteControl, IsPaused = session.IsPaused, NowViewingContext = session.NowViewingContext, - NowViewingItemIdentifier = session.NowViewingItemIdentifier, + NowViewingItemId = session.NowViewingItemId, + NowViewingItemName = session.NowViewingItemName, NowViewingItemType = session.NowViewingItemType }; diff --git a/MediaBrowser.Controller/Session/SessionInfo.cs b/MediaBrowser.Controller/Session/SessionInfo.cs index c9ed47756b..c3651974b3 100644 --- a/MediaBrowser.Controller/Session/SessionInfo.cs +++ b/MediaBrowser.Controller/Session/SessionInfo.cs @@ -63,7 +63,13 @@ namespace MediaBrowser.Controller.Session /// Gets or sets the now viewing item identifier. /// /// The now viewing item identifier. - public string NowViewingItemIdentifier { get; set; } + public string NowViewingItemId { get; set; } + + /// + /// Gets or sets the name of the now viewing item. + /// + /// The name of the now viewing item. + public string NowViewingItemName { get; set; } /// /// Gets or sets the now playing item. diff --git a/MediaBrowser.Model/Session/SessionInfoDto.cs b/MediaBrowser.Model/Session/SessionInfoDto.cs index 2b9c1a64e7..879d496b2e 100644 --- a/MediaBrowser.Model/Session/SessionInfoDto.cs +++ b/MediaBrowser.Model/Session/SessionInfoDto.cs @@ -45,7 +45,13 @@ namespace MediaBrowser.Model.Session /// Gets or sets the now viewing item identifier. /// /// The now viewing item identifier. - public string NowViewingItemIdentifier { get; set; } + public string NowViewingItemId { get; set; } + + /// + /// Gets or sets the name of the now viewing item. + /// + /// The name of the now viewing item. + public string NowViewingItemName { get; set; } /// /// Gets or sets the name of the device. diff --git a/MediaBrowser.Server.Implementations/Session/SessionWebSocketListener.cs b/MediaBrowser.Server.Implementations/Session/SessionWebSocketListener.cs index 19d177a948..44e833c7a7 100644 --- a/MediaBrowser.Server.Implementations/Session/SessionWebSocketListener.cs +++ b/MediaBrowser.Server.Implementations/Session/SessionWebSocketListener.cs @@ -82,8 +82,9 @@ namespace MediaBrowser.Server.Implementations.Session var vals = message.Data.Split('|'); session.NowViewingItemType = vals[0]; - session.NowViewingItemIdentifier = vals[1]; - session.NowViewingContext = vals.Length > 2 ? vals[2] : null; + session.NowViewingItemId = vals[1]; + session.NowViewingItemName = vals[2]; + session.NowViewingContext = vals.Length > 3 ? vals[3] : null; } } else if (string.Equals(message.MessageType, "PlaybackStart", StringComparison.OrdinalIgnoreCase)) diff --git a/Nuget/MediaBrowser.Common.Internal.nuspec b/Nuget/MediaBrowser.Common.Internal.nuspec index 13b1bae99b..e4955edc42 100644 --- a/Nuget/MediaBrowser.Common.Internal.nuspec +++ b/Nuget/MediaBrowser.Common.Internal.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common.Internal - 3.0.104 + 3.0.105 MediaBrowser.Common.Internal Luke ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains common components shared by Media Browser Theatre and Media Browser Server. Not intended for plugin developer consumption. Copyright © Media Browser 2013 - + diff --git a/Nuget/MediaBrowser.Common.nuspec b/Nuget/MediaBrowser.Common.nuspec index a8530230c3..e43c7c2276 100644 --- a/Nuget/MediaBrowser.Common.nuspec +++ b/Nuget/MediaBrowser.Common.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common - 3.0.104 + 3.0.105 MediaBrowser.Common Media Browser Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Server.Core.nuspec b/Nuget/MediaBrowser.Server.Core.nuspec index 8236cd6333..5676f2ab68 100644 --- a/Nuget/MediaBrowser.Server.Core.nuspec +++ b/Nuget/MediaBrowser.Server.Core.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Server.Core - 3.0.104 + 3.0.105 Media Browser.Server.Core Media Browser Team ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains core components required to build plugins for Media Browser Server. Copyright © Media Browser 2013 - + -- cgit v1.2.3 From 95afe143e8c6cd2dfa93cae3421d64b9885dfcba Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 22 May 2013 00:21:36 -0400 Subject: add refresh item api method --- MediaBrowser.Api/LibraryService.cs | 24 ++++++++++- .../Providers/ProviderManager.cs | 47 ++-------------------- 2 files changed, 26 insertions(+), 45 deletions(-) (limited to 'MediaBrowser.Server.Implementations') diff --git a/MediaBrowser.Api/LibraryService.cs b/MediaBrowser.Api/LibraryService.cs index 87bf08e636..1018053ccf 100644 --- a/MediaBrowser.Api/LibraryService.cs +++ b/MediaBrowser.Api/LibraryService.cs @@ -96,6 +96,17 @@ namespace MediaBrowser.Api { } + [Route("/Items/{Id}/Refresh", "POST")] + [Api(Description = "Refreshes metadata for an item")] + public class RefreshItem : IReturnVoid + { + [ApiMember(Name = "IsForced", Description = "Indicates if a normal or forced refresh should occur.", IsRequired = true, DataType = "bool", ParameterType = "query", Verb = "POST")] + public bool IsForced { get; set; } + + [ApiMember(Name = "Id", Description = "Item Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "POST")] + public string Id { get; set; } + } + [Route("/Items/Counts", "GET")] [Api(Description = "Gets counts of various item types")] public class GetItemCounts : IReturn @@ -304,6 +315,17 @@ namespace MediaBrowser.Api return ToOptimizedResult(result); } + /// + /// Posts the specified request. + /// + /// The request. + public void Post(RefreshItem request) + { + var item = DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager); + + item.RefreshMetadata(CancellationToken.None, forceRefresh: request.IsForced); + } + /// /// Gets the specified request. /// @@ -467,7 +489,7 @@ namespace MediaBrowser.Api { var artists1 = item1.RecursiveChildren .OfType