add GuestStar distinction

This commit is contained in:
Luke Pulverenti 2013-04-13 19:43:41 -04:00
parent 0ae93163bd
commit 7f1fdbf223
14 changed files with 62 additions and 24 deletions

View File

@ -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 /// If the Person filter is used, this can also be used to restrict to a specific person type
/// </summary> /// </summary>
/// <value>The type of the person.</value> /// <value>The type of the person.</value>
[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")] [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 PersonType { get; set; } public string PersonTypes { get; set; }
/// <summary> /// <summary>
/// Search characters used to find items /// Search characters used to find items
@ -448,11 +448,21 @@ namespace MediaBrowser.Api.UserLibrary
// Apply person filter // Apply person filter
if (!string.IsNullOrEmpty(personName)) if (!string.IsNullOrEmpty(personName))
{ {
var personType = request.PersonType; var personTypes = request.PersonTypes;
items = !string.IsNullOrEmpty(personType) if (string.IsNullOrEmpty(personTypes))
? 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))); 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; return items;

View File

@ -89,7 +89,6 @@ namespace MediaBrowser.Api.UserLibrary
{ {
var people = itemsList.SelectMany(i => i.People.OrderBy(p => p.Type)); var people = itemsList.SelectMany(i => i.People.OrderBy(p => p.Type));
return personTypes.Length == 0 ? return personTypes.Length == 0 ?
people : people :

View File

@ -32,7 +32,7 @@ namespace MediaBrowser.Controller.Entities
/// Gets or sets the name. /// Gets or sets the name.
/// </summary> /// </summary>
/// <value>The name.</value> /// <value>The name.</value>
public virtual string Name { get; set; } public string Name { get; set; }
/// <summary> /// <summary>
/// Gets or sets the id. /// Gets or sets the id.

View File

@ -127,7 +127,7 @@ namespace MediaBrowser.Controller.Entities
/// <returns>IEnumerable{BaseItem}.</returns> /// <returns>IEnumerable{BaseItem}.</returns>
protected IEnumerable<BaseItem> GetIndexByPerformer(User user) protected IEnumerable<BaseItem> GetIndexByPerformer(User user)
{ {
return GetIndexByPerson(user, new List<string> { PersonType.Actor, PersonType.MusicArtist }, LocalizedStrings.Instance.GetString("PerformerDispPref")); return GetIndexByPerson(user, new List<string> { PersonType.Actor, PersonType.MusicArtist, PersonType.GuestStar }, LocalizedStrings.Instance.GetString("PerformerDispPref"));
} }
/// <summary> /// <summary>

View File

@ -242,7 +242,6 @@ namespace MediaBrowser.Controller.Providers
} }
case "Actors": case "Actors":
case "GuestStars":
{ {
foreach (var p in SplitNames(reader.ReadElementContentAsString()).Select(v => new PersonInfo { Name = v.Trim(), Type = PersonType.Actor })) 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; 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": case "Trailer":
{ {
var val = reader.ReadElementContentAsString(); var val = reader.ReadElementContentAsString();

View File

@ -63,7 +63,20 @@ namespace MediaBrowser.Controller.Providers
{ {
// If the IBN location exists return the last modified date of any file in it // If the IBN location exists return the last modified date of any file in it
var location = GetLocation(item); 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();
} }
/// <summary> /// <summary>

View File

@ -263,21 +263,21 @@ namespace MediaBrowser.Controller.Providers.TV
var actors = doc.SafeGetString("//GuestStars"); var actors = doc.SafeGetString("//GuestStars");
if (actors != null) 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"); var directors = doc.SafeGetString("//Director");
if (directors != null) 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"); var writers = doc.SafeGetString("//Writer");
if (writers != null) 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) if (ConfigurationManager.Configuration.SaveLocalMeta)

View File

@ -322,7 +322,7 @@ namespace MediaBrowser.Controller.Providers.TV
personNode.AppendChild(doc.ImportNode(subNode, true)); personNode.AppendChild(doc.ImportNode(subNode, true));
//need to add the type //need to add the type
var typeNode = doc.CreateNode(XmlNodeType.Element, "Type", null); var typeNode = doc.CreateNode(XmlNodeType.Element, "Type", null);
typeNode.InnerText = "Actor"; typeNode.InnerText = PersonType.Actor;
personNode.AppendChild(typeNode); personNode.AppendChild(typeNode);
actorsNode.AppendChild(personNode); actorsNode.AppendChild(personNode);
} }

View File

@ -26,5 +26,9 @@ namespace MediaBrowser.Model.Entities
/// The music artist /// The music artist
/// </summary> /// </summary>
public const string MusicArtist = "MusicArtist"; public const string MusicArtist = "MusicArtist";
/// <summary>
/// The guest star
/// </summary>
public const string GuestStar = "GuestStar";
} }
} }

View File

@ -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 /// If the Person filter is used, this can also be used to restrict to a specific person type
/// </summary> /// </summary>
/// <value>The type of the person.</value> /// <value>The type of the person.</value>
public string PersonType { get; set; } public string[] PersonTypes { get; set; }
/// <summary> /// <summary>
/// Search characters used to find items /// Search characters used to find items

View File

@ -696,7 +696,7 @@ namespace MediaBrowser.Server.Implementations.Library
var tasks = new List<Task>(); var tasks = new List<Task>();
var includedPersonTypes = new[] { PersonType.Actor, PersonType.Director }; var includedPersonTypes = new[] { PersonType.Actor, PersonType.Director, PersonType.GuestStar };
var people = RootFolder.RecursiveChildren var people = RootFolder.RecursiveChildren
.Where(c => c.People != null) .Where(c => c.People != null)

View File

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd"> <package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata> <metadata>
<id>MediaBrowser.Common.Internal</id> <id>MediaBrowser.Common.Internal</id>
<version>3.0.73</version> <version>3.0.75</version>
<title>MediaBrowser.Common.Internal</title> <title>MediaBrowser.Common.Internal</title>
<authors>Luke</authors> <authors>Luke</authors>
<owners>ebr,Luke,scottisafool</owners> <owners>ebr,Luke,scottisafool</owners>
@ -12,7 +12,7 @@
<description>Contains common components shared by Media Browser Theatre and Media Browser Server. Not intended for plugin developer consumption.</description> <description>Contains common components shared by Media Browser Theatre and Media Browser Server. Not intended for plugin developer consumption.</description>
<copyright>Copyright © Media Browser 2013</copyright> <copyright>Copyright © Media Browser 2013</copyright>
<dependencies> <dependencies>
<dependency id="MediaBrowser.Common" version="3.0.73" /> <dependency id="MediaBrowser.Common" version="3.0.74" />
<dependency id="NLog" version="2.0.0.2000" /> <dependency id="NLog" version="2.0.0.2000" />
<dependency id="ServiceStack.Text" version="3.9.38" /> <dependency id="ServiceStack.Text" version="3.9.38" />
<dependency id="protobuf-net" version="2.0.0.621" /> <dependency id="protobuf-net" version="2.0.0.621" />

View File

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"> <package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata> <metadata>
<id>MediaBrowser.Common</id> <id>MediaBrowser.Common</id>
<version>3.0.73</version> <version>3.0.75</version>
<title>MediaBrowser.Common</title> <title>MediaBrowser.Common</title>
<authors>Media Browser Team</authors> <authors>Media Browser Team</authors>
<owners>ebr,Luke,scottisafool</owners> <owners>ebr,Luke,scottisafool</owners>

View File

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"> <package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata> <metadata>
<id>MediaBrowser.Server.Core</id> <id>MediaBrowser.Server.Core</id>
<version>3.0.73</version> <version>3.0.75</version>
<title>Media Browser.Server.Core</title> <title>Media Browser.Server.Core</title>
<authors>Media Browser Team</authors> <authors>Media Browser Team</authors>
<owners>ebr,Luke,scottisafool</owners> <owners>ebr,Luke,scottisafool</owners>
@ -12,7 +12,7 @@
<description>Contains core components required to build plugins for Media Browser Server.</description> <description>Contains core components required to build plugins for Media Browser Server.</description>
<copyright>Copyright © Media Browser 2013</copyright> <copyright>Copyright © Media Browser 2013</copyright>
<dependencies> <dependencies>
<dependency id="MediaBrowser.Common" version="3.0.73" /> <dependency id="MediaBrowser.Common" version="3.0.75" />
</dependencies> </dependencies>
</metadata> </metadata>
<files> <files>