From 7f1fdbf223f95dfc1435a8ff1b82fd635cc9b1d9 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 13 Apr 2013 19:43:41 -0400 Subject: [PATCH] add GuestStar distinction --- MediaBrowser.Api/UserLibrary/ItemsService.cs | 22 ++++++++++++++----- .../UserLibrary/PersonsService.cs | 1 - MediaBrowser.Controller/Entities/BaseItem.cs | 6 ++--- MediaBrowser.Controller/Entities/Folder.cs | 2 +- .../Providers/BaseItemXmlParser.cs | 14 +++++++++++- .../Providers/ImagesByNameProvider.cs | 15 ++++++++++++- .../Providers/TV/RemoteEpisodeProvider.cs | 6 ++--- .../Providers/TV/RemoteSeriesProvider.cs | 2 +- MediaBrowser.Model/Entities/PersonType.cs | 4 ++++ MediaBrowser.Model/Querying/ItemQuery.cs | 2 +- .../Library/LibraryManager.cs | 2 +- Nuget/MediaBrowser.Common.Internal.nuspec | 4 ++-- Nuget/MediaBrowser.Common.nuspec | 2 +- Nuget/MediaBrowser.Server.Core.nuspec | 4 ++-- 14 files changed, 62 insertions(+), 24 deletions(-) diff --git a/MediaBrowser.Api/UserLibrary/ItemsService.cs b/MediaBrowser.Api/UserLibrary/ItemsService.cs index c907dfe9b..cd6bd7854 100644 --- a/MediaBrowser.Api/UserLibrary/ItemsService.cs +++ b/MediaBrowser.Api/UserLibrary/ItemsService.cs @@ -38,8 +38,8 @@ namespace MediaBrowser.Api.UserLibrary /// If the Person filter is used, this can also be used to restrict to a specific person type /// /// The type of the person. - [ApiMember(Name = "PersonType", Description = "Optional. If specified, along with Person, results will be filtered to include only those containing the specified person and PersonType.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] - public string PersonType { get; set; } + [ApiMember(Name = "PersonTypes", Description = "Optional. If specified, along with Person, results will be filtered to include only those containing the specified person and PersonType. Allows multiple, comma-delimited", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] + public string PersonTypes { get; set; } /// /// Search characters used to find items @@ -448,11 +448,21 @@ namespace MediaBrowser.Api.UserLibrary // Apply person filter if (!string.IsNullOrEmpty(personName)) { - var personType = request.PersonType; + var personTypes = request.PersonTypes; - items = !string.IsNullOrEmpty(personType) - ? items.Where(item => item.People != null && item.People.Any(p => p.Name.Equals(personName, StringComparison.OrdinalIgnoreCase) && p.Type.Equals(personType, StringComparison.OrdinalIgnoreCase))) - : items.Where(item => item.People != null && item.People.Any(p => p.Name.Equals(personName, StringComparison.OrdinalIgnoreCase))); + if (string.IsNullOrEmpty(personTypes)) + { + items = items.Where(item => item.People != null && item.People.Any(p => string.Equals(p.Name, personName, StringComparison.OrdinalIgnoreCase))); + } + else + { + var types = personTypes.Split(','); + + items = items.Where(item => + item.People != null && + item.People.Any(p => + p.Name.Equals(personName, StringComparison.OrdinalIgnoreCase) && types.Contains(p.Type, StringComparer.OrdinalIgnoreCase))); + } } return items; diff --git a/MediaBrowser.Api/UserLibrary/PersonsService.cs b/MediaBrowser.Api/UserLibrary/PersonsService.cs index 698530eb5..fe5cf39f6 100644 --- a/MediaBrowser.Api/UserLibrary/PersonsService.cs +++ b/MediaBrowser.Api/UserLibrary/PersonsService.cs @@ -89,7 +89,6 @@ namespace MediaBrowser.Api.UserLibrary { var people = itemsList.SelectMany(i => i.People.OrderBy(p => p.Type)); - return personTypes.Length == 0 ? people : diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index d8a0db69a..3c60d3a39 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -32,7 +32,7 @@ namespace MediaBrowser.Controller.Entities /// Gets or sets the name. /// /// The name. - public virtual string Name { get; set; } + public string Name { get; set; } /// /// Gets or sets the id. @@ -477,7 +477,7 @@ namespace MediaBrowser.Controller.Entities /// /// The end date. public DateTime? EndDate { get; set; } - + /// /// Gets or sets the display type of the media. /// @@ -569,7 +569,7 @@ namespace MediaBrowser.Controller.Entities /// /// The production locations. public List ProductionLocations { get; set; } - + /// /// Gets or sets the community rating. /// diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index fed6bb7de..5816b23f8 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -127,7 +127,7 @@ namespace MediaBrowser.Controller.Entities /// IEnumerable{BaseItem}. protected IEnumerable GetIndexByPerformer(User user) { - return GetIndexByPerson(user, new List { PersonType.Actor, PersonType.MusicArtist }, LocalizedStrings.Instance.GetString("PerformerDispPref")); + return GetIndexByPerson(user, new List { PersonType.Actor, PersonType.MusicArtist, PersonType.GuestStar }, LocalizedStrings.Instance.GetString("PerformerDispPref")); } /// diff --git a/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs b/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs index d539ed771..e0091cd80 100644 --- a/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs +++ b/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs @@ -242,7 +242,6 @@ namespace MediaBrowser.Controller.Providers } case "Actors": - case "GuestStars": { foreach (var p in SplitNames(reader.ReadElementContentAsString()).Select(v => new PersonInfo { Name = v.Trim(), Type = PersonType.Actor })) { @@ -255,6 +254,19 @@ namespace MediaBrowser.Controller.Providers break; } + case "GuestStars": + { + foreach (var p in SplitNames(reader.ReadElementContentAsString()).Select(v => new PersonInfo { Name = v.Trim(), Type = PersonType.GuestStar })) + { + if (string.IsNullOrWhiteSpace(p.Name)) + { + continue; + } + item.AddPerson(p); + } + break; + } + case "Trailer": { var val = reader.ReadElementContentAsString(); diff --git a/MediaBrowser.Controller/Providers/ImagesByNameProvider.cs b/MediaBrowser.Controller/Providers/ImagesByNameProvider.cs index 53ff94720..1c4c783c4 100644 --- a/MediaBrowser.Controller/Providers/ImagesByNameProvider.cs +++ b/MediaBrowser.Controller/Providers/ImagesByNameProvider.cs @@ -63,7 +63,20 @@ namespace MediaBrowser.Controller.Providers { // If the IBN location exists return the last modified date of any file in it var location = GetLocation(item); - return Directory.Exists(location) ? FileSystem.GetFiles(location).Select(f => f.CreationTimeUtc > f.LastWriteTimeUtc ? f.CreationTimeUtc : f.LastWriteTimeUtc).Max() : DateTime.MinValue; + + if (!Directory.Exists(location)) + { + return DateTime.MinValue; + } + + var files = FileSystem.GetFiles(location).ToList(); + + if (files.Count == 0) + { + return DateTime.MinValue; + } + + return files.Select(f => f.CreationTimeUtc > f.LastWriteTimeUtc ? f.CreationTimeUtc : f.LastWriteTimeUtc).Max(); } /// diff --git a/MediaBrowser.Controller/Providers/TV/RemoteEpisodeProvider.cs b/MediaBrowser.Controller/Providers/TV/RemoteEpisodeProvider.cs index 6be0881b4..b5c6df7ec 100644 --- a/MediaBrowser.Controller/Providers/TV/RemoteEpisodeProvider.cs +++ b/MediaBrowser.Controller/Providers/TV/RemoteEpisodeProvider.cs @@ -263,21 +263,21 @@ namespace MediaBrowser.Controller.Providers.TV var actors = doc.SafeGetString("//GuestStars"); if (actors != null) { - episode.AddPeople(actors.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries).Select(str => new PersonInfo { Type = "Actor", Name = str })); + episode.AddPeople(actors.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries).Select(str => new PersonInfo { Type = PersonType.GuestStar, Name = str })); } var directors = doc.SafeGetString("//Director"); if (directors != null) { - episode.AddPeople(directors.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries).Select(str => new PersonInfo { Type = "Director", Name = str })); + episode.AddPeople(directors.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries).Select(str => new PersonInfo { Type = PersonType.Director, Name = str })); } var writers = doc.SafeGetString("//Writer"); if (writers != null) { - episode.AddPeople(writers.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries).Select(str => new PersonInfo { Type = "Writer", Name = str })); + episode.AddPeople(writers.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries).Select(str => new PersonInfo { Type = PersonType.Writer, Name = str })); } if (ConfigurationManager.Configuration.SaveLocalMeta) diff --git a/MediaBrowser.Controller/Providers/TV/RemoteSeriesProvider.cs b/MediaBrowser.Controller/Providers/TV/RemoteSeriesProvider.cs index f4e6d7893..89cb89289 100644 --- a/MediaBrowser.Controller/Providers/TV/RemoteSeriesProvider.cs +++ b/MediaBrowser.Controller/Providers/TV/RemoteSeriesProvider.cs @@ -322,7 +322,7 @@ namespace MediaBrowser.Controller.Providers.TV personNode.AppendChild(doc.ImportNode(subNode, true)); //need to add the type var typeNode = doc.CreateNode(XmlNodeType.Element, "Type", null); - typeNode.InnerText = "Actor"; + typeNode.InnerText = PersonType.Actor; personNode.AppendChild(typeNode); actorsNode.AppendChild(personNode); } diff --git a/MediaBrowser.Model/Entities/PersonType.cs b/MediaBrowser.Model/Entities/PersonType.cs index fca1fbf20..e8c46e29a 100644 --- a/MediaBrowser.Model/Entities/PersonType.cs +++ b/MediaBrowser.Model/Entities/PersonType.cs @@ -26,5 +26,9 @@ namespace MediaBrowser.Model.Entities /// The music artist /// public const string MusicArtist = "MusicArtist"; + /// + /// The guest star + /// + public const string GuestStar = "GuestStar"; } } diff --git a/MediaBrowser.Model/Querying/ItemQuery.cs b/MediaBrowser.Model/Querying/ItemQuery.cs index 86886d751..59a5e938d 100644 --- a/MediaBrowser.Model/Querying/ItemQuery.cs +++ b/MediaBrowser.Model/Querying/ItemQuery.cs @@ -120,7 +120,7 @@ namespace MediaBrowser.Model.Querying /// If the Person filter is used, this can also be used to restrict to a specific person type /// /// The type of the person. - public string PersonType { get; set; } + public string[] PersonTypes { get; set; } /// /// Search characters used to find items diff --git a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs index 3bb5472df..ca261a393 100644 --- a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs +++ b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs @@ -696,7 +696,7 @@ namespace MediaBrowser.Server.Implementations.Library var tasks = new List(); - var includedPersonTypes = new[] { PersonType.Actor, PersonType.Director }; + var includedPersonTypes = new[] { PersonType.Actor, PersonType.Director, PersonType.GuestStar }; var people = RootFolder.RecursiveChildren .Where(c => c.People != null) diff --git a/Nuget/MediaBrowser.Common.Internal.nuspec b/Nuget/MediaBrowser.Common.Internal.nuspec index ee5dd453d..861112b50 100644 --- a/Nuget/MediaBrowser.Common.Internal.nuspec +++ b/Nuget/MediaBrowser.Common.Internal.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common.Internal - 3.0.73 + 3.0.75 MediaBrowser.Common.Internal Luke ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains common components shared by Media Browser Theatre and Media Browser Server. Not intended for plugin developer consumption. Copyright © Media Browser 2013 - + diff --git a/Nuget/MediaBrowser.Common.nuspec b/Nuget/MediaBrowser.Common.nuspec index 5b721d6c1..f034329f9 100644 --- a/Nuget/MediaBrowser.Common.nuspec +++ b/Nuget/MediaBrowser.Common.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common - 3.0.73 + 3.0.75 MediaBrowser.Common Media Browser Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Server.Core.nuspec b/Nuget/MediaBrowser.Server.Core.nuspec index f420da078..1797f275c 100644 --- a/Nuget/MediaBrowser.Server.Core.nuspec +++ b/Nuget/MediaBrowser.Server.Core.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Server.Core - 3.0.73 + 3.0.75 Media Browser.Server.Core Media Browser Team ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains core components required to build plugins for Media Browser Server. Copyright © Media Browser 2013 - +