diff options
Diffstat (limited to 'MediaBrowser.Controller')
| -rw-r--r-- | MediaBrowser.Controller/Entities/BaseItem.cs | 43 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/Folder.cs | 8 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/IItemByName.cs | 2 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/InternalItemsQuery.cs | 16 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/InternalPeopleQuery.cs | 21 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/Person.cs | 18 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/UserViewBuilder.cs | 156 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Library/ILibraryManager.cs | 28 | ||||
| -rw-r--r-- | MediaBrowser.Controller/MediaBrowser.Controller.csproj | 2 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Persistence/IItemRepository.cs | 11 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Social/ISharingManager.cs | 28 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Sync/IServerSyncProvider.cs | 14 |
12 files changed, 311 insertions, 36 deletions
diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index 5d7c02f48..d9dbf265f 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -235,6 +235,15 @@ namespace MediaBrowser.Controller.Entities } } + [IgnoreDataMember] + public virtual bool EnableAlphaNumericSorting + { + get + { + return true; + } + } + /// <summary> /// This is just a helper for convenience /// </summary> @@ -439,6 +448,11 @@ namespace MediaBrowser.Controller.Entities { if (Name == null) return null; //some items may not have name filled in properly + if (!EnableAlphaNumericSorting) + { + return Name.TrimStart(); + } + var sortable = Name.Trim().ToLower(); sortable = ConfigurationManager.Configuration.SortRemoveCharacters.Aggregate(sortable, (current, search) => current.Replace(search.ToLower(), string.Empty)); @@ -464,12 +478,37 @@ namespace MediaBrowser.Controller.Entities return sortable; } + public Guid ParentId { get; set; } + + private Folder _parent; /// <summary> /// Gets or sets the parent. /// </summary> /// <value>The parent.</value> - [IgnoreDataMember] - public Folder Parent { get; set; } + public Folder Parent + { + get + { + if (_parent != null) + { + return _parent; + } + + if (ParentId != Guid.Empty) + { + return LibraryManager.GetItemById(ParentId) as Folder; + } + + return null; + } + set { _parent = value; } + } + + public void SetParent(Folder parent) + { + Parent = parent; + ParentId = parent == null ? Guid.Empty : parent.Id; + } [IgnoreDataMember] public IEnumerable<Folder> Parents diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index 821e6b5ca..22efb09e1 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -134,7 +134,7 @@ namespace MediaBrowser.Controller.Entities /// <exception cref="System.InvalidOperationException">Unable to add + item.Name</exception> public async Task AddChild(BaseItem item, CancellationToken cancellationToken) { - item.Parent = this; + item.SetParent(this); if (item.Id == Guid.Empty) { @@ -230,7 +230,7 @@ namespace MediaBrowser.Controller.Entities { RemoveChildrenInternal(new[] { item }); - item.Parent = null; + item.SetParent(null); return ItemRepository.SaveChildren(Id, ActualChildren.Select(i => i.Id).ToList(), cancellationToken); } @@ -783,11 +783,11 @@ namespace MediaBrowser.Controller.Entities return LibraryManager.GetOrAddByReferenceItem(item); } - item.Parent = this; + item.SetParent(this); } else { - child.Parent = this; + child.SetParent(this); LibraryManager.RegisterItem(child); item = child; } diff --git a/MediaBrowser.Controller/Entities/IItemByName.cs b/MediaBrowser.Controller/Entities/IItemByName.cs index 14b69b8fd..e6667290c 100644 --- a/MediaBrowser.Controller/Entities/IItemByName.cs +++ b/MediaBrowser.Controller/Entities/IItemByName.cs @@ -6,7 +6,7 @@ namespace MediaBrowser.Controller.Entities /// <summary> /// Marker interface /// </summary> - public interface IItemByName + public interface IItemByName : IHasMetadata { /// <summary> /// Gets the tagged items. diff --git a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs index faa9bc875..c5e60a73d 100644 --- a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs +++ b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Model.Entities; +using System.Collections.Generic; +using MediaBrowser.Model.Entities; using System; namespace MediaBrowser.Controller.Entities @@ -42,6 +43,7 @@ namespace MediaBrowser.Controller.Entities public string Person { get; set; } public string[] PersonIds { get; set; } + public string[] ItemIds { get; set; } public string AdjacentTo { get; set; } public string[] PersonTypes { get; set; } @@ -82,9 +84,16 @@ namespace MediaBrowser.Controller.Entities public bool? IsMovie { get; set; } public bool? IsSports { get; set; } public bool? IsKids { get; set; } - + + public int? MinPlayers { get; set; } + public int? MaxPlayers { get; set; } + public double? MinCriticRating { get; set; } + public double? MinCommunityRating { get; set; } + public string[] ChannelIds { get; set; } - + + internal List<Guid> ItemIdsFromPersonFilters { get; set; } + public InternalItemsQuery() { Tags = new string[] { }; @@ -102,6 +111,7 @@ namespace MediaBrowser.Controller.Entities PersonTypes = new string[] { }; PersonIds = new string[] { }; ChannelIds = new string[] { }; + ItemIds = new string[] { }; } } } diff --git a/MediaBrowser.Controller/Entities/InternalPeopleQuery.cs b/MediaBrowser.Controller/Entities/InternalPeopleQuery.cs new file mode 100644 index 000000000..05d23d986 --- /dev/null +++ b/MediaBrowser.Controller/Entities/InternalPeopleQuery.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; + +namespace MediaBrowser.Controller.Entities +{ + public class InternalPeopleQuery + { + public Guid ItemId { get; set; } + public List<string> PersonTypes { get; set; } + public List<string> ExcludePersonTypes { get; set; } + public int? MaxListOrder { get; set; } + public Guid AppearsInItemId { get; set; } + public string NameContains { get; set; } + + public InternalPeopleQuery() + { + PersonTypes = new List<string>(); + ExcludePersonTypes = new List<string>(); + } + } +} diff --git a/MediaBrowser.Controller/Entities/Person.cs b/MediaBrowser.Controller/Entities/Person.cs index 390fcaf80..6c277da56 100644 --- a/MediaBrowser.Controller/Entities/Person.cs +++ b/MediaBrowser.Controller/Entities/Person.cs @@ -55,6 +55,15 @@ namespace MediaBrowser.Controller.Entities return true; } + [IgnoreDataMember] + public override bool EnableAlphaNumericSorting + { + get + { + return false; + } + } + /// <summary> /// Gets a value indicating whether this instance is owned item. /// </summary> @@ -70,7 +79,12 @@ namespace MediaBrowser.Controller.Entities public IEnumerable<BaseItem> GetTaggedItems(IEnumerable<BaseItem> inputItems) { - return inputItems.Where(GetItemFilter()); + var itemsWithPerson = LibraryManager.GetItemIds(new InternalItemsQuery + { + Person = Name + }); + + return inputItems.Where(i => itemsWithPerson.Contains(i.Id)); } @@ -94,6 +108,8 @@ namespace MediaBrowser.Controller.Entities /// </summary> public class PersonInfo { + public Guid ItemId { get; set; } + /// <summary> /// Gets or sets the name. /// </summary> diff --git a/MediaBrowser.Controller/Entities/UserViewBuilder.cs b/MediaBrowser.Controller/Entities/UserViewBuilder.cs index 41e5406e1..b2d359277 100644 --- a/MediaBrowser.Controller/Entities/UserViewBuilder.cs +++ b/MediaBrowser.Controller/Entities/UserViewBuilder.cs @@ -1116,6 +1116,11 @@ namespace MediaBrowser.Controller.Entities return false; } + if (request.ItemIds.Length > 0) + { + return false; + } + if (request.Studios.Length > 0) { return false; @@ -1146,6 +1151,26 @@ namespace MediaBrowser.Controller.Entities return false; } + if (request.MinPlayers.HasValue) + { + return false; + } + + if (request.MaxPlayers.HasValue) + { + return false; + } + + if (request.MinCommunityRating.HasValue) + { + return false; + } + + if (request.MinCriticRating.HasValue) + { + return false; + } + return true; } @@ -1304,6 +1329,41 @@ namespace MediaBrowser.Controller.Entities public static bool Filter(BaseItem item, User user, InternalItemsQuery query, IUserDataManager userDataManager, ILibraryManager libraryManager) { + if (query.ItemIdsFromPersonFilters == null) + { + if (query.PersonIds.Length > 0) + { + var names = query.PersonIds + .Select(libraryManager.GetItemById) + .Select(i => i == null ? null : i.Name) + .Where(i => !string.IsNullOrWhiteSpace(i)) + .ToList(); + + var itemIdList = new List<Guid>(); + foreach (var name in names) + { + itemIdList.AddRange(libraryManager.GetItemIds(new InternalItemsQuery + { + Person = name + })); + } + query.ItemIdsFromPersonFilters = itemIdList; + } + + // Apply person filter + else if (!string.IsNullOrWhiteSpace(query.Person)) + { + var itemIdList = new List<Guid>(); + + itemIdList.AddRange(libraryManager.GetItemIds(new InternalItemsQuery + { + Person = query.Person, + PersonTypes = query.PersonTypes + })); + query.ItemIdsFromPersonFilters = itemIdList; + } + } + if (query.MediaTypes.Length > 0 && !query.MediaTypes.Contains(item.MediaType ?? string.Empty, StringComparer.OrdinalIgnoreCase)) { return false; @@ -1691,58 +1751,108 @@ namespace MediaBrowser.Controller.Entities return false; } - // Apply person filter - if (query.PersonIds.Length > 0) + if (query.ItemIds.Length > 0) { - var names = query.PersonIds - .Select(libraryManager.GetItemById) - .Select(i => i == null ? "-1" : i.Name) - .ToList(); - - if (!(names.Any( - v => libraryManager.GetPeople(item).Select(i => i.Name).Contains(v, StringComparer.OrdinalIgnoreCase)))) + if (!query.ItemIds.Contains(item.Id.ToString("N"), StringComparer.OrdinalIgnoreCase)) { return false; } } // Apply person filter - if (!string.IsNullOrWhiteSpace(query.Person)) + if (query.ItemIdsFromPersonFilters != null) { - var personTypes = query.PersonTypes; + if (!query.ItemIdsFromPersonFilters.Contains(item.Id)) + { + return false; + } + } - if (personTypes.Length == 0) + // Apply tag filter + var tags = query.Tags; + if (tags.Length > 0) + { + var hasTags = item as IHasTags; + if (hasTags == null) { - if (!(libraryManager.GetPeople(item).Any(p => string.Equals(p.Name, query.Person, StringComparison.OrdinalIgnoreCase)))) + return false; + } + if (!(tags.Any(v => hasTags.Tags.Contains(v, StringComparer.OrdinalIgnoreCase)))) + { + return false; + } + } + + if (query.MinPlayers.HasValue) + { + var filterValue = query.MinPlayers.Value; + + var game = item as Game; + + if (game != null) + { + var players = game.PlayersSupported ?? 1; + + var ok = players >= filterValue; + + if (!ok) { return false; } } else { - var types = personTypes; + return false; + } + } + + if (query.MaxPlayers.HasValue) + { + var filterValue = query.MaxPlayers.Value; + + var game = item as Game; + + if (game != null) + { + var players = game.PlayersSupported ?? 1; - var ok = new[] { item }.Any(i => - libraryManager.GetPeople(i).Any(p => - string.Equals(p.Name, query.Person, StringComparison.OrdinalIgnoreCase) && (types.Contains(p.Type ?? string.Empty, StringComparer.OrdinalIgnoreCase) || types.Contains(p.Role ?? string.Empty, StringComparer.OrdinalIgnoreCase)))); + var ok = players <= filterValue; if (!ok) { return false; } } + else + { + return false; + } } - // Apply tag filter - var tags = query.Tags; - if (tags.Length > 0) + if (query.MinCommunityRating.HasValue) { - var hasTags = item as IHasTags; - if (hasTags == null) + var val = query.MinCommunityRating.Value; + + if (!(item.CommunityRating.HasValue && item.CommunityRating >= val)) { return false; } - if (!(tags.Any(v => hasTags.Tags.Contains(v, StringComparer.OrdinalIgnoreCase)))) + } + + if (query.MinCriticRating.HasValue) + { + var val = query.MinCriticRating.Value; + + var hasCriticRating = item as IHasCriticRating; + + if (hasCriticRating != null) + { + if (!(hasCriticRating.CriticRating.HasValue && hasCriticRating.CriticRating >= val)) + { + return false; + } + } + else { return false; } diff --git a/MediaBrowser.Controller/Library/ILibraryManager.cs b/MediaBrowser.Controller/Library/ILibraryManager.cs index 92028cc1a..f0bfaaf66 100644 --- a/MediaBrowser.Controller/Library/ILibraryManager.cs +++ b/MediaBrowser.Controller/Library/ILibraryManager.cs @@ -421,6 +421,20 @@ namespace MediaBrowser.Controller.Library List<PersonInfo> GetPeople(BaseItem item); /// <summary> + /// Gets the people. + /// </summary> + /// <param name="query">The query.</param> + /// <returns>List<PersonInfo>.</returns> + List<PersonInfo> GetPeople(InternalPeopleQuery query); + + /// <summary> + /// Gets the people items. + /// </summary> + /// <param name="query">The query.</param> + /// <returns>List<Person>.</returns> + List<Person> GetPeopleItems(InternalPeopleQuery query); + + /// <summary> /// Gets all people names. /// </summary> /// <returns>List<System.String>.</returns> @@ -433,5 +447,19 @@ namespace MediaBrowser.Controller.Library /// <param name="people">The people.</param> /// <returns>Task.</returns> Task UpdatePeople(BaseItem item, List<PersonInfo> people); + + /// <summary> + /// Gets the item ids. + /// </summary> + /// <param name="query">The query.</param> + /// <returns>List<Guid>.</returns> + List<Guid> GetItemIds(InternalItemsQuery query); + + /// <summary> + /// Gets the people names. + /// </summary> + /// <param name="query">The query.</param> + /// <returns>List<System.String>.</returns> + List<string> GetPeopleNames(InternalPeopleQuery query); } }
\ No newline at end of file diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj index 62578e675..fcde6d8c0 100644 --- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj +++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj @@ -166,6 +166,7 @@ <Compile Include="Entities\ImageSourceInfo.cs" /> <Compile Include="Entities\IMetadataContainer.cs" /> <Compile Include="Entities\InternalItemsQuery.cs" /> + <Compile Include="Entities\InternalPeopleQuery.cs" /> <Compile Include="Entities\ISupportsBoxSetGrouping.cs" /> <Compile Include="Entities\ISupportsPlaceHolders.cs" /> <Compile Include="Entities\ItemImageInfo.cs" /> @@ -329,6 +330,7 @@ <Compile Include="Security\IAuthenticationRepository.cs" /> <Compile Include="Security\IEncryptionManager.cs" /> <Compile Include="Session\AuthenticationRequest.cs" /> + <Compile Include="Social\ISharingManager.cs" /> <Compile Include="Subtitles\ISubtitleManager.cs" /> <Compile Include="Subtitles\ISubtitleProvider.cs" /> <Compile Include="Providers\ItemIdentifier.cs" /> diff --git a/MediaBrowser.Controller/Persistence/IItemRepository.cs b/MediaBrowser.Controller/Persistence/IItemRepository.cs index fba5f4c03..a4b9bf120 100644 --- a/MediaBrowser.Controller/Persistence/IItemRepository.cs +++ b/MediaBrowser.Controller/Persistence/IItemRepository.cs @@ -151,9 +151,9 @@ namespace MediaBrowser.Controller.Persistence /// <summary> /// Gets the people. /// </summary> - /// <param name="itemId">The item identifier.</param> + /// <param name="query">The query.</param> /// <returns>List<PersonInfo>.</returns> - List<PersonInfo> GetPeople(Guid itemId); + List<PersonInfo> GetPeople(InternalPeopleQuery query); /// <summary> /// Updates the people. @@ -162,6 +162,13 @@ namespace MediaBrowser.Controller.Persistence /// <param name="people">The people.</param> /// <returns>Task.</returns> Task UpdatePeople(Guid itemId, List<PersonInfo> people); + + /// <summary> + /// Gets the people names. + /// </summary> + /// <param name="query">The query.</param> + /// <returns>List<System.String>.</returns> + List<string> GetPeopleNames(InternalPeopleQuery query); } } diff --git a/MediaBrowser.Controller/Social/ISharingManager.cs b/MediaBrowser.Controller/Social/ISharingManager.cs new file mode 100644 index 000000000..ded37771a --- /dev/null +++ b/MediaBrowser.Controller/Social/ISharingManager.cs @@ -0,0 +1,28 @@ +using MediaBrowser.Model.Social; +using System.Threading.Tasks; + +namespace MediaBrowser.Controller.Social +{ + public interface ISharingManager + { + /// <summary> + /// Creates the share. + /// </summary> + /// <param name="itemId">The item identifier.</param> + /// <param name="userId">The user identifier.</param> + /// <returns>Task<SocialShareInfo>.</returns> + Task<SocialShareInfo> CreateShare(string itemId, string userId); + /// <summary> + /// Gets the share information. + /// </summary> + /// <param name="id">The identifier.</param> + /// <returns>SocialShareInfo.</returns> + SocialShareInfo GetShareInfo(string id); + /// <summary> + /// Deletes the share. + /// </summary> + /// <param name="id">The identifier.</param> + /// <returns>Task.</returns> + Task DeleteShare(string id); + } +} diff --git a/MediaBrowser.Controller/Sync/IServerSyncProvider.cs b/MediaBrowser.Controller/Sync/IServerSyncProvider.cs index 2635a4cbf..860c736ea 100644 --- a/MediaBrowser.Controller/Sync/IServerSyncProvider.cs +++ b/MediaBrowser.Controller/Sync/IServerSyncProvider.cs @@ -49,4 +49,18 @@ namespace MediaBrowser.Controller.Sync /// <returns>Task<QueryResult<FileMetadata>>.</returns> Task<QueryResult<FileMetadata>> GetFiles(FileQuery query, SyncTarget target, CancellationToken cancellationToken); } + + public interface ISupportsDirectCopy + { + /// <summary> + /// Sends the file. + /// </summary> + /// <param name="path">The path.</param> + /// <param name="pathParts">The path parts.</param> + /// <param name="target">The target.</param> + /// <param name="progress">The progress.</param> + /// <param name="cancellationToken">The cancellation token.</param> + /// <returns>Task<SyncedFileInfo>.</returns> + Task<SyncedFileInfo> SendFile(string path, string[] pathParts, SyncTarget target, IProgress<double> progress, CancellationToken cancellationToken); + } } |
