diff --git a/MediaBrowser.Api/DefaultTheme/DefaultThemeService.cs b/MediaBrowser.Api/DefaultTheme/DefaultThemeService.cs index 7339e90ad..379698059 100644 --- a/MediaBrowser.Api/DefaultTheme/DefaultThemeService.cs +++ b/MediaBrowser.Api/DefaultTheme/DefaultThemeService.cs @@ -246,13 +246,13 @@ namespace MediaBrowser.Api.DefaultTheme var fields = new List(); view.BackdropItems = gamesWithBackdrops - .Randomize("backdrop") + .OrderBy(i => Guid.NewGuid()) .Take(10) .Select(i => _dtoService.GetBaseItemDto(i, fields, user)) .ToList(); view.SpotlightItems = gamesWithBackdrops - .Randomize("spotlight") + .OrderBy(i => Guid.NewGuid()) .Take(10) .Select(i => _dtoService.GetBaseItemDto(i, fields, user)) .ToList(); @@ -294,7 +294,7 @@ namespace MediaBrowser.Api.DefaultTheme var seriesWithBestBackdrops = FilterItemsForBackdropDisplay(seriesWithBackdrops).ToList(); view.BackdropItems = seriesWithBestBackdrops - .Randomize("backdrop") + .OrderBy(i => Guid.NewGuid()) .Take(10) .AsParallel() .Select(i => _dtoService.GetBaseItemDto(i, fields, user)) @@ -336,7 +336,7 @@ namespace MediaBrowser.Api.DefaultTheme } spotlightSeries = spotlightSeries - .Randomize("spotlight") + .OrderBy(i => Guid.NewGuid()) .Take(10) .ToList(); @@ -374,8 +374,11 @@ namespace MediaBrowser.Api.DefaultTheme view.SeriesIdsInProgress = nextUpEpisodes.Select(i => i.Series.Id.ToString("N")).ToList(); + // Avoid implicitly captured closure + var currentUser1 = user; + var ownedEpisodes = series - .SelectMany(i => i.GetRecursiveChildren(user, j => j.LocationType != LocationType.Virtual)) + .SelectMany(i => i.GetRecursiveChildren(currentUser1, j => j.LocationType != LocationType.Virtual)) .OfType() .ToList(); @@ -439,7 +442,7 @@ namespace MediaBrowser.Api.DefaultTheme var itemsWithTopBackdrops = FilterItemsForBackdropDisplay(itemsWithBackdrops).ToList(); view.BackdropItems = itemsWithTopBackdrops - .Randomize("backdrop") + .OrderBy(i => Guid.NewGuid()) .Take(10) .AsParallel() .Select(i => _dtoService.GetBaseItemDto(i, fields, user)) @@ -524,7 +527,7 @@ namespace MediaBrowser.Api.DefaultTheme } spotlightItems = spotlightItems - .Randomize("spotlight") + .OrderBy(i => Guid.NewGuid()) .Take(10) .ToList(); @@ -559,16 +562,19 @@ namespace MediaBrowser.Api.DefaultTheme .Select(i => _dtoService.GetBaseItemDto(i, fields, user)) .ToList(); + // Avoid implicitly captured closure + var currentUserId1 = user.Id; + view.LatestMovies = movies .OrderByDescending(i => i.DateCreated) - .Where(i => !_userDataManager.GetUserData(user.Id, i.GetUserDataKey()).Played) + .Where(i => !_userDataManager.GetUserData(currentUserId1, i.GetUserDataKey()).Played) .Take(request.LatestMoviesLimit) .Select(i => _dtoService.GetBaseItemDto(i, fields, user)) .ToList(); view.LatestTrailers = trailers .OrderByDescending(i => i.DateCreated) - .Where(i => !_userDataManager.GetUserData(user.Id, i.GetUserDataKey()).Played) + .Where(i => !_userDataManager.GetUserData(currentUserId1, i.GetUserDataKey()).Played) .Take(request.LatestTrailersLimit) .Select(i => _dtoService.GetBaseItemDto(i, fields, user)) .ToList(); diff --git a/MediaBrowser.Controller/Library/ILibraryManager.cs b/MediaBrowser.Controller/Library/ILibraryManager.cs index 0bab0d356..0a89c0df8 100644 --- a/MediaBrowser.Controller/Library/ILibraryManager.cs +++ b/MediaBrowser.Controller/Library/ILibraryManager.cs @@ -294,5 +294,13 @@ namespace MediaBrowser.Controller.Library /// The item. /// System.String. string FindCollectionType(BaseItem item); + + /// + /// Saves the metadata. + /// + /// The item. + /// Type of the update. + /// Task. + Task SaveMetadata(BaseItem item, ItemUpdateType updateType); } } \ No newline at end of file diff --git a/MediaBrowser.Controller/Library/ItemChangeEventArgs.cs b/MediaBrowser.Controller/Library/ItemChangeEventArgs.cs index c83ec54b7..a2951f548 100644 --- a/MediaBrowser.Controller/Library/ItemChangeEventArgs.cs +++ b/MediaBrowser.Controller/Library/ItemChangeEventArgs.cs @@ -12,5 +12,11 @@ namespace MediaBrowser.Controller.Library /// /// The item. public BaseItem Item { get; set; } + + /// + /// Gets or sets the item. + /// + /// The item. + public ItemUpdateType UpdateReason { get; set; } } } diff --git a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs index 88832722b..6a2df70b1 100644 --- a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs +++ b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs @@ -1312,7 +1312,11 @@ namespace MediaBrowser.Server.Implementations.Library { try { - ItemUpdated(this, new ItemChangeEventArgs { Item = item }); + ItemUpdated(this, new ItemChangeEventArgs + { + Item = item, + UpdateReason = updateReason + }); } catch (Exception ex) { @@ -1377,8 +1381,14 @@ namespace MediaBrowser.Server.Implementations.Library /// The item. /// Type of the update. /// Task. - private async Task SaveMetadata(BaseItem item, ItemUpdateType updateType) + public async Task SaveMetadata(BaseItem item, ItemUpdateType updateType) { + var locationType = item.LocationType; + if (locationType == LocationType.Remote || locationType == LocationType.Virtual) + { + throw new ArgumentException("Only file-system based items can save metadata."); + } + foreach (var saver in _savers.Where(i => i.IsEnabledFor(item, updateType))) { var path = saver.GetSavePath(item); @@ -1444,7 +1454,7 @@ namespace MediaBrowser.Server.Implementations.Library try { - + return i.ResolveArgs.PhysicalLocations.Contains(item.Path); } catch (IOException ex) diff --git a/Nuget/MediaBrowser.Common.Internal.nuspec b/Nuget/MediaBrowser.Common.Internal.nuspec index c61a8ce53..e1bd6a542 100644 --- a/Nuget/MediaBrowser.Common.Internal.nuspec +++ b/Nuget/MediaBrowser.Common.Internal.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common.Internal - 3.0.240 + 3.0.241 MediaBrowser.Common.Internal Luke ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains common components shared by Media Browser Theater 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 918c15c0d..4d7e8c28c 100644 --- a/Nuget/MediaBrowser.Common.nuspec +++ b/Nuget/MediaBrowser.Common.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common - 3.0.240 + 3.0.241 MediaBrowser.Common Media Browser Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Server.Core.nuspec b/Nuget/MediaBrowser.Server.Core.nuspec index 8a9ab2225..0ffe59d60 100644 --- a/Nuget/MediaBrowser.Server.Core.nuspec +++ b/Nuget/MediaBrowser.Server.Core.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Server.Core - 3.0.240 + 3.0.241 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 - +