diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index 3c8d8baece..e3841099e7 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -666,6 +666,27 @@ namespace MediaBrowser.Controller.Entities }); } + public virtual int GetChildCount(User user) + { + if (LinkedChildren.Count > 0) + { + if (!(this is ICollectionFolder)) + { + return GetChildren(user, true).Count(); + } + } + + var result = GetItems(new InternalItemsQuery(user) + { + Recursive = false, + Limit = 0, + ParentId = Id + + }).Result; + + return result.TotalRecordCount; + } + public QueryResult QueryRecursive(InternalItemsQuery query) { var user = query.User; diff --git a/MediaBrowser.Controller/Entities/TV/Season.cs b/MediaBrowser.Controller/Entities/TV/Season.cs index c984a2832a..9a90148443 100644 --- a/MediaBrowser.Controller/Entities/TV/Season.cs +++ b/MediaBrowser.Controller/Entities/TV/Season.cs @@ -75,6 +75,11 @@ namespace MediaBrowser.Controller.Entities.TV return list; } + public override int GetChildCount(User user) + { + return GetChildren(user, true).Count(); + } + /// /// This Episode's Series Instance /// diff --git a/MediaBrowser.Controller/Entities/TV/Series.cs b/MediaBrowser.Controller/Entities/TV/Series.cs index 1f341ba138..1cc496b352 100644 --- a/MediaBrowser.Controller/Entities/TV/Series.cs +++ b/MediaBrowser.Controller/Entities/TV/Series.cs @@ -111,6 +111,20 @@ namespace MediaBrowser.Controller.Entities.TV } } + public override int GetChildCount(User user) + { + var result = LibraryManager.GetItemsResult(new InternalItemsQuery(user) + { + AncestorWithPresentationUniqueKey = PresentationUniqueKey, + IncludeItemTypes = new[] { typeof(Season).Name }, + SortBy = new[] { ItemSortBy.SortName }, + IsVirtualItem = false, + Limit = 0 + }); + + return result.TotalRecordCount; + } + /// /// Gets the user data key. /// diff --git a/MediaBrowser.Controller/Entities/UserRootFolder.cs b/MediaBrowser.Controller/Entities/UserRootFolder.cs index 37c4c91b17..8e6f11c2ce 100644 --- a/MediaBrowser.Controller/Entities/UserRootFolder.cs +++ b/MediaBrowser.Controller/Entities/UserRootFolder.cs @@ -38,6 +38,11 @@ namespace MediaBrowser.Controller.Entities return PostFilterAndSort(result.Where(filter), query); } + public override int GetChildCount(User user) + { + return GetChildren(user, true).Count(); + } + [IgnoreDataMember] protected override bool SupportsShortcutChildren { diff --git a/MediaBrowser.Controller/Entities/UserView.cs b/MediaBrowser.Controller/Entities/UserView.cs index 6ec719e875..35375e7e66 100644 --- a/MediaBrowser.Controller/Entities/UserView.cs +++ b/MediaBrowser.Controller/Entities/UserView.cs @@ -45,6 +45,11 @@ namespace MediaBrowser.Controller.Entities return list; } + public override int GetChildCount(User user) + { + return GetChildren(user, true).Count(); + } + protected override Task> GetItemsInternal(InternalItemsQuery query) { var parent = this as Folder; diff --git a/MediaBrowser.Controller/Library/ILibraryManager.cs b/MediaBrowser.Controller/Library/ILibraryManager.cs index 936b97c6e2..1d0e06482b 100644 --- a/MediaBrowser.Controller/Library/ILibraryManager.cs +++ b/MediaBrowser.Controller/Library/ILibraryManager.cs @@ -150,13 +150,6 @@ namespace MediaBrowser.Controller.Library /// BaseItem. BaseItem GetItemById(Guid id); - /// - /// Gets the memory item by identifier. - /// - /// The identifier. - /// BaseItem. - BaseItem GetMemoryItemById(Guid id); - /// /// Gets the intros. /// diff --git a/MediaBrowser.Dlna/Profiles/SamsungSmartTvProfile.cs b/MediaBrowser.Dlna/Profiles/SamsungSmartTvProfile.cs index 1b06e1d6a7..c117d030f9 100644 --- a/MediaBrowser.Dlna/Profiles/SamsungSmartTvProfile.cs +++ b/MediaBrowser.Dlna/Profiles/SamsungSmartTvProfile.cs @@ -21,8 +21,8 @@ namespace MediaBrowser.Dlna.Profiles new HttpHeaderInfo { Name = "User-Agent", - Value = @"SEC_", - Match = HeaderMatchType.Substring + Value = @".*(SEC_HHP_\[TV\] [A-Z]{2}\d{2}J[A-Z]?\d{3,4})*.", + Match = HeaderMatchType.Regex } } }; diff --git a/MediaBrowser.Dlna/Profiles/Xml/Samsung Smart TV.xml b/MediaBrowser.Dlna/Profiles/Xml/Samsung Smart TV.xml index b09c25afa9..967538bdf0 100644 --- a/MediaBrowser.Dlna/Profiles/Xml/Samsung Smart TV.xml +++ b/MediaBrowser.Dlna/Profiles/Xml/Samsung Smart TV.xml @@ -4,7 +4,7 @@ samsung.com - + Emby diff --git a/MediaBrowser.Providers/Music/MusicBrainzAlbumProvider.cs b/MediaBrowser.Providers/Music/MusicBrainzAlbumProvider.cs index 30fe7c21ad..792f92b498 100644 --- a/MediaBrowser.Providers/Music/MusicBrainzAlbumProvider.cs +++ b/MediaBrowser.Providers/Music/MusicBrainzAlbumProvider.cs @@ -307,7 +307,6 @@ namespace MediaBrowser.Providers.Music } var nodes = releaseList.ChildNodes; - string releaseGroupId = null; if (nodes != null) { diff --git a/MediaBrowser.Server.Implementations/Dto/DtoService.cs b/MediaBrowser.Server.Implementations/Dto/DtoService.cs index 31a35eec9c..95a2351093 100644 --- a/MediaBrowser.Server.Implementations/Dto/DtoService.cs +++ b/MediaBrowser.Server.Implementations/Dto/DtoService.cs @@ -549,8 +549,7 @@ namespace MediaBrowser.Server.Implementations.Dto private int GetChildCount(Folder folder, User user) { - return folder.GetChildren(user, true) - .Count(); + return folder.GetChildCount(user); } /// diff --git a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs index 2483ec93e8..c0c40aa5bd 100644 --- a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs +++ b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs @@ -1276,18 +1276,9 @@ namespace MediaBrowser.Server.Implementations.Library return item; } - public BaseItem GetMemoryItemById(Guid id) + private bool EnableCaching { - if (id == Guid.Empty) - { - throw new ArgumentNullException("id"); - } - - BaseItem item; - - LibraryItemsCache.TryGetValue(id, out item); - - return item; + get { return true; } } public IEnumerable GetItemList(InternalItemsQuery query) @@ -1297,6 +1288,11 @@ namespace MediaBrowser.Server.Implementations.Library AddUserToQuery(query, query.User); } + if (!EnableCaching) + { + return ItemRepository.GetItemList(query); + } + var result = ItemRepository.GetItemIdsList(query); return result.Select(GetItemById).Where(i => i != null); @@ -1336,6 +1332,11 @@ namespace MediaBrowser.Server.Implementations.Library SetTopParentIdsOrAncestors(query, parents); + if (!EnableCaching) + { + return ItemRepository.GetItemList(query); + } + return GetItemIds(query).Select(GetItemById).Where(i => i != null); } @@ -1358,6 +1359,11 @@ namespace MediaBrowser.Server.Implementations.Library if (query.EnableTotalRecordCount) { + if (!EnableCaching) + { + return ItemRepository.GetItems(query); + } + var initialResult = ItemRepository.GetItemIds(query); return new QueryResult @@ -1367,6 +1373,14 @@ namespace MediaBrowser.Server.Implementations.Library }; } + if (!EnableCaching) + { + return new QueryResult + { + Items = ItemRepository.GetItemList(query).ToArray() + }; + } + return new QueryResult { Items = ItemRepository.GetItemIdsList(query).Select(GetItemById).Where(i => i != null).ToArray() diff --git a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs index 04118cb855..437d169744 100644 --- a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs +++ b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs @@ -122,7 +122,7 @@ namespace MediaBrowser.Server.Implementations.Persistence protected override async Task CreateConnection(bool isReadOnly = false) { - var connection = await DbConnector.Connect(DbFilePath, false, false, 20000).ConfigureAwait(false); + var connection = await DbConnector.Connect(DbFilePath, false, false, 5000).ConfigureAwait(false); connection.RunQueries(new[] {