diff options
Diffstat (limited to 'MediaBrowser.Server.Implementations')
3 files changed, 31 insertions, 42 deletions
diff --git a/MediaBrowser.Server.Implementations/Library/Resolvers/Audio/MusicAlbumResolver.cs b/MediaBrowser.Server.Implementations/Library/Resolvers/Audio/MusicAlbumResolver.cs index 28d4769714..034894670d 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 /// <returns><c>true</c> if [is music album] [the specified data]; otherwise, <c>false</c>.</returns> 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)); } /// <summary> @@ -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; + } + + var fullName = fileSystemInfo.FullName; - if (EntityResolutionHelper.IsAudioFile(fullName)) foundAudio++; + 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 f48431dc1d..4e2b3c7b78 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 365845f416..a50a6f02ef 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"); - + /// <summary> /// Reports the playback start. /// </summary> @@ -284,7 +276,7 @@ namespace MediaBrowser.Server.Implementations.Session _sessionManager.OnPlaybackProgress(info); } } - + /// <summary> /// Reports the playback progress. /// </summary> @@ -362,7 +354,7 @@ namespace MediaBrowser.Server.Implementations.Session _sessionManager.OnPlaybackStopped(info); } } - + /// <summary> /// Reports the playback stopped. /// </summary> |
