diff --git a/MediaBrowser.Api/ItemUpdateService.cs b/MediaBrowser.Api/ItemUpdateService.cs index 0138380915..bab02de356 100644 --- a/MediaBrowser.Api/ItemUpdateService.cs +++ b/MediaBrowser.Api/ItemUpdateService.cs @@ -389,22 +389,28 @@ namespace MediaBrowser.Api game.PlayersSupported = request.Players; } - var hasAlbumArtists = item as IHasAlbumArtist; - if (hasAlbumArtists != null) + if (request.AlbumArtists != null) { - hasAlbumArtists.AlbumArtists = request - .AlbumArtists - .Select(i => i.Name) - .ToList(); + var hasAlbumArtists = item as IHasAlbumArtist; + if (hasAlbumArtists != null) + { + hasAlbumArtists.AlbumArtists = request + .AlbumArtists + .Select(i => i.Name) + .ToList(); + } } - var hasArtists = item as IHasArtist; - if (hasArtists != null) + if (request.ArtistItems != null) { - hasArtists.Artists = request - .ArtistItems - .Select(i => i.Name) - .ToList(); + var hasArtists = item as IHasArtist; + if (hasArtists != null) + { + hasArtists.Artists = request + .ArtistItems + .Select(i => i.Name) + .ToList(); + } } var song = item as Audio; diff --git a/MediaBrowser.Server.Implementations/Devices/DeviceManager.cs b/MediaBrowser.Server.Implementations/Devices/DeviceManager.cs index b65b7d11b3..fb64a6d285 100644 --- a/MediaBrowser.Server.Implementations/Devices/DeviceManager.cs +++ b/MediaBrowser.Server.Implementations/Devices/DeviceManager.cs @@ -233,6 +233,12 @@ namespace MediaBrowser.Server.Implementations.Devices } var user = _userManager.GetUserById(userId); + + if (user == null) + { + throw new ArgumentException("user not found"); + } + if (!CanAccessDevice(user.Policy, deviceId)) { var capabilities = GetCapabilities(deviceId); diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs index d7a8828c08..a82775de70 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs @@ -17,6 +17,7 @@ using MediaBrowser.Model.Dto; using MediaBrowser.Model.Entities; using MediaBrowser.Model.LiveTv; using MediaBrowser.Model.Logging; +using MediaBrowser.Model.MediaInfo; using MediaBrowser.Model.Querying; using MediaBrowser.Model.Serialization; using System; diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs index 9706ed6d25..4a9028af4e 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs @@ -1,10 +1,12 @@ -using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller; +using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.LiveTv; using MediaBrowser.Controller.MediaEncoding; using MediaBrowser.Model.Dlna; using MediaBrowser.Model.Dto; using MediaBrowser.Model.Logging; +using MediaBrowser.Model.MediaInfo; using MediaBrowser.Model.Serialization; using System; using System.Collections.Generic; @@ -21,13 +23,15 @@ namespace MediaBrowser.Server.Implementations.LiveTv private readonly ILogger _logger; private readonly IMediaSourceManager _mediaSourceManager; private readonly IMediaEncoder _mediaEncoder; + private readonly IServerApplicationHost _appHost; - public LiveTvMediaSourceProvider(ILiveTvManager liveTvManager, IJsonSerializer jsonSerializer, ILogManager logManager, IMediaSourceManager mediaSourceManager, IMediaEncoder mediaEncoder) + public LiveTvMediaSourceProvider(ILiveTvManager liveTvManager, IJsonSerializer jsonSerializer, ILogManager logManager, IMediaSourceManager mediaSourceManager, IMediaEncoder mediaEncoder, IServerApplicationHost appHost) { _liveTvManager = liveTvManager; _jsonSerializer = jsonSerializer; _mediaSourceManager = mediaSourceManager; _mediaEncoder = mediaEncoder; + _appHost = appHost; _logger = logManager.GetLogger(GetType().Name); } @@ -74,6 +78,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv } var list = sources.ToList(); + var serverUrl = _appHost.LocalApiUrl; foreach (var source in list) { @@ -86,6 +91,12 @@ namespace MediaBrowser.Server.Implementations.LiveTv openKeys.Add(item.Id.ToString("N")); openKeys.Add(source.Id ?? string.Empty); source.OpenToken = string.Join("|", openKeys.ToArray()); + + // Dummy this up so that direct play checks can still run + if (string.IsNullOrEmpty(source.Path) && source.Protocol == MediaProtocol.Http) + { + source.Path = serverUrl; + } } _logger.Debug("MediaSources: {0}", _jsonSerializer.SerializeToString(list)); @@ -187,7 +198,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv } } } - + // Try to estimate this if (!mediaSource.Bitrate.HasValue) { diff --git a/MediaBrowser.Server.Implementations/Sync/SyncJobProcessor.cs b/MediaBrowser.Server.Implementations/Sync/SyncJobProcessor.cs index fd4092974e..04ebcd9034 100644 --- a/MediaBrowser.Server.Implementations/Sync/SyncJobProcessor.cs +++ b/MediaBrowser.Server.Implementations/Sync/SyncJobProcessor.cs @@ -458,6 +458,13 @@ namespace MediaBrowser.Server.Implementations.Sync var syncOptions = _config.GetSyncOptions(); var user = _userManager.GetUserById(job.UserId); + if (user == null) + { + jobItem.Status = SyncJobItemStatus.Failed; + _logger.Error("User not found. Cannot complete the sync job."); + await _syncManager.UpdateSyncJobItemInternal(jobItem).ConfigureAwait(false); + return; + } var video = item as Video; if (video != null)