From 2db452f68f64fe4182e8ef3e83cc236c61fa8d82 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 2 Mar 2014 21:17:12 -0500 Subject: [PATCH] add more data to media report --- MediaBrowser.Api/UserLibrary/ItemsService.cs | 2 +- MediaBrowser.Controller/Entities/BaseItem.cs | 14 +++++++++++++- MediaBrowser.Controller/Entities/IHasMetadata.cs | 6 ------ MediaBrowser.Providers/Manager/MetadataService.cs | 15 --------------- MediaBrowser.ServerApplication/LibraryViewer.cs | 13 ++++++++----- 5 files changed, 22 insertions(+), 28 deletions(-) diff --git a/MediaBrowser.Api/UserLibrary/ItemsService.cs b/MediaBrowser.Api/UserLibrary/ItemsService.cs index 39cccf28a..9075bdfc6 100644 --- a/MediaBrowser.Api/UserLibrary/ItemsService.cs +++ b/MediaBrowser.Api/UserLibrary/ItemsService.cs @@ -332,7 +332,7 @@ namespace MediaBrowser.Api.UserLibrary var userId = user == null ? (Guid?)null : user.Id; var item = string.IsNullOrEmpty(request.ParentId) ? - user == null ? (BaseItem)_libraryManager.RootFolder : user.RootFolder : + user == null ? _libraryManager.RootFolder : user.RootFolder : _dtoService.GetItemByDtoId(request.ParentId, userId); // Default list type = children diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index 923673bd8..f7f2346a8 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -229,7 +229,19 @@ namespace MediaBrowser.Controller.Entities } } - public bool IsUnidentified { get; set; } + [IgnoreDataMember] + public bool IsUnidentified + { + get + { + if (ProviderIds.Any()) + { + return false; + } + + return false; + } + } /// /// Gets or sets the locked fields. diff --git a/MediaBrowser.Controller/Entities/IHasMetadata.cs b/MediaBrowser.Controller/Entities/IHasMetadata.cs index 91f37135f..095db0815 100644 --- a/MediaBrowser.Controller/Entities/IHasMetadata.cs +++ b/MediaBrowser.Controller/Entities/IHasMetadata.cs @@ -49,11 +49,5 @@ namespace MediaBrowser.Controller.Entities /// /// true if XXXX, false otherwise. bool BeforeMetadataRefresh(); - - /// - /// Gets or sets a value indicating whether this instance is unidentified. - /// - /// true if this instance is unidentified; otherwise, false. - bool IsUnidentified { get; set; } } } diff --git a/MediaBrowser.Providers/Manager/MetadataService.cs b/MediaBrowser.Providers/Manager/MetadataService.cs index 9b42820e8..24f4b3b2f 100644 --- a/MediaBrowser.Providers/Manager/MetadataService.cs +++ b/MediaBrowser.Providers/Manager/MetadataService.cs @@ -312,7 +312,6 @@ namespace MediaBrowser.Providers.Manager // Only one local provider allowed per item hasLocalMetadata = true; - item.IsUnidentified = false; break; } @@ -387,9 +386,6 @@ namespace MediaBrowser.Providers.Manager { TIdType id = null; - var unidentifiedCount = 0; - var identifiedCount = 0; - foreach (var provider in providers) { var providerName = provider.GetType().Name; @@ -414,11 +410,9 @@ namespace MediaBrowser.Providers.Manager refreshResult.UpdateType = refreshResult.UpdateType | ItemUpdateType.MetadataDownload; - identifiedCount++; } else { - unidentifiedCount++; Logger.Debug("{0} returned no metadata for {1}", providerName, item.Path ?? item.Name); } } @@ -428,20 +422,11 @@ namespace MediaBrowser.Providers.Manager } catch (Exception ex) { - unidentifiedCount++; refreshResult.Status = ProviderRefreshStatus.CompletedWithErrors; refreshResult.ErrorMessage = ex.Message; Logger.ErrorException("Error in {0}", ex, provider.Name); } } - - var isUnidentified = unidentifiedCount > 0 && identifiedCount == 0; - - if (item.IsUnidentified != isUnidentified) - { - item.IsUnidentified = isUnidentified; - refreshResult.UpdateType = refreshResult.UpdateType | ItemUpdateType.MetadataImport; - } } private void MergeNewData(TItemType source, TIdType lookupInfo) diff --git a/MediaBrowser.ServerApplication/LibraryViewer.cs b/MediaBrowser.ServerApplication/LibraryViewer.cs index 2bf51be4a..a8eda801b 100644 --- a/MediaBrowser.ServerApplication/LibraryViewer.cs +++ b/MediaBrowser.ServerApplication/LibraryViewer.cs @@ -84,7 +84,8 @@ namespace MediaBrowser.ServerApplication { treeView1.Nodes.Clear(); - IEnumerable children = _currentUser.Name == "Physical" ? new[] { _libraryManager.RootFolder } : _libraryManager.RootFolder.GetChildren(_currentUser, true); + var isPhysical = _currentUser.Name == "Physical"; + IEnumerable children = isPhysical ? new[] { _libraryManager.RootFolder } : _libraryManager.RootFolder.GetChildren(_currentUser, true); children = OrderByName(children, _currentUser); foreach (Folder folder in children) @@ -94,9 +95,9 @@ namespace MediaBrowser.ServerApplication var node = new TreeNode { Tag = currentFolder }; - var subChildren = currentFolder.GetChildren(_currentUser, true); + var subChildren = isPhysical ? currentFolder.Children : currentFolder.GetChildren(_currentUser, true); subChildren = OrderByName(subChildren, _currentUser); - AddChildren(node, subChildren, _currentUser); + AddChildren(node, subChildren, _currentUser, isPhysical); node.Text = currentFolder.Name + " (" + node.Nodes.Count + ")"; @@ -110,7 +111,7 @@ namespace MediaBrowser.ServerApplication /// The parent. /// The children. /// The user. - private void AddChildren(TreeNode parent, IEnumerable children, User user) + private void AddChildren(TreeNode parent, IEnumerable children, User user, bool isPhysical) { foreach (var item in children) { @@ -120,7 +121,9 @@ namespace MediaBrowser.ServerApplication { var prefs = _displayPreferencesManager.GetDisplayPreferences(subFolder.DisplayPreferencesId, user.Id, "LibraryExplorer"); - AddChildren(node, OrderBy(subFolder.GetChildren(user, true), user, prefs.SortBy), user); + var subChildren = isPhysical ? subFolder.Children : subFolder.GetChildren(_currentUser, true); + + AddChildren(node, OrderBy(subChildren, user, prefs.SortBy), user, isPhysical); node.Text = item.Name + " (" + node.Nodes.Count + ")"; } else