diff options
Diffstat (limited to 'MediaBrowser.Server.Implementations/Library')
7 files changed, 92 insertions, 44 deletions
diff --git a/MediaBrowser.Server.Implementations/Library/CoreResolutionIgnoreRule.cs b/MediaBrowser.Server.Implementations/Library/CoreResolutionIgnoreRule.cs index 3dda3f1581..be8c1cfbd7 100644 --- a/MediaBrowser.Server.Implementations/Library/CoreResolutionIgnoreRule.cs +++ b/MediaBrowser.Server.Implementations/Library/CoreResolutionIgnoreRule.cs @@ -32,6 +32,7 @@ namespace MediaBrowser.Server.Implementations.Library ".wd_tv", // Synology + "@eaDir", "eaDir" }; diff --git a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs index ee0bf354f5..c3793b3a3e 100644 --- a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs +++ b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs @@ -16,6 +16,7 @@ using MediaBrowser.Controller.Sorting; using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Entities; using MediaBrowser.Model.Logging; +using MediaBrowser.Model.Querying; using MediaBrowser.Naming.Audio; using MediaBrowser.Naming.Common; using MediaBrowser.Naming.TV; @@ -31,6 +32,7 @@ using System.IO; using System.Linq; using System.Threading; using System.Threading.Tasks; +using MoreLinq; using SortOrder = MediaBrowser.Model.Entities.SortOrder; namespace MediaBrowser.Server.Implementations.Library @@ -1106,6 +1108,8 @@ namespace MediaBrowser.Server.Implementations.Library progress.Report(innerPercent); }); + _logger.Debug("Running post-scan task {0}", task.GetType().Name); + try { await task.Run(innerProgress, cancellationToken).ConfigureAwait(false); @@ -1209,6 +1213,23 @@ namespace MediaBrowser.Server.Implementations.Library return item; } + public QueryResult<BaseItem> GetItems(InternalItemsQuery query) + { + var result = ItemRepository.GetItemIdsList(query); + + var items = result.Select(GetItemById).ToArray(); + + return new QueryResult<BaseItem> + { + Items = items + }; + } + + public List<Guid> GetItemIds(InternalItemsQuery query) + { + return ItemRepository.GetItemIdsList(query); + } + /// <summary> /// Gets the intros. /// </summary> @@ -2042,5 +2063,58 @@ namespace MediaBrowser.Server.Implementations.Library item.ExtraType = ExtraType.Clip; } } + + public List<PersonInfo> GetPeople(InternalPeopleQuery query) + { + return ItemRepository.GetPeople(query); + } + + public List<PersonInfo> GetPeople(BaseItem item) + { + return item.People ?? GetPeople(new InternalPeopleQuery + { + ItemId = item.Id + }); + } + + public List<Person> GetPeopleItems(InternalPeopleQuery query) + { + return ItemRepository.GetPeopleNames(query).Select(i => + { + try + { + return GetPerson(i); + } + catch (Exception ex) + { + _logger.ErrorException("Error getting person", ex); + return null; + } + + }).Where(i => i != null).ToList(); + } + + public List<string> GetPeopleNames(InternalPeopleQuery query) + { + return ItemRepository.GetPeopleNames(query); + } + + public List<PersonInfo> GetAllPeople() + { + return GetPeople(new InternalPeopleQuery()) + .DistinctBy(i => i.Name, StringComparer.OrdinalIgnoreCase) + .ToList(); + } + + public async Task UpdatePeople(BaseItem item, List<PersonInfo> people) + { + await ItemRepository.UpdatePeople(item.Id, people).ConfigureAwait(false); + + if (item.People != null) + { + item.People = null; + await item.UpdateToRepository(ItemUpdateType.MetadataEdit, CancellationToken.None).ConfigureAwait(false); + } + } } } diff --git a/MediaBrowser.Server.Implementations/Library/MediaSourceManager.cs b/MediaBrowser.Server.Implementations/Library/MediaSourceManager.cs index 71fd4127b5..b6441053d7 100644 --- a/MediaBrowser.Server.Implementations/Library/MediaSourceManager.cs +++ b/MediaBrowser.Server.Implementations/Library/MediaSourceManager.cs @@ -474,7 +474,7 @@ namespace MediaBrowser.Server.Implementations.Library } private Timer _closeTimer; - private readonly TimeSpan _openStreamMaxAge = TimeSpan.FromSeconds(40); + private readonly TimeSpan _openStreamMaxAge = TimeSpan.FromSeconds(60); private void StartCloseTimer() { diff --git a/MediaBrowser.Server.Implementations/Library/ResolverHelper.cs b/MediaBrowser.Server.Implementations/Library/ResolverHelper.cs index b6a93408ad..dac6580951 100644 --- a/MediaBrowser.Server.Implementations/Library/ResolverHelper.cs +++ b/MediaBrowser.Server.Implementations/Library/ResolverHelper.cs @@ -34,7 +34,7 @@ namespace MediaBrowser.Server.Implementations.Library // If the resolver didn't specify this if (parent != null) { - item.Parent = parent; + item.SetParent(parent); } item.Id = libraryManager.GetNewItemId(item.Path, item.GetType()); @@ -68,7 +68,7 @@ namespace MediaBrowser.Server.Implementations.Library // If the resolver didn't specify this if (args.Parent != null) { - item.Parent = args.Parent; + item.SetParent(args.Parent); } item.Id = libraryManager.GetNewItemId(item.Path, item.GetType()); diff --git a/MediaBrowser.Server.Implementations/Library/SearchEngine.cs b/MediaBrowser.Server.Implementations/Library/SearchEngine.cs index 72bbefae45..05dde5b3e1 100644 --- a/MediaBrowser.Server.Implementations/Library/SearchEngine.cs +++ b/MediaBrowser.Server.Implementations/Library/SearchEngine.cs @@ -256,10 +256,15 @@ namespace MediaBrowser.Server.Implementations.Library if (query.IncludePeople) { + var itemIds = items.Select(i => i.Id).ToList(); + // Find persons - var persons = items.SelectMany(i => i.People) + var persons = _libraryManager.GetPeople(new InternalPeopleQuery + { + NameContains = searchTerm + }) + .Where(i => itemIds.Contains(i.ItemId)) .Select(i => i.Name) - .Where(i => !string.IsNullOrWhiteSpace(i)) .Distinct(StringComparer.OrdinalIgnoreCase) .ToList(); diff --git a/MediaBrowser.Server.Implementations/Library/UserDataManager.cs b/MediaBrowser.Server.Implementations/Library/UserDataManager.cs index 8cbb2eb1aa..ae737d2446 100644 --- a/MediaBrowser.Server.Implementations/Library/UserDataManager.cs +++ b/MediaBrowser.Server.Implementations/Library/UserDataManager.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using MediaBrowser.Common.Events; +using MediaBrowser.Common.Events; using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.Audio; @@ -10,6 +9,7 @@ using MediaBrowser.Model.Entities; using MediaBrowser.Model.Logging; using System; using System.Collections.Concurrent; +using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; @@ -262,5 +262,9 @@ namespace MediaBrowser.Server.Implementations.Library return playedToCompletion; } + public UserItemData GetUserData(string userId, string key) + { + return GetUserData(new Guid(userId), key); + } } } diff --git a/MediaBrowser.Server.Implementations/Library/Validators/PeopleValidator.cs b/MediaBrowser.Server.Implementations/Library/Validators/PeopleValidator.cs index 059ad2481d..ef9dee8b51 100644 --- a/MediaBrowser.Server.Implementations/Library/Validators/PeopleValidator.cs +++ b/MediaBrowser.Server.Implementations/Library/Validators/PeopleValidator.cs @@ -72,39 +72,6 @@ namespace MediaBrowser.Server.Implementations.Library.Validators return options.DownloadOtherPeopleMetadata; } - private IEnumerable<PersonInfo> GetPeopleToValidate(BaseItem item, PeopleMetadataOptions options) - { - return item.People.Where(i => - { - if (i.IsType(PersonType.Actor)) - { - return options.DownloadActorMetadata; - } - if (i.IsType(PersonType.Director)) - { - return options.DownloadDirectorMetadata; - } - if (i.IsType(PersonType.Composer)) - { - return options.DownloadComposerMetadata; - } - if (i.IsType(PersonType.Writer)) - { - return options.DownloadWriterMetadata; - } - if (i.IsType(PersonType.Producer)) - { - return options.DownloadProducerMetadata; - } - if (i.IsType(PersonType.GuestStar)) - { - return options.DownloadGuestStarMetadata; - } - - return options.DownloadOtherPeopleMetadata; - }); - } - /// <summary> /// Validates the people. /// </summary> @@ -119,10 +86,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators var peopleOptions = _config.Configuration.PeopleMetadataOptions; - var people = _libraryManager.RootFolder.GetRecursiveChildren() - .SelectMany(i => i.People) - .Where(i => !string.IsNullOrWhiteSpace(i.Name)) - .ToList(); + var people = _libraryManager.GetAllPeople(); var dict = new Dictionary<string, bool>(StringComparer.OrdinalIgnoreCase); |
