diff --git a/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs b/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs index 4185590ab3..f6d1d32a4c 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs @@ -216,5 +216,14 @@ namespace MediaBrowser.Controller.Entities.Audio return hasArtist != null && hasArtist.HasAnyArtist(Name); }; } + + [IgnoreDataMember] + public override bool SupportsPeople + { + get + { + return false; + } + } } } diff --git a/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs b/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs index 971c092361..5f24dbf672 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs @@ -71,5 +71,14 @@ namespace MediaBrowser.Controller.Entities.Audio { return i => (i is IHasMusicGenres) && i.Genres.Contains(Name, StringComparer.OrdinalIgnoreCase); } + + [IgnoreDataMember] + public override bool SupportsPeople + { + get + { + return false; + } + } } } diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index 6e8c9ae54d..5d7c02f482 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -35,7 +35,6 @@ namespace MediaBrowser.Controller.Entities { Genres = new List(); Studios = new List(); - People = new List(); ProviderIds = new Dictionary(StringComparer.OrdinalIgnoreCase); LockedFields = new List(); ImageInfos = new List(); @@ -776,6 +775,12 @@ namespace MediaBrowser.Controller.Entities get { return IsFolder || Parent != null; } } + [IgnoreDataMember] + public virtual bool SupportsPeople + { + get { return true; } + } + /// /// Refreshes owned items such as trailers, theme videos, special features, etc. /// Returns true or false indicating if changes were found. @@ -1239,7 +1244,6 @@ namespace MediaBrowser.Controller.Entities /// public void AddPerson(PersonInfo person) { - PeopleHelper.AddPerson(People, person); } /// diff --git a/MediaBrowser.Controller/Entities/BasePluginFolder.cs b/MediaBrowser.Controller/Entities/BasePluginFolder.cs index 1cc5477904..5a1ad6b157 100644 --- a/MediaBrowser.Controller/Entities/BasePluginFolder.cs +++ b/MediaBrowser.Controller/Entities/BasePluginFolder.cs @@ -1,4 +1,6 @@  +using System.Runtime.Serialization; + namespace MediaBrowser.Controller.Entities { /// @@ -21,5 +23,14 @@ namespace MediaBrowser.Controller.Entities { return true; } + + [IgnoreDataMember] + public override bool SupportsPeople + { + get + { + return false; + } + } } } diff --git a/MediaBrowser.Controller/Entities/CollectionFolder.cs b/MediaBrowser.Controller/Entities/CollectionFolder.cs index bcf68263ae..3a610be641 100644 --- a/MediaBrowser.Controller/Entities/CollectionFolder.cs +++ b/MediaBrowser.Controller/Entities/CollectionFolder.cs @@ -194,5 +194,14 @@ namespace MediaBrowser.Controller.Entities .Where(i => i.Path != null && PhysicalLocations.Contains(i.Path, StringComparer.OrdinalIgnoreCase)) .SelectMany(c => c.Children); } + + [IgnoreDataMember] + public override bool SupportsPeople + { + get + { + return false; + } + } } } diff --git a/MediaBrowser.Controller/Entities/GameGenre.cs b/MediaBrowser.Controller/Entities/GameGenre.cs index c91acbe3f1..bf448da0d5 100644 --- a/MediaBrowser.Controller/Entities/GameGenre.cs +++ b/MediaBrowser.Controller/Entities/GameGenre.cs @@ -62,5 +62,14 @@ namespace MediaBrowser.Controller.Entities { return i => (i is Game) && i.Genres.Contains(Name, StringComparer.OrdinalIgnoreCase); } + + [IgnoreDataMember] + public override bool SupportsPeople + { + get + { + return false; + } + } } } diff --git a/MediaBrowser.Controller/Entities/GameSystem.cs b/MediaBrowser.Controller/Entities/GameSystem.cs index cf69167638..35f7e33501 100644 --- a/MediaBrowser.Controller/Entities/GameSystem.cs +++ b/MediaBrowser.Controller/Entities/GameSystem.cs @@ -58,5 +58,14 @@ namespace MediaBrowser.Controller.Entities return id; } + + [IgnoreDataMember] + public override bool SupportsPeople + { + get + { + return false; + } + } } } diff --git a/MediaBrowser.Controller/Entities/Genre.cs b/MediaBrowser.Controller/Entities/Genre.cs index cb68e5dae9..233e1e0fd1 100644 --- a/MediaBrowser.Controller/Entities/Genre.cs +++ b/MediaBrowser.Controller/Entities/Genre.cs @@ -66,5 +66,14 @@ namespace MediaBrowser.Controller.Entities { return i => !(i is Game) && !(i is IHasMusicGenres) && i.Genres.Contains(Name, StringComparer.OrdinalIgnoreCase); } + + [IgnoreDataMember] + public override bool SupportsPeople + { + get + { + return false; + } + } } } diff --git a/MediaBrowser.Controller/Entities/IHasMetadata.cs b/MediaBrowser.Controller/Entities/IHasMetadata.cs index 3643c58b3e..158bcb6d19 100644 --- a/MediaBrowser.Controller/Entities/IHasMetadata.cs +++ b/MediaBrowser.Controller/Entities/IHasMetadata.cs @@ -59,5 +59,11 @@ namespace MediaBrowser.Controller.Entities /// Afters the metadata refresh. /// void AfterMetadataRefresh(); + + /// + /// Gets a value indicating whether [supports people]. + /// + /// true if [supports people]; otherwise, false. + bool SupportsPeople { get; } } } diff --git a/MediaBrowser.Controller/Entities/Person.cs b/MediaBrowser.Controller/Entities/Person.cs index bbd112de0f..390fcaf804 100644 --- a/MediaBrowser.Controller/Entities/Person.cs +++ b/MediaBrowser.Controller/Entities/Person.cs @@ -78,6 +78,15 @@ namespace MediaBrowser.Controller.Entities { return i => LibraryManager.GetPeople(i).Any(p => string.Equals(p.Name, Name, StringComparison.OrdinalIgnoreCase)); } + + [IgnoreDataMember] + public override bool SupportsPeople + { + get + { + return false; + } + } } /// diff --git a/MediaBrowser.Controller/Entities/Studio.cs b/MediaBrowser.Controller/Entities/Studio.cs index b8d359369b..822f305ede 100644 --- a/MediaBrowser.Controller/Entities/Studio.cs +++ b/MediaBrowser.Controller/Entities/Studio.cs @@ -72,5 +72,14 @@ namespace MediaBrowser.Controller.Entities { return i => i.Studios.Contains(Name, StringComparer.OrdinalIgnoreCase); } + + [IgnoreDataMember] + public override bool SupportsPeople + { + get + { + return false; + } + } } } diff --git a/MediaBrowser.Controller/Entities/User.cs b/MediaBrowser.Controller/Entities/User.cs index 5b70ee5f4e..71e3d1ce03 100644 --- a/MediaBrowser.Controller/Entities/User.cs +++ b/MediaBrowser.Controller/Entities/User.cs @@ -295,5 +295,14 @@ namespace MediaBrowser.Controller.Entities return config.GroupedFolders.Select(i => new Guid(i)).Contains(id); } + + [IgnoreDataMember] + public override bool SupportsPeople + { + get + { + return false; + } + } } } diff --git a/MediaBrowser.Controller/Entities/UserView.cs b/MediaBrowser.Controller/Entities/UserView.cs index 9be30273a0..dad6de01a8 100644 --- a/MediaBrowser.Controller/Entities/UserView.cs +++ b/MediaBrowser.Controller/Entities/UserView.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Controller.Playlists; +using System.Runtime.Serialization; +using MediaBrowser.Controller.Playlists; using MediaBrowser.Controller.TV; using MediaBrowser.Model.Entities; using MediaBrowser.Model.Querying; @@ -93,5 +94,14 @@ namespace MediaBrowser.Controller.Entities return standaloneTypes.Contains(collectionFolder.CollectionType ?? string.Empty); } + + [IgnoreDataMember] + public override bool SupportsPeople + { + get + { + return false; + } + } } } diff --git a/MediaBrowser.Controller/Entities/Year.cs b/MediaBrowser.Controller/Entities/Year.cs index a1a1523873..163dcd667c 100644 --- a/MediaBrowser.Controller/Entities/Year.cs +++ b/MediaBrowser.Controller/Entities/Year.cs @@ -88,5 +88,14 @@ namespace MediaBrowser.Controller.Entities var val = GetYearValue(); return i => i.ProductionYear.HasValue && val.HasValue && i.ProductionYear.Value == val.Value; } + + [IgnoreDataMember] + public override bool SupportsPeople + { + get + { + return false; + } + } } } diff --git a/MediaBrowser.Controller/Persistence/IItemRepository.cs b/MediaBrowser.Controller/Persistence/IItemRepository.cs index 7c02a0ea1e..fba5f4c03e 100644 --- a/MediaBrowser.Controller/Persistence/IItemRepository.cs +++ b/MediaBrowser.Controller/Persistence/IItemRepository.cs @@ -147,6 +147,21 @@ namespace MediaBrowser.Controller.Persistence /// The query. /// List<Guid>. List GetItemIdsList(InternalItemsQuery query); + + /// + /// Gets the people. + /// + /// The item identifier. + /// List<PersonInfo>. + List GetPeople(Guid itemId); + + /// + /// Updates the people. + /// + /// The item identifier. + /// The people. + /// Task. + Task UpdatePeople(Guid itemId, List people); } } diff --git a/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs b/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs index 2ed12973b6..c1a4fa765a 100644 --- a/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs +++ b/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs @@ -40,7 +40,7 @@ namespace MediaBrowser.Controller.Providers /// The metadata file. /// The cancellation token. /// - public void Fetch(T item, string metadataFile, CancellationToken cancellationToken) + public void Fetch(MetadataResult item, string metadataFile, CancellationToken cancellationToken) { if (item == null) { @@ -72,7 +72,7 @@ namespace MediaBrowser.Controller.Providers /// The settings. /// The encoding. /// The cancellation token. - private void Fetch(T item, string metadataFile, XmlReaderSettings settings, Encoding encoding, CancellationToken cancellationToken) + private void Fetch(MetadataResult item, string metadataFile, XmlReaderSettings settings, Encoding encoding, CancellationToken cancellationToken) { using (var streamReader = new StreamReader(metadataFile, encoding)) { @@ -101,9 +101,11 @@ namespace MediaBrowser.Controller.Providers /// Fetches metadata from one Xml Element /// /// The reader. - /// The item. - protected virtual void FetchDataFromXmlNode(XmlReader reader, T item) + /// The item result. + protected virtual void FetchDataFromXmlNode(XmlReader reader, MetadataResult itemResult) { + var item = itemResult.Item; + switch (reader.Name) { // DateCreated @@ -490,7 +492,7 @@ namespace MediaBrowser.Controller.Providers { continue; } - PeopleHelper.AddPerson(item.People, p); + PeopleHelper.AddPerson(itemResult.People, p); } break; } @@ -502,7 +504,7 @@ namespace MediaBrowser.Controller.Providers { continue; } - PeopleHelper.AddPerson(item.People, p); + PeopleHelper.AddPerson(itemResult.People, p); } break; } @@ -516,7 +518,7 @@ namespace MediaBrowser.Controller.Providers { // This is one of the mis-named "Actors" full nodes created by MB2 // Create a reader and pass it to the persons node processor - FetchDataFromPersonsNode(new XmlTextReader(new StringReader("" + actors + "")), item); + FetchDataFromPersonsNode(new XmlTextReader(new StringReader("" + actors + "")), itemResult); } else { @@ -527,7 +529,7 @@ namespace MediaBrowser.Controller.Providers { continue; } - PeopleHelper.AddPerson(item.People, p); + PeopleHelper.AddPerson(itemResult.People, p); } } break; @@ -541,7 +543,7 @@ namespace MediaBrowser.Controller.Providers { continue; } - PeopleHelper.AddPerson(item.People, p); + PeopleHelper.AddPerson(itemResult.People, p); } break; } @@ -833,7 +835,7 @@ namespace MediaBrowser.Controller.Providers { using (var subtree = reader.ReadSubtree()) { - FetchDataFromPersonsNode(subtree, item); + FetchDataFromPersonsNode(subtree, itemResult); } break; } @@ -1133,7 +1135,7 @@ namespace MediaBrowser.Controller.Providers /// /// The reader. /// The item. - private void FetchDataFromPersonsNode(XmlReader reader, T item) + private void FetchDataFromPersonsNode(XmlReader reader, MetadataResult item) { reader.MoveToContent(); diff --git a/MediaBrowser.Controller/Providers/LocalMetadataResult.cs b/MediaBrowser.Controller/Providers/LocalMetadataResult.cs index 8be3ee7aac..76b7a31360 100644 --- a/MediaBrowser.Controller/Providers/LocalMetadataResult.cs +++ b/MediaBrowser.Controller/Providers/LocalMetadataResult.cs @@ -1,23 +1,17 @@ -using System.Collections.Generic; using MediaBrowser.Controller.Entities; -using MediaBrowser.Model.Entities; +using System.Collections.Generic; namespace MediaBrowser.Controller.Providers { - public class LocalMetadataResult + public class LocalMetadataResult : MetadataResult where T : IHasMetadata { - public bool HasMetadata { get; set; } - public T Item { get; set; } - public List Images { get; set; } - public List Chapters { get; set; } public List UserDataLIst { get; set; } public LocalMetadataResult() { Images = new List(); - Chapters = new List(); UserDataLIst = new List(); } } diff --git a/MediaBrowser.Controller/Providers/MetadataResult.cs b/MediaBrowser.Controller/Providers/MetadataResult.cs index 756458cfaf..a18dd83e83 100644 --- a/MediaBrowser.Controller/Providers/MetadataResult.cs +++ b/MediaBrowser.Controller/Providers/MetadataResult.cs @@ -1,8 +1,18 @@ +using MediaBrowser.Controller.Entities; +using System.Collections.Generic; + namespace MediaBrowser.Controller.Providers { public class MetadataResult { + public List People { get; set; } + public bool HasMetadata { get; set; } public T Item { get; set; } + + public MetadataResult() + { + People = new List(); + } } } \ No newline at end of file diff --git a/MediaBrowser.LocalMetadata/Parsers/BoxSetXmlParser.cs b/MediaBrowser.LocalMetadata/Parsers/BoxSetXmlParser.cs index f89e29d54b..772af06737 100644 --- a/MediaBrowser.LocalMetadata/Parsers/BoxSetXmlParser.cs +++ b/MediaBrowser.LocalMetadata/Parsers/BoxSetXmlParser.cs @@ -14,7 +14,7 @@ namespace MediaBrowser.LocalMetadata.Parsers { } - protected override void FetchDataFromXmlNode(XmlReader reader, BoxSet item) + protected override void FetchDataFromXmlNode(XmlReader reader, MetadataResult item) { switch (reader.Name) { @@ -32,7 +32,7 @@ namespace MediaBrowser.LocalMetadata.Parsers } } - private void FetchFromCollectionItemsNode(XmlReader reader, BoxSet item) + private void FetchFromCollectionItemsNode(XmlReader reader, MetadataResult item) { reader.MoveToContent(); @@ -66,7 +66,7 @@ namespace MediaBrowser.LocalMetadata.Parsers } } - item.LinkedChildren = list; + item.Item.LinkedChildren = list; } } } diff --git a/MediaBrowser.LocalMetadata/Parsers/EpisodeXmlParser.cs b/MediaBrowser.LocalMetadata/Parsers/EpisodeXmlParser.cs index 8430f3b3c7..08454c8e71 100644 --- a/MediaBrowser.LocalMetadata/Parsers/EpisodeXmlParser.cs +++ b/MediaBrowser.LocalMetadata/Parsers/EpisodeXmlParser.cs @@ -1,13 +1,13 @@ -using System; +using MediaBrowser.Controller.Entities.TV; +using MediaBrowser.Controller.Providers; +using MediaBrowser.Model.Entities; +using MediaBrowser.Model.Logging; +using System; using System.Collections.Generic; using System.Globalization; using System.IO; using System.Threading; using System.Xml; -using MediaBrowser.Controller.Entities.TV; -using MediaBrowser.Controller.Providers; -using MediaBrowser.Model.Entities; -using MediaBrowser.Model.Logging; namespace MediaBrowser.LocalMetadata.Parsers { @@ -17,7 +17,6 @@ namespace MediaBrowser.LocalMetadata.Parsers public class EpisodeXmlParser : BaseItemXmlParser { private List _imagesFound; - private List _chaptersFound; public EpisodeXmlParser(ILogger logger) : base(logger) @@ -26,14 +25,12 @@ namespace MediaBrowser.LocalMetadata.Parsers private string _xmlPath; - public void Fetch(Episode item, + public void Fetch(MetadataResult item, List images, - List chapters, string metadataFile, CancellationToken cancellationToken) { _imagesFound = images; - _chaptersFound = chapters; _xmlPath = metadataFile; Fetch(item, metadataFile, cancellationToken); @@ -45,16 +42,13 @@ namespace MediaBrowser.LocalMetadata.Parsers /// Fetches the data from XML node. /// /// The reader. - /// The item. - protected override void FetchDataFromXmlNode(XmlReader reader, Episode item) + /// The result. + protected override void FetchDataFromXmlNode(XmlReader reader, MetadataResult result) { + var item = result.Item; + switch (reader.Name) { - case "Chapters": - - _chaptersFound.AddRange(FetchChaptersFromXmlNode(item, reader.ReadSubtree())); - break; - case "Episode": //MB generated metadata is within an "Episode" node @@ -67,7 +61,7 @@ namespace MediaBrowser.LocalMetadata.Parsers { if (subTree.NodeType == XmlNodeType.Element) { - FetchDataFromXmlNode(subTree, item); + FetchDataFromXmlNode(subTree, result); } } @@ -263,7 +257,7 @@ namespace MediaBrowser.LocalMetadata.Parsers default: - base.FetchDataFromXmlNode(reader, item); + base.FetchDataFromXmlNode(reader, result); break; } } diff --git a/MediaBrowser.LocalMetadata/Parsers/GameSystemXmlParser.cs b/MediaBrowser.LocalMetadata/Parsers/GameSystemXmlParser.cs index d449108c4b..8ae0eafecc 100644 --- a/MediaBrowser.LocalMetadata/Parsers/GameSystemXmlParser.cs +++ b/MediaBrowser.LocalMetadata/Parsers/GameSystemXmlParser.cs @@ -16,7 +16,7 @@ namespace MediaBrowser.LocalMetadata.Parsers } private readonly Task _cachedTask = Task.FromResult(true); - public Task FetchAsync(GameSystem item, string metadataFile, CancellationToken cancellationToken) + public Task FetchAsync(MetadataResult item, string metadataFile, CancellationToken cancellationToken) { Fetch(item, metadataFile, cancellationToken); @@ -29,9 +29,11 @@ namespace MediaBrowser.LocalMetadata.Parsers /// Fetches the data from XML node. /// /// The reader. - /// The item. - protected override void FetchDataFromXmlNode(XmlReader reader, GameSystem item) + /// The result. + protected override void FetchDataFromXmlNode(XmlReader reader, MetadataResult result) { + var item = result.Item; + switch (reader.Name) { case "GameSystem": @@ -56,7 +58,7 @@ namespace MediaBrowser.LocalMetadata.Parsers default: - base.FetchDataFromXmlNode(reader, item); + base.FetchDataFromXmlNode(reader, result); break; } } diff --git a/MediaBrowser.LocalMetadata/Parsers/GameXmlParser.cs b/MediaBrowser.LocalMetadata/Parsers/GameXmlParser.cs index 2caced8a94..b5a68c61f9 100644 --- a/MediaBrowser.LocalMetadata/Parsers/GameXmlParser.cs +++ b/MediaBrowser.LocalMetadata/Parsers/GameXmlParser.cs @@ -22,7 +22,7 @@ namespace MediaBrowser.LocalMetadata.Parsers } private readonly Task _cachedTask = Task.FromResult(true); - public Task FetchAsync(Game item, string metadataFile, CancellationToken cancellationToken) + public Task FetchAsync(MetadataResult item, string metadataFile, CancellationToken cancellationToken) { Fetch(item, metadataFile, cancellationToken); @@ -35,9 +35,11 @@ namespace MediaBrowser.LocalMetadata.Parsers /// Fetches the data from XML node. /// /// The reader. - /// The item. - protected override void FetchDataFromXmlNode(XmlReader reader, Game item) + /// The result. + protected override void FetchDataFromXmlNode(XmlReader reader, MetadataResult result) { + var item = result.Item; + switch (reader.Name) { case "GameSystem": @@ -97,7 +99,7 @@ namespace MediaBrowser.LocalMetadata.Parsers default: - base.FetchDataFromXmlNode(reader, item); + base.FetchDataFromXmlNode(reader, result); break; } } diff --git a/MediaBrowser.LocalMetadata/Parsers/MovieXmlParser.cs b/MediaBrowser.LocalMetadata/Parsers/MovieXmlParser.cs index 388a0d20d7..0b434231fd 100644 --- a/MediaBrowser.LocalMetadata/Parsers/MovieXmlParser.cs +++ b/MediaBrowser.LocalMetadata/Parsers/MovieXmlParser.cs @@ -1,43 +1,31 @@ -using System.Collections.Generic; -using System.Threading; -using System.Xml; -using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.Movies; using MediaBrowser.Controller.Providers; -using MediaBrowser.Model.Entities; using MediaBrowser.Model.Logging; +using System.Xml; namespace MediaBrowser.LocalMetadata.Parsers { /// /// Class EpisodeXmlParser /// - public class MovieXmlParser : BaseItemXmlParser