mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-11-15 09:59:06 -07:00
update people queries
This commit is contained in:
parent
8ccd82719a
commit
dfa17aec70
@ -70,7 +70,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));
|
||||
}
|
||||
|
||||
|
||||
|
@ -1699,8 +1699,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
.Select(i => i == null ? "-1" : i.Name)
|
||||
.ToList();
|
||||
|
||||
if (!(names.Any(
|
||||
v => libraryManager.GetPeople(item).Select(i => i.Name).Contains(v, StringComparer.OrdinalIgnoreCase))))
|
||||
if (!(names.Any(v => libraryManager.GetPeople(item).Select(i => i.Name).Contains(v, StringComparer.OrdinalIgnoreCase))))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -420,6 +420,13 @@ namespace MediaBrowser.Controller.Library
|
||||
/// <returns>List<PersonInfo>.</returns>
|
||||
List<PersonInfo> GetPeople(BaseItem item);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the people items.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <returns>List<Person>.</returns>
|
||||
List<Person> GetPeopleItems(BaseItem item);
|
||||
|
||||
/// <summary>
|
||||
/// Gets all people names.
|
||||
/// </summary>
|
||||
@ -433,5 +440,12 @@ 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);
|
||||
}
|
||||
}
|
@ -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="itemId">The item identifier.</param>
|
||||
/// <returns>List<System.String>.</returns>
|
||||
List<string> GetPeopleNames(Guid itemId);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -410,18 +410,7 @@ namespace MediaBrowser.Dlna.ContentDirectory
|
||||
{
|
||||
if (stubType.Value == StubType.People)
|
||||
{
|
||||
var items = _libraryManager.GetPeople(item).Select(i =>
|
||||
{
|
||||
try
|
||||
{
|
||||
return _libraryManager.GetPerson(i.Name);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
}).Where(i => i != null).ToArray();
|
||||
var items = _libraryManager.GetPeopleItems(item).ToArray();
|
||||
|
||||
var result = new QueryResult<ServerItem>
|
||||
{
|
||||
|
@ -59,9 +59,13 @@ namespace MediaBrowser.Providers.People
|
||||
// Avoid implicitly captured closure
|
||||
var itemName = item.Name;
|
||||
|
||||
var seriesWithPerson = _libraryManager.RootFolder
|
||||
.GetRecursiveChildren(i => i is Series && !string.IsNullOrEmpty(i.GetProviderId(MetadataProviders.Tvdb)) && _libraryManager.GetPeople(i).Any(p => string.Equals(p.Name, itemName, StringComparison.OrdinalIgnoreCase)))
|
||||
.Cast<Series>()
|
||||
var seriesWithPerson = _libraryManager.GetItems(new InternalItemsQuery
|
||||
{
|
||||
IncludeItemTypes = new[] { typeof(Series).Name },
|
||||
Person = itemName
|
||||
|
||||
}).Items.Cast<Series>()
|
||||
.Where(i => !string.IsNullOrEmpty(i.GetProviderId(MetadataProviders.Tvdb)))
|
||||
.ToList();
|
||||
|
||||
var infos = seriesWithPerson.Select(i => GetImageFromSeriesData(i, item.Name, cancellationToken))
|
||||
|
@ -1223,6 +1223,11 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
};
|
||||
}
|
||||
|
||||
public List<Guid> GetItemIds(InternalItemsQuery query)
|
||||
{
|
||||
return ItemRepository.GetItemIdsList(query);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the intros.
|
||||
/// </summary>
|
||||
@ -2057,12 +2062,28 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public List<PersonInfo> GetPeople(BaseItem item)
|
||||
{
|
||||
return item.People ?? ItemRepository.GetPeople(item.Id);
|
||||
}
|
||||
|
||||
public List<Person> GetPeopleItems(BaseItem item)
|
||||
{
|
||||
return ItemRepository.GetPeopleNames(item.Id).Select(i =>
|
||||
{
|
||||
try
|
||||
{
|
||||
return GetPerson(i);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.ErrorException("Error getting person", ex);
|
||||
return null;
|
||||
}
|
||||
|
||||
}).Where(i => i != null).ToList();
|
||||
}
|
||||
|
||||
public List<PersonInfo> GetAllPeople()
|
||||
{
|
||||
return RootFolder.GetRecursiveChildren()
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System.Runtime.Serialization;
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Controller.LiveTv;
|
||||
using MediaBrowser.Controller.Persistence;
|
||||
using MediaBrowser.Model.Entities;
|
||||
@ -739,9 +740,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||
{
|
||||
cmd.CommandText = "select guid from TypedBaseItems";
|
||||
|
||||
var whereClauses = GetWhereClauses(query, cmd, false);
|
||||
|
||||
whereClauses = GetWhereClauses(query, cmd, true);
|
||||
var whereClauses = GetWhereClauses(query, cmd, true);
|
||||
|
||||
var whereText = whereClauses.Count == 0 ?
|
||||
string.Empty :
|
||||
@ -914,6 +913,12 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(query.Person))
|
||||
{
|
||||
whereClauses.Add("Guid in (select ItemId from People where Name=@PersonName)");
|
||||
cmd.Parameters.Add(cmd, "@PersonName", DbType.String).Value = query.Person;
|
||||
}
|
||||
|
||||
if (addPaging)
|
||||
{
|
||||
if (query.StartIndex.HasValue && query.StartIndex.Value > 0)
|
||||
@ -938,6 +943,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||
{typeof(LiveTvChannel).Name, new []{typeof(LiveTvChannel).FullName}},
|
||||
{typeof(LiveTvVideoRecording).Name, new []{typeof(LiveTvVideoRecording).FullName}},
|
||||
{typeof(LiveTvAudioRecording).Name, new []{typeof(LiveTvAudioRecording).FullName}},
|
||||
{typeof(Series).Name, new []{typeof(Series).FullName}},
|
||||
{"Recording", new []{typeof(LiveTvAudioRecording).FullName, typeof(LiveTvVideoRecording).FullName}}
|
||||
};
|
||||
|
||||
@ -1127,6 +1133,34 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||
return _mediaStreamsRepository.SaveMediaStreams(id, streams, cancellationToken);
|
||||
}
|
||||
|
||||
public List<string> GetPeopleNames(Guid itemId)
|
||||
{
|
||||
if (itemId == Guid.Empty)
|
||||
{
|
||||
throw new ArgumentNullException("itemId");
|
||||
}
|
||||
|
||||
CheckDisposed();
|
||||
|
||||
using (var cmd = _connection.CreateCommand())
|
||||
{
|
||||
cmd.CommandText = "select Distinct Name from People where ItemId=@ItemId order by ListOrder";
|
||||
|
||||
cmd.Parameters.Add(cmd, "@ItemId", DbType.Guid).Value = itemId;
|
||||
|
||||
var list = new List<string>();
|
||||
|
||||
using (var reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess | CommandBehavior.SingleResult))
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
list.Add(reader.GetString(0));
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
public List<PersonInfo> GetPeople(Guid itemId)
|
||||
{
|
||||
|
@ -8,7 +8,6 @@ using MediaBrowser.Model.Logging;
|
||||
using MediaBrowser.XbmcMetadata.Configuration;
|
||||
using MediaBrowser.XbmcMetadata.Savers;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace MediaBrowser.XbmcMetadata
|
||||
{
|
||||
@ -50,7 +49,11 @@ namespace MediaBrowser.XbmcMetadata
|
||||
return;
|
||||
}
|
||||
|
||||
var items = _libraryManager.RootFolder.GetRecursiveChildren(person.GetItemFilter());
|
||||
var items = _libraryManager.GetItems(new InternalItemsQuery
|
||||
{
|
||||
Person = person.Name
|
||||
|
||||
}).Items;
|
||||
|
||||
foreach (var item in items)
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
using System.Reflection;
|
||||
|
||||
//[assembly: AssemblyVersion("3.0.*")]
|
||||
[assembly: AssemblyVersion("3.0.5666.0")]
|
||||
[assembly: AssemblyVersion("3.0.*")]
|
||||
//[assembly: AssemblyVersion("3.0.5666.0")]
|
||||
|
Loading…
Reference in New Issue
Block a user