The Free Software Media System - Server Backend & API
resolve local trailers not used for cinema mode
Luke Pulverentie4fd626d1ccc
diff --git a/Emby.Server.Implementations/Data/SqliteItemRepository.cs b/Emby.Server.Implementations/Data/SqliteItemRepository.csindex af1594cf74..6bec6dce38 100644--- a/Emby.Server.Implementations/Data/SqliteItemRepository.cs+++ b/Emby.Server.Implementations/Data/SqliteItemRepository.cs@@ -2648,7 +2648,7 @@ namespace Emby.Server.Implementations.Data{//Logger.Debug("{2} query time: {0}ms. Query: {1}",// Convert.ToInt32(elapsed),- // cmd.CommandText,+ // commandText,// methodName);}}@@ -4203,7 +4203,7 @@ namespace Emby.Server.Implementations.Datavar paramName = "@ExcludeProviderId" + index;//excludeIds.Add("(COALESCE((select value from ProviderIds where ItemId=Guid and Name = '" + pair.Key + "'), '') <> " + paramName + ")");- excludeIds.Add("ProviderIds not like " + paramName);+ excludeIds.Add("(ProviderIds is null or ProviderIds not like " + paramName + ")");if (statement != null){statement.TryBind(paramName, "%" + pair.Key + "=" + pair.Value + "%");diff --git a/Emby.Server.Implementations/Intros/DefaultIntroProvider.cs b/Emby.Server.Implementations/Intros/DefaultIntroProvider.csindex 90bb2f5c07..500d4b69b1 100644--- a/Emby.Server.Implementations/Intros/DefaultIntroProvider.cs+++ b/Emby.Server.Implementations/Intros/DefaultIntroProvider.cs@@ -105,21 +105,26 @@ namespace Emby.Server.Implementations.IntrostrailerTypes.Clear();}- var trailerResult = _libraryManager.GetItemList(new InternalItemsQuery(user)+ // hack - can't filter by user library because local trailers get TopParentId =null in the db.+ // for now we have to use a post-query filter afterwards to solve that+ var trailerResult = _libraryManager.GetItemList(new InternalItemsQuery{IncludeItemTypes = new[] { typeof(Trailer).Name },TrailerTypes = trailerTypes.ToArray(),SimilarTo = item,- IsPlayed = config.EnableIntrosForWatchedContent ? (bool?)null : false,+ //IsPlayed = config.EnableIntrosForWatchedContent ? (bool?)null : false,MaxParentalRating = config.EnableIntrosParentalControl ? ratingLevel : null,BlockUnratedItems = config.EnableIntrosParentalControl ? new[] { UnratedItem.Trailer } : new UnratedItem[] { },// Account for duplicates by imdb id, since the database doesn't support this yet- Limit = config.TrailerLimit * 2,+ Limit = config.TrailerLimit * 4,SourceTypes = sourceTypes.ToArray(),MinSimilarityScore = 0-- }).Where(i => string.IsNullOrWhiteSpace(i.GetProviderId(MetadataProviders.Imdb)) || !string.Equals(i.GetProviderId(MetadataProviders.Imdb), item.GetProviderId(MetadataProviders.Imdb), StringComparison.OrdinalIgnoreCase)).Take(config.TrailerLimit);+ })+ .Where(i => string.IsNullOrWhiteSpace(i.GetProviderId(MetadataProviders.Imdb)) || !string.Equals(i.GetProviderId(MetadataProviders.Imdb), item.GetProviderId(MetadataProviders.Imdb), StringComparison.OrdinalIgnoreCase))+ .Where(i => i.IsVisibleStandalone(user))+ .Where(i => config.EnableIntrosForWatchedContent || !i.IsPlayed(user))+ .Take(config.TrailerLimit);candidates.AddRange(trailerResult.Select(i => new ItemWithTrailer{diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.csindex 3651ba3631..23dfb802c0 100644--- a/MediaBrowser.Controller/Entities/BaseItem.cs+++ b/MediaBrowser.Controller/Entities/BaseItem.cs@@ -1590,12 +1590,15 @@ namespace MediaBrowser.Controller.Entitiesreturn true;}- var userCollectionFolders = user.RootFolder.GetChildren(user, true).Select(i => i.Id).ToList();- var itemCollectionFolders = LibraryManager.GetCollectionFolders(this).Select(i => i.Id);+ var itemCollectionFolders = LibraryManager.GetCollectionFolders(this).Select(i => i.Id).ToList();- if (!itemCollectionFolders.Any(userCollectionFolders.Contains))+ if (itemCollectionFolders.Count > 0){- return false;+ var userCollectionFolders = user.RootFolder.GetChildren(user, true).Select(i => i.Id).ToList();+ if (!itemCollectionFolders.Any(userCollectionFolders.Contains))+ {+ return false;+ }}}