From bd8513270203a77cf17f1944c18feb6eec4aec29 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 21 May 2013 21:53:18 -0400 Subject: [PATCH 1/7] support 5.1 aac --- MediaBrowser.Api/Playback/BaseStreamingService.cs | 5 ----- MediaBrowser.Api/Playback/Hls/AudioHlsService.cs | 5 +++++ MediaBrowser.Api/Playback/Hls/VideoHlsService.cs | 5 +++++ MediaBrowser.Api/Playback/Progressive/AudioService.cs | 7 +++++++ MediaBrowser.Api/Playback/Progressive/VideoService.cs | 5 +++++ 5 files changed, 22 insertions(+), 5 deletions(-) diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index b2b37a1acb..7f3c7ca9e4 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -426,11 +426,6 @@ namespace MediaBrowser.Api.Playback { if (audioStream.Channels > 2 && request.AudioCodec.HasValue) { - if (request.AudioCodec.Value == AudioCodecs.Aac) - { - // libvo_aacenc currently only supports two channel output - return 2; - } if (request.AudioCodec.Value == AudioCodecs.Wma) { // wmav2 currently only supports two channel output diff --git a/MediaBrowser.Api/Playback/Hls/AudioHlsService.cs b/MediaBrowser.Api/Playback/Hls/AudioHlsService.cs index f72006a235..a666d46280 100644 --- a/MediaBrowser.Api/Playback/Hls/AudioHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/AudioHlsService.cs @@ -93,6 +93,11 @@ namespace MediaBrowser.Api.Playback.Hls var args = "-codec:a " + codec; + if (string.Equals(codec, "aac", StringComparison.OrdinalIgnoreCase)) + { + args += " -strict experimental"; + } + var channels = GetNumAudioChannelsParam(state.Request, state.AudioStream); if (channels.HasValue) diff --git a/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs b/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs index 42a1bf839f..8273335989 100644 --- a/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs @@ -98,6 +98,11 @@ namespace MediaBrowser.Api.Playback.Hls if (state.AudioStream != null) { + if (string.Equals(codec, "aac", StringComparison.OrdinalIgnoreCase)) + { + args += " -strict experimental"; + } + var channels = GetNumAudioChannelsParam(state.Request, state.AudioStream); if (channels.HasValue) diff --git a/MediaBrowser.Api/Playback/Progressive/AudioService.cs b/MediaBrowser.Api/Playback/Progressive/AudioService.cs index f5a95d898f..b6a7c72046 100644 --- a/MediaBrowser.Api/Playback/Progressive/AudioService.cs +++ b/MediaBrowser.Api/Playback/Progressive/AudioService.cs @@ -3,7 +3,9 @@ using MediaBrowser.Common.MediaInfo; using MediaBrowser.Controller; using MediaBrowser.Controller.Library; using ServiceStack.ServiceHost; +using System; using System.Collections.Generic; +using System.IO; namespace MediaBrowser.Api.Playback.Progressive { @@ -84,6 +86,11 @@ namespace MediaBrowser.Api.Playback.Progressive var audioTranscodeParams = new List(); + if (string.Equals(Path.GetExtension(outputPath), ".aac", StringComparison.OrdinalIgnoreCase)) + { + audioTranscodeParams.Add("-strict experimental"); + } + if (request.AudioBitRate.HasValue) { audioTranscodeParams.Add("-ab " + request.AudioBitRate.Value); diff --git a/MediaBrowser.Api/Playback/Progressive/VideoService.cs b/MediaBrowser.Api/Playback/Progressive/VideoService.cs index 117b6033f5..3e92c96ec4 100644 --- a/MediaBrowser.Api/Playback/Progressive/VideoService.cs +++ b/MediaBrowser.Api/Playback/Progressive/VideoService.cs @@ -217,6 +217,11 @@ namespace MediaBrowser.Api.Playback.Progressive var args = "-acodec " + codec; + if (string.Equals(codec, "aac", StringComparison.OrdinalIgnoreCase)) + { + args += " -strict experimental"; + } + // Add the number of audio channels var channels = GetNumAudioChannelsParam(request, state.AudioStream); From a3ecf6c2b7760935de541568cfdfa3c1c09edda9 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 21 May 2013 23:42:25 -0400 Subject: [PATCH 2/7] localize library changed messages per user --- .../HttpClientManager/HttpClientManager.cs | 22 +-- MediaBrowser.Common/Net/IServerManager.cs | 17 ++ .../Providers/Music/LastfmArtistProvider.cs | 2 +- .../Library/LibraryManager.cs | 19 +- .../ServerManager/ServerManager.cs | 38 +++- .../EntryPoints/LibraryChangedNotifier.cs | 164 ++++++++++++++---- .../MediaBrowser.ServerApplication.csproj | 4 + .../packages.config | 1 + 8 files changed, 214 insertions(+), 53 deletions(-) diff --git a/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs b/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs index c84239f92a..99ce17ebdd 100644 --- a/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs +++ b/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs @@ -162,17 +162,17 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager using (var message = GetHttpRequestMessage(options)) { - if (options.EnableResponseCache && cachedInfo != null) - { - if (!string.IsNullOrEmpty(cachedInfo.Etag)) - { - message.Headers.Add("If-None-Match", cachedInfo.Etag); - } - else if (cachedInfo.LastModified.HasValue) - { - message.Headers.IfModifiedSince = new DateTimeOffset(cachedInfo.LastModified.Value); - } - } + //if (options.EnableResponseCache && cachedInfo != null) + //{ + // if (!string.IsNullOrEmpty(cachedInfo.Etag)) + // { + // message.Headers.Add("If-None-Match", cachedInfo.Etag); + // } + // else if (cachedInfo.LastModified.HasValue) + // { + // message.Headers.IfModifiedSince = new DateTimeOffset(cachedInfo.LastModified.Value); + // } + //} if (options.ResourcePool != null) { diff --git a/MediaBrowser.Common/Net/IServerManager.cs b/MediaBrowser.Common/Net/IServerManager.cs index 0f95c775ed..3234e70600 100644 --- a/MediaBrowser.Common/Net/IServerManager.cs +++ b/MediaBrowser.Common/Net/IServerManager.cs @@ -52,10 +52,27 @@ namespace MediaBrowser.Common.Net /// messageType Task SendWebSocketMessageAsync(string messageType, Func dataFunction, CancellationToken cancellationToken); + /// + /// Sends the web socket message async. + /// + /// + /// Type of the message. + /// The data function. + /// The connections. + /// The cancellation token. + /// Task. + Task SendWebSocketMessageAsync(string messageType, Func dataFunction, IEnumerable connections, CancellationToken cancellationToken); + /// /// Adds the web socket listeners. /// /// The listeners. void AddWebSocketListeners(IEnumerable listeners); + + /// + /// Gets the web socket connections. + /// + /// The web socket connections. + IEnumerable WebSocketConnections { get; } } } \ No newline at end of file diff --git a/MediaBrowser.Controller/Providers/Music/LastfmArtistProvider.cs b/MediaBrowser.Controller/Providers/Music/LastfmArtistProvider.cs index 4837b4da9b..588f6db4fc 100644 --- a/MediaBrowser.Controller/Providers/Music/LastfmArtistProvider.cs +++ b/MediaBrowser.Controller/Providers/Music/LastfmArtistProvider.cs @@ -83,7 +83,7 @@ namespace MediaBrowser.Controller.Providers.Music private string FindIdFromMusicArtistEntity(BaseItem item) { var artist = _libraryManager.RootFolder.RecursiveChildren.OfType() - .FirstOrDefault(i => string.Equals(i.Name, item.Name, StringComparison.OrdinalIgnoreCase)); + .FirstOrDefault(i => string.Compare(i.Name, item.Name, CultureInfo.CurrentCulture, CompareOptions.IgnoreNonSpace | CompareOptions.IgnoreCase | CompareOptions.IgnoreSymbols) == 0); return artist != null ? artist.GetProviderId(MetadataProviders.Musicbrainz) : null; } 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 { diff --git a/MediaBrowser.ServerApplication/EntryPoints/LibraryChangedNotifier.cs b/MediaBrowser.ServerApplication/EntryPoints/LibraryChangedNotifier.cs index 62c1e17f90..715492aac4 100644 --- a/MediaBrowser.ServerApplication/EntryPoints/LibraryChangedNotifier.cs +++ b/MediaBrowser.ServerApplication/EntryPoints/LibraryChangedNotifier.cs @@ -1,8 +1,12 @@ using MediaBrowser.Common.Net; +using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Plugins; using MediaBrowser.Controller.Session; using MediaBrowser.Model.Entities; +using MoreLinq; +using System; +using System.Collections.Generic; using System.Linq; using System.Threading; @@ -17,17 +21,19 @@ namespace MediaBrowser.ServerApplication.EntryPoints private readonly ISessionManager _sessionManager; private readonly IServerManager _serverManager; - + private readonly IUserManager _userManager; + /// /// The _library changed sync lock /// private readonly object _libraryChangedSyncLock = new object(); - /// - /// Gets or sets the library update info. - /// - /// The library update info. - private LibraryUpdateInfo LibraryUpdateInfo { get; set; } + private readonly List _foldersAddedTo = new List(); + private readonly List _foldersRemovedFrom = new List(); + + private readonly List _itemsAdded = new List(); + private readonly List _itemsRemoved = new List(); + private readonly List _itemsUpdated = new List(); /// /// Gets or sets the library update timer. @@ -40,11 +46,12 @@ namespace MediaBrowser.ServerApplication.EntryPoints /// private const int LibraryUpdateDuration = 60000; - public LibraryChangedNotifier(ILibraryManager libraryManager, ISessionManager sessionManager, IServerManager serverManager) + public LibraryChangedNotifier(ILibraryManager libraryManager, ISessionManager sessionManager, IServerManager serverManager, IUserManager userManager) { _libraryManager = libraryManager; _sessionManager = sessionManager; _serverManager = serverManager; + _userManager = userManager; } public void Run() @@ -64,11 +71,6 @@ namespace MediaBrowser.ServerApplication.EntryPoints { lock (_libraryChangedSyncLock) { - if (LibraryUpdateInfo == null) - { - LibraryUpdateInfo = new LibraryUpdateInfo(); - } - if (LibraryUpdateTimer == null) { LibraryUpdateTimer = new Timer(LibraryUpdateTimerCallback, null, LibraryUpdateDuration, @@ -81,10 +83,10 @@ namespace MediaBrowser.ServerApplication.EntryPoints if (e.Item.Parent != null) { - LibraryUpdateInfo.FoldersAddedTo.Add(e.Item.Parent.Id); + _foldersAddedTo.Add(e.Item.Parent); } - LibraryUpdateInfo.ItemsAdded.Add(e.Item.Id); + _itemsAdded.Add(e.Item); } } @@ -97,11 +99,6 @@ namespace MediaBrowser.ServerApplication.EntryPoints { lock (_libraryChangedSyncLock) { - if (LibraryUpdateInfo == null) - { - LibraryUpdateInfo = new LibraryUpdateInfo(); - } - if (LibraryUpdateTimer == null) { LibraryUpdateTimer = new Timer(LibraryUpdateTimerCallback, null, LibraryUpdateDuration, @@ -112,7 +109,7 @@ namespace MediaBrowser.ServerApplication.EntryPoints LibraryUpdateTimer.Change(LibraryUpdateDuration, Timeout.Infinite); } - LibraryUpdateInfo.ItemsUpdated.Add(e.Item.Id); + _itemsUpdated.Add(e.Item); } } @@ -125,11 +122,6 @@ namespace MediaBrowser.ServerApplication.EntryPoints { lock (_libraryChangedSyncLock) { - if (LibraryUpdateInfo == null) - { - LibraryUpdateInfo = new LibraryUpdateInfo(); - } - if (LibraryUpdateTimer == null) { LibraryUpdateTimer = new Timer(LibraryUpdateTimerCallback, null, LibraryUpdateDuration, @@ -142,10 +134,10 @@ namespace MediaBrowser.ServerApplication.EntryPoints if (e.Item.Parent != null) { - LibraryUpdateInfo.FoldersRemovedFrom.Add(e.Item.Parent.Id); + _foldersRemovedFrom.Add(e.Item.Parent); } - LibraryUpdateInfo.ItemsRemoved.Add(e.Item.Id); + _itemsRemoved.Add(e.Item); } } @@ -158,16 +150,16 @@ namespace MediaBrowser.ServerApplication.EntryPoints lock (_libraryChangedSyncLock) { // Remove dupes in case some were saved multiple times - LibraryUpdateInfo.FoldersAddedTo = LibraryUpdateInfo.FoldersAddedTo.Distinct().ToList(); + var foldersAddedTo = _foldersAddedTo.DistinctBy(i => i.Id).ToList(); - LibraryUpdateInfo.FoldersRemovedFrom = LibraryUpdateInfo.FoldersRemovedFrom.Distinct().ToList(); + var foldersRemovedFrom = _foldersRemovedFrom.DistinctBy(i => i.Id).ToList(); - LibraryUpdateInfo.ItemsUpdated = LibraryUpdateInfo.ItemsUpdated - .Where(i => !LibraryUpdateInfo.ItemsAdded.Contains(i)) - .Distinct() + var itemsUpdated = _itemsUpdated + .Where(i => !_itemsAdded.Contains(i)) + .DistinctBy(i => i.Id) .ToList(); - _serverManager.SendWebSocketMessage("LibraryChanged", LibraryUpdateInfo); + SendChangeNotifications(_itemsAdded.ToList(), itemsUpdated, _itemsRemoved.ToList(), foldersAddedTo, foldersRemovedFrom, CancellationToken.None); if (LibraryUpdateTimer != null) { @@ -175,8 +167,112 @@ namespace MediaBrowser.ServerApplication.EntryPoints LibraryUpdateTimer = null; } - LibraryUpdateInfo = null; + _itemsAdded.Clear(); + _itemsRemoved.Clear(); + _itemsUpdated.Clear(); + _foldersAddedTo.Clear(); + _foldersRemovedFrom.Clear(); + } + } + + /// + /// Sends the change notifications. + /// + /// The items added. + /// The items updated. + /// The items removed. + /// The folders added to. + /// The folders removed from. + /// The cancellation token. + private async void SendChangeNotifications(IEnumerable itemsAdded, IEnumerable itemsUpdated, IEnumerable itemsRemoved, IEnumerable foldersAddedTo, IEnumerable foldersRemovedFrom, CancellationToken cancellationToken) + { + var currentSessions = _sessionManager.Sessions.ToList(); + + var users = currentSessions.Select(i => i.UserId ?? Guid.Empty).Where(i => i != Guid.Empty).Distinct().ToList(); + + foreach (var userId in users) + { + var id = userId; + var webSockets = currentSessions.Where(u => u.UserId.HasValue && u.UserId.Value == id).SelectMany(i => i.WebSockets).ToList(); + + await _serverManager.SendWebSocketMessageAsync("LibraryChanged", () => GetLibraryUpdateInfo(itemsAdded, itemsUpdated, itemsRemoved, foldersAddedTo, foldersRemovedFrom, id), webSockets, cancellationToken).ConfigureAwait(false); + } + } + + /// + /// Gets the library update info. + /// + /// The items added. + /// The items updated. + /// The items removed. + /// The folders added to. + /// The folders removed from. + /// The user id. + /// LibraryUpdateInfo. + private LibraryUpdateInfo GetLibraryUpdateInfo(IEnumerable itemsAdded, IEnumerable itemsUpdated, IEnumerable itemsRemoved, IEnumerable foldersAddedTo, IEnumerable foldersRemovedFrom, Guid userId) + { + var user = _userManager.GetUserById(userId); + + var collections = user.RootFolder.GetChildren(user).ToList(); + + var allRecursiveChildren = user.RootFolder.GetRecursiveChildren(user).ToDictionary(i => i.Id); + + return new LibraryUpdateInfo + { + ItemsAdded = itemsAdded.SelectMany(i => TranslatePhysicalItemToUserLibrary(i, user, collections, allRecursiveChildren)).Select(i => i.Id).Distinct().ToList(), + + ItemsUpdated = itemsUpdated.SelectMany(i => TranslatePhysicalItemToUserLibrary(i, user, collections, allRecursiveChildren)).Select(i => i.Id).Distinct().ToList(), + + ItemsRemoved = itemsRemoved.SelectMany(i => TranslatePhysicalItemToUserLibrary(i, user, collections, allRecursiveChildren)).Select(i => i.Id).Distinct().ToList(), + + FoldersAddedTo = foldersAddedTo.SelectMany(i => TranslatePhysicalItemToUserLibrary(i, user, collections, allRecursiveChildren)).Select(i => i.Id).Distinct().ToList(), + + FoldersRemovedFrom = foldersRemovedFrom.SelectMany(i => TranslatePhysicalItemToUserLibrary(i, user, collections, allRecursiveChildren)).Select(i => i.Id).Distinct().ToList() + }; + } + + /// + /// Translates the physical item to user library. + /// + /// + /// The item. + /// The user. + /// The collections. + /// All recursive children. + /// IEnumerable{``0}. + private IEnumerable TranslatePhysicalItemToUserLibrary(T item, User user, List collections, Dictionary allRecursiveChildren) + where T : BaseItem + { + // If the physical root changed, return the user root + if (item is AggregateFolder) + { + return new T[] { user.RootFolder as T }; + } + + // Need to find what user collection folder this belongs to + if (item.Parent is AggregateFolder) + { + return new T[] { user.RootFolder as T }; + } + + // If it's a user root, return it only if it's the right one + if (item is UserRootFolder) + { + if (item.Id == user.RootFolder.Id) + { + return new T[] { item }; + } + + return new T[] { }; } + + // Return it only if it's in the user's library + if (allRecursiveChildren.ContainsKey(item.Id)) + { + return new T[] { item }; + } + + return new T[] { }; } /// diff --git a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj index a624f8e421..af0fa257d9 100644 --- a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj +++ b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj @@ -130,6 +130,10 @@ False ..\packages\MediaBrowser.IsoMounting.3.0.51\lib\net45\MediaBrowser.IsoMounter.dll + + False + ..\packages\morelinq.1.0.15631-beta\lib\net35\MoreLinq.dll + False ..\packages\NLog.2.0.1.2\lib\net45\NLog.dll diff --git a/MediaBrowser.ServerApplication/packages.config b/MediaBrowser.ServerApplication/packages.config index b411ab00ef..1679a99faf 100644 --- a/MediaBrowser.ServerApplication/packages.config +++ b/MediaBrowser.ServerApplication/packages.config @@ -4,6 +4,7 @@ + From b310c986568bf44f72a9ca42deab54966a1867f0 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 21 May 2013 23:59:55 -0400 Subject: [PATCH 3/7] 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(-) 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 - + From 95afe143e8c6cd2dfa93cae3421d64b9885dfcba Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 22 May 2013 00:21:36 -0400 Subject: [PATCH 4/7] add refresh item api method --- MediaBrowser.Api/LibraryService.cs | 24 +++++++++- .../Providers/ProviderManager.cs | 47 ++----------------- 2 files changed, 26 insertions(+), 45 deletions(-) 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