diff --git a/MediaBrowser.Api/BaseApiService.cs b/MediaBrowser.Api/BaseApiService.cs index ca5b8b63a..569e12530 100644 --- a/MediaBrowser.Api/BaseApiService.cs +++ b/MediaBrowser.Api/BaseApiService.cs @@ -88,9 +88,14 @@ namespace MediaBrowser.Api { var auth = AuthorizationRequestFilterAttribute.GetAuthorization(Request); - return sessionManager.Sessions.First(i => string.Equals(i.DeviceId, auth.DeviceId) && - string.Equals(i.Client, auth.Client) && - string.Equals(i.ApplicationVersion, auth.Version)); + var session = sessionManager.GetSession(auth.DeviceId, auth.Client, auth.Version); + + if (session == null) + { + throw new ArgumentException("Session not found."); + } + + return session; } /// diff --git a/MediaBrowser.Api/SessionsService.cs b/MediaBrowser.Api/SessionsService.cs index 4cb48e9fe..36f1d6577 100644 --- a/MediaBrowser.Api/SessionsService.cs +++ b/MediaBrowser.Api/SessionsService.cs @@ -285,7 +285,7 @@ namespace MediaBrowser.Api SeekPositionTicks = request.SeekPositionTicks }; - var task = _sessionManager.SendPlaystateCommand(GetSession().Id, request.Id, command, CancellationToken.None); + var task = _sessionManager.SendPlaystateCommand(GetSession(_sessionManager).Id, request.Id, command, CancellationToken.None); Task.WaitAll(task); } @@ -303,7 +303,7 @@ namespace MediaBrowser.Api ItemType = request.ItemType }; - var task = _sessionManager.SendBrowseCommand(GetSession().Id, request.Id, command, CancellationToken.None); + var task = _sessionManager.SendBrowseCommand(GetSession(_sessionManager).Id, request.Id, command, CancellationToken.None); Task.WaitAll(task); } @@ -318,7 +318,7 @@ namespace MediaBrowser.Api if (Enum.TryParse(request.Command, true, out commandType)) { - var currentSession = GetSession(); + var currentSession = GetSession(_sessionManager); var command = new GeneralCommand { @@ -345,7 +345,7 @@ namespace MediaBrowser.Api Text = request.Text }; - var task = _sessionManager.SendMessageCommand(GetSession().Id, request.Id, command, CancellationToken.None); + var task = _sessionManager.SendMessageCommand(GetSession(_sessionManager).Id, request.Id, command, CancellationToken.None); Task.WaitAll(task); } @@ -364,14 +364,14 @@ namespace MediaBrowser.Api StartPositionTicks = request.StartPositionTicks }; - var task = _sessionManager.SendPlayCommand(GetSession().Id, request.Id, command, CancellationToken.None); + var task = _sessionManager.SendPlayCommand(GetSession(_sessionManager).Id, request.Id, command, CancellationToken.None); Task.WaitAll(task); } public void Post(SendGeneralCommand request) { - var currentSession = GetSession(); + var currentSession = GetSession(_sessionManager); var command = new GeneralCommand { @@ -386,7 +386,7 @@ namespace MediaBrowser.Api public void Post(SendFullGeneralCommand request) { - var currentSession = GetSession(); + var currentSession = GetSession(_sessionManager); request.ControllingUserId = currentSession.UserId.HasValue ? currentSession.UserId.Value.ToString("N") : null; @@ -409,7 +409,7 @@ namespace MediaBrowser.Api { if (string.IsNullOrWhiteSpace(request.Id)) { - request.Id = GetSession().Id; + request.Id = GetSession(_sessionManager).Id; } _sessionManager.ReportCapabilities(request.Id, new SessionCapabilities { @@ -422,14 +422,5 @@ namespace MediaBrowser.Api MessageCallbackUrl = request.MessageCallbackUrl }); } - - private SessionInfo GetSession() - { - var auth = AuthorizationRequestFilterAttribute.GetAuthorization(Request); - - return _sessionManager.Sessions.First(i => string.Equals(i.DeviceId, auth.DeviceId) && - string.Equals(i.Client, auth.Client) && - string.Equals(i.ApplicationVersion, auth.Version)); - } } } \ No newline at end of file diff --git a/MediaBrowser.Controller/Session/ISessionManager.cs b/MediaBrowser.Controller/Session/ISessionManager.cs index 8c2ece131..74ad1b7ee 100644 --- a/MediaBrowser.Controller/Session/ISessionManager.cs +++ b/MediaBrowser.Controller/Session/ISessionManager.cs @@ -239,5 +239,14 @@ namespace MediaBrowser.Controller.Session /// /// The device identifier. void ClearTranscodingInfo(string deviceId); + + /// + /// Gets the session. + /// + /// The device identifier. + /// The client. + /// The version. + /// SessionInfo. + SessionInfo GetSession(string deviceId, string client, string version); } } \ No newline at end of file diff --git a/MediaBrowser.Dlna/PlayTo/TransportCommands.cs b/MediaBrowser.Dlna/PlayTo/TransportCommands.cs index 2f2276a87..13b9b6b18 100644 --- a/MediaBrowser.Dlna/PlayTo/TransportCommands.cs +++ b/MediaBrowser.Dlna/PlayTo/TransportCommands.cs @@ -146,34 +146,6 @@ namespace MediaBrowser.Dlna.PlayTo return string.Format(CommandBase, action.Name, xmlNamesapce, stateString); } - public string BuildSearchPost(ServiceAction action, string xmlNamesapce, object value, string commandParameter = "") - { - var stateString = string.Empty; - - foreach (var arg in action.ArgumentList) - { - if (arg.Direction == "out") - continue; - - if (arg.Name == "ObjectID") - stateString += BuildArgumentXml(arg, value.ToString()); - else if (arg.Name == "Filter") - stateString += BuildArgumentXml(arg, "*"); - else if (arg.Name == "StartingIndex") - stateString += BuildArgumentXml(arg, "0"); - else if (arg.Name == "RequestedCount") - stateString += BuildArgumentXml(arg, "200"); - else if (arg.Name == "BrowseFlag") - stateString += BuildArgumentXml(arg, null, "BrowseDirectChildren"); - else if (arg.Name == "SortCriteria") - stateString += BuildArgumentXml(arg, ""); - else - stateString += BuildArgumentXml(arg, value.ToString(), commandParameter); - } - - return string.Format(CommandBase, action.Name, xmlNamesapce, stateString); - } - public string BuildPost(ServiceAction action, string xmlNamesapce, object value, Dictionary dictionary) { var stateString = string.Empty; diff --git a/MediaBrowser.Providers/Savers/XmlSaverHelpers.cs b/MediaBrowser.Providers/Savers/XmlSaverHelpers.cs index 6b9ebbfe9..d10422f78 100644 --- a/MediaBrowser.Providers/Savers/XmlSaverHelpers.cs +++ b/MediaBrowser.Providers/Savers/XmlSaverHelpers.cs @@ -72,6 +72,7 @@ namespace MediaBrowser.Providers.Savers "MusicbrainzId", "Overview", + "ShortOverview", "Persons", "PlotKeywords", "PremiereDate", @@ -257,6 +258,11 @@ namespace MediaBrowser.Providers.Savers } } + if (!string.IsNullOrEmpty(item.Overview)) + { + builder.Append(""); + } + var hasShortOverview = item as IHasShortOverview; if (hasShortOverview != null) { diff --git a/MediaBrowser.Server.Implementations/Library/Resolvers/Audio/MusicAlbumResolver.cs b/MediaBrowser.Server.Implementations/Library/Resolvers/Audio/MusicAlbumResolver.cs index 28d476971..034894670 100644 --- a/MediaBrowser.Server.Implementations/Library/Resolvers/Audio/MusicAlbumResolver.cs +++ b/MediaBrowser.Server.Implementations/Library/Resolvers/Audio/MusicAlbumResolver.cs @@ -67,32 +67,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio /// true if [is music album] [the specified data]; otherwise, false. public static bool IsMusicAlbum(string path, IDirectoryService directoryService) { - // If list contains at least 2 audio files or at least one and no video files consider it to contain music - var foundAudio = 0; - - foreach (var file in directoryService.GetFiles(path)) - { - var fullName = file.FullName; - - if (EntityResolutionHelper.IsAudioFile(fullName)) - { - // Don't resolve these into audio files - if (string.Equals(Path.GetFileNameWithoutExtension(fullName), BaseItem.ThemeSongFilename) && EntityResolutionHelper.IsAudioFile(fullName)) - { - continue; - } - - foundAudio++; - } - if (foundAudio >= 2) - { - return true; - } - if (EntityResolutionHelper.IsVideoFile(fullName)) return false; - } - - // or a single audio file and no video files - return foundAudio > 0; + return ContainsMusic(directoryService.GetFileSystemEntries(path)); } /// @@ -122,15 +97,31 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio // If list contains at least 2 audio files or at least one and no video files consider it to contain music var foundAudio = 0; - foreach (var file in list) + foreach (var fileSystemInfo in list) { - var fullName = file.FullName; + // TODO: Support disc 1, disc 2, etc + if ((fileSystemInfo.Attributes & FileAttributes.Directory) == FileAttributes.Directory) + { + continue; + } - if (EntityResolutionHelper.IsAudioFile(fullName)) foundAudio++; + var fullName = fileSystemInfo.FullName; + + if (EntityResolutionHelper.IsAudioFile(fullName)) + { + // Don't resolve these into audio files + if (string.Equals(Path.GetFileNameWithoutExtension(fullName), BaseItem.ThemeSongFilename) && EntityResolutionHelper.IsAudioFile(fullName)) + { + continue; + } + + foundAudio++; + } if (foundAudio >= 2) { return true; } + if (EntityResolutionHelper.IsVideoFile(fullName)) return false; if (EntityResolutionHelper.IsVideoPlaceHolder(fullName)) return false; } diff --git a/MediaBrowser.Server.Implementations/Session/SessionManager.cs b/MediaBrowser.Server.Implementations/Session/SessionManager.cs index f48431dc1..4e2b3c7b7 100644 --- a/MediaBrowser.Server.Implementations/Session/SessionManager.cs +++ b/MediaBrowser.Server.Implementations/Session/SessionManager.cs @@ -1516,5 +1516,11 @@ namespace MediaBrowser.Server.Implementations.Session { ReportTranscodingInfo(deviceId, null); } + + public SessionInfo GetSession(string deviceId, string client, string version) + { + return Sessions.FirstOrDefault(i => string.Equals(i.DeviceId, deviceId) && + string.Equals(i.Client, client)); + } } } \ No newline at end of file diff --git a/MediaBrowser.Server.Implementations/Session/SessionWebSocketListener.cs b/MediaBrowser.Server.Implementations/Session/SessionWebSocketListener.cs index 365845f41..a50a6f02e 100644 --- a/MediaBrowser.Server.Implementations/Session/SessionWebSocketListener.cs +++ b/MediaBrowser.Server.Implementations/Session/SessionWebSocketListener.cs @@ -113,21 +113,13 @@ namespace MediaBrowser.Server.Implementations.Session var version = vals[2]; var deviceName = vals.Length > 3 ? vals[3] : string.Empty; - var session = _sessionManager.Sessions - .FirstOrDefault(i => string.Equals(i.DeviceId, deviceId) && - string.Equals(i.Client, client) && - string.Equals(i.ApplicationVersion, version)); + var session = _sessionManager.GetSession(deviceId, client, version); if (session == null && !string.IsNullOrEmpty(deviceName)) { _logger.Debug("Logging session activity"); - await _sessionManager.LogSessionActivity(client, version, deviceId, deviceName, message.Connection.RemoteEndPoint, null).ConfigureAwait(false); - - session = _sessionManager.Sessions - .FirstOrDefault(i => string.Equals(i.DeviceId, deviceId) && - string.Equals(i.Client, client) && - string.Equals(i.ApplicationVersion, version)); + session = await _sessionManager.LogSessionActivity(client, version, deviceId, deviceName, message.Connection.RemoteEndPoint, null).ConfigureAwait(false); } if (session != null) @@ -197,7 +189,7 @@ namespace MediaBrowser.Server.Implementations.Session } private readonly CultureInfo _usCulture = new CultureInfo("en-US"); - + /// /// Reports the playback start. /// @@ -284,7 +276,7 @@ namespace MediaBrowser.Server.Implementations.Session _sessionManager.OnPlaybackProgress(info); } } - + /// /// Reports the playback progress. /// @@ -362,7 +354,7 @@ namespace MediaBrowser.Server.Implementations.Session _sessionManager.OnPlaybackStopped(info); } } - + /// /// Reports the playback stopped. ///