3.0.5666.2

This commit is contained in:
Luke Pulverenti 2015-07-08 12:10:34 -04:00
parent dfa17aec70
commit 0291df3193
23 changed files with 287 additions and 113 deletions

View File

@ -344,9 +344,7 @@ namespace MediaBrowser.Api
return name;
}
return libraryManager.GetAllPeople()
.Select(i => i.Name)
.DistinctNames()
return libraryManager.GetPeopleNames(new InternalPeopleQuery())
.FirstOrDefault(i =>
{
i = _dashReplaceChars.Aggregate(i, (current, c) => current.Replace(c, SlugChar));

View File

@ -165,7 +165,7 @@ namespace MediaBrowser.Api.Movies
return ToOptimizedResult(result);
}
private async Task<ItemsResult> GetSimilarItemsResult(BaseGetSimilarItemsFromItem request, Func<BaseItem, bool> includeInSearch, Func<BaseItem, BaseItem, ILibraryManager, int> getSimilarityScore)
private async Task<ItemsResult> GetSimilarItemsResult(BaseGetSimilarItemsFromItem request, Func<BaseItem, bool> includeInSearch, Func<BaseItem, List<PersonInfo>, List<PersonInfo>, BaseItem, int> getSimilarityScore)
{
var user = !string.IsNullOrWhiteSpace(request.UserId) ? _userManager.GetUserById(request.UserId) : null;
@ -358,12 +358,15 @@ namespace MediaBrowser.Api.Movies
private IEnumerable<RecommendationDto> GetWithActor(User user, List<BaseItem> allMovies, IEnumerable<string> names, int itemLimit, DtoOptions dtoOptions, RecommendationType type)
{
var userId = user.Id;
foreach (var name in names)
{
var itemsWithActor = _libraryManager.GetItemIds(new InternalItemsQuery
{
Person = name
});
var items = allMovies
.Where(i => _libraryManager.GetPeople(i).Any(p => string.Equals(p.Name, name, StringComparison.OrdinalIgnoreCase)))
.Where(i => itemsWithActor.Contains(i.Id))
.Take(itemLimit)
.ToList();
@ -382,8 +385,6 @@ namespace MediaBrowser.Api.Movies
private IEnumerable<RecommendationDto> GetSimilarTo(User user, List<BaseItem> allMovies, IEnumerable<BaseItem> baselineItems, int itemLimit, DtoOptions dtoOptions, RecommendationType type)
{
var userId = user.Id;
foreach (var item in baselineItems)
{
var similar = SimilarItemsHelper
@ -406,18 +407,37 @@ namespace MediaBrowser.Api.Movies
private IEnumerable<string> GetActors(IEnumerable<BaseItem> items)
{
// Get the two leading actors for all movies
return items
.SelectMany(i => _libraryManager.GetPeople(i).Where(p => !string.Equals(PersonType.Director, p.Type, StringComparison.OrdinalIgnoreCase)).Take(2))
var people = _libraryManager.GetPeople(new InternalPeopleQuery
{
ExcludePersonTypes = new List<string>
{
PersonType.Director
},
MaxListOrder = 3
});
var itemIds = items.Select(i => i.Id).ToList();
return people
.Where(i => itemIds.Contains(i.ItemId))
.Select(i => i.Name)
.DistinctNames();
}
private IEnumerable<string> GetDirectors(IEnumerable<BaseItem> items)
{
return items
.Select(i => _libraryManager.GetPeople(i).FirstOrDefault(p => string.Equals(PersonType.Director, p.Type, StringComparison.OrdinalIgnoreCase)))
.Where(i => i != null)
var people = _libraryManager.GetPeople(new InternalPeopleQuery
{
PersonTypes = new List<string>
{
PersonType.Director
}
});
var itemIds = items.Select(i => i.Id).ToList();
return people
.Where(i => itemIds.Contains(i.ItemId))
.Select(i => i.Name)
.DistinctNames();
}

View File

@ -6,6 +6,7 @@ using MediaBrowser.Controller.Net;
using MediaBrowser.Controller.Persistence;
using ServiceStack;
using System;
using System.Collections.Generic;
using System.Linq;
namespace MediaBrowser.Api.Music
@ -68,12 +69,13 @@ namespace MediaBrowser.Api.Music
/// Gets the album similarity score.
/// </summary>
/// <param name="item1">The item1.</param>
/// <param name="item1People">The item1 people.</param>
/// <param name="allPeople">All people.</param>
/// <param name="item2">The item2.</param>
/// <param name="libraryManager">The library manager.</param>
/// <returns>System.Int32.</returns>
private int GetAlbumSimilarityScore(BaseItem item1, BaseItem item2, ILibraryManager libraryManager)
private int GetAlbumSimilarityScore(BaseItem item1, List<PersonInfo> item1People, List<PersonInfo> allPeople, BaseItem item2)
{
var points = SimilarItemsHelper.GetSimiliarityScore(item1, item2, libraryManager);
var points = SimilarItemsHelper.GetSimiliarityScore(item1, item1People, allPeople, item2);
var album1 = (MusicAlbum)item1;
var album2 = (MusicAlbum)item2;

View File

@ -632,7 +632,7 @@ namespace MediaBrowser.Api.Playback
{
var maxHeightParam = request.MaxHeight.Value.ToString(UsCulture);
filters.Add(string.Format("scale=trunc(oh*a*2)/2:min(ih\\,{0})", maxHeightParam));
filters.Add(string.Format("scale=trunc(oh*a/2)*2:min(ih\\,{0})", maxHeightParam));
}
if (string.Equals(outputVideoCodec, "h264_qsv", StringComparison.OrdinalIgnoreCase))

View File

@ -68,7 +68,7 @@ namespace MediaBrowser.Api
/// <param name="includeInSearch">The include in search.</param>
/// <param name="getSimilarityScore">The get similarity score.</param>
/// <returns>ItemsResult.</returns>
internal static ItemsResult GetSimilarItemsResult(DtoOptions dtoOptions, IUserManager userManager, IItemRepository itemRepository, ILibraryManager libraryManager, IUserDataManager userDataRepository, IDtoService dtoService, ILogger logger, BaseGetSimilarItemsFromItem request, Func<BaseItem, bool> includeInSearch, Func<BaseItem, BaseItem, ILibraryManager, int> getSimilarityScore)
internal static ItemsResult GetSimilarItemsResult(DtoOptions dtoOptions, IUserManager userManager, IItemRepository itemRepository, ILibraryManager libraryManager, IUserDataManager userDataRepository, IDtoService dtoService, ILogger logger, BaseGetSimilarItemsFromItem request, Func<BaseItem, bool> includeInSearch, Func<BaseItem, List<PersonInfo>, List<PersonInfo>, BaseItem, int> getSimilarityScore)
{
var user = !string.IsNullOrWhiteSpace(request.UserId) ? userManager.GetUserById(request.UserId) : null;
@ -110,12 +110,17 @@ namespace MediaBrowser.Api
/// <param name="inputItems">The input items.</param>
/// <param name="getSimilarityScore">The get similarity score.</param>
/// <returns>IEnumerable{BaseItem}.</returns>
internal static IEnumerable<BaseItem> GetSimilaritems(BaseItem item, ILibraryManager libraryManager, IEnumerable<BaseItem> inputItems, Func<BaseItem, BaseItem, ILibraryManager, int> getSimilarityScore)
internal static IEnumerable<BaseItem> GetSimilaritems(BaseItem item, ILibraryManager libraryManager, IEnumerable<BaseItem> inputItems, Func<BaseItem, List<PersonInfo>, List<PersonInfo>, BaseItem, int> getSimilarityScore)
{
var itemId = item.Id;
inputItems = inputItems.Where(i => i.Id != itemId);
var itemPeople = libraryManager.GetPeople(item);
var allPeople = libraryManager.GetPeople(new InternalPeopleQuery
{
AppearsInItemId = item.Id
});
return inputItems.Select(i => new Tuple<BaseItem, int>(i, getSimilarityScore(item, i, libraryManager)))
return inputItems.Select(i => new Tuple<BaseItem, int>(i, getSimilarityScore(item, itemPeople, allPeople, i)))
.Where(i => i.Item2 > 2)
.OrderByDescending(i => i.Item2)
.Select(i => i.Item1);
@ -147,9 +152,11 @@ namespace MediaBrowser.Api
/// Gets the similiarity score.
/// </summary>
/// <param name="item1">The item1.</param>
/// <param name="item1People">The item1 people.</param>
/// <param name="allPeople">All people.</param>
/// <param name="item2">The item2.</param>
/// <returns>System.Int32.</returns>
internal static int GetSimiliarityScore(BaseItem item1, BaseItem item2, ILibraryManager libraryManager)
internal static int GetSimiliarityScore(BaseItem item1, List<PersonInfo> item1People, List<PersonInfo> allPeople, BaseItem item2)
{
var points = 0;
@ -170,11 +177,13 @@ namespace MediaBrowser.Api
// Find common studios
points += item1.Studios.Where(i => item2.Studios.Contains(i, StringComparer.OrdinalIgnoreCase)).Sum(i => 3);
var item2PeopleNames = libraryManager.GetPeople(item2).Select(i => i.Name)
var item2PeopleNames = allPeople.Where(i => i.ItemId == item2.Id)
.Select(i => i.Name)
.Where(i => !string.IsNullOrWhiteSpace(i))
.DistinctNames()
.ToDictionary(i => i, StringComparer.OrdinalIgnoreCase);
points += libraryManager.GetPeople(item1).Where(i => item2PeopleNames.ContainsKey(i.Name)).Sum(i =>
points += item1People.Where(i => item2PeopleNames.ContainsKey(i.Name)).Sum(i =>
{
if (string.Equals(i.Type, PersonType.Director, StringComparison.OrdinalIgnoreCase) || string.Equals(i.Role, PersonType.Director, StringComparison.OrdinalIgnoreCase))
{

View File

@ -5,7 +5,6 @@ using MediaBrowser.Controller.Net;
using MediaBrowser.Controller.Persistence;
using MediaBrowser.Model.Dto;
using ServiceStack;
using System;
using System.Collections.Generic;
using System.Linq;
@ -151,18 +150,16 @@ namespace MediaBrowser.Api.UserLibrary
/// <param name="itemsList">The items list.</param>
/// <param name="personTypes">The person types.</param>
/// <returns>IEnumerable{PersonInfo}.</returns>
private IEnumerable<PersonInfo> GetAllPeople(IEnumerable<BaseItem> itemsList, string[] personTypes)
private IEnumerable<PersonInfo> GetAllPeople(IEnumerable<BaseItem> itemsList, IEnumerable<string> personTypes)
{
var people = itemsList.SelectMany(i => LibraryManager.GetPeople(i).OrderBy(p => p.SortOrder ?? int.MaxValue).ThenBy(p => p.Type));
var allIds = itemsList.Select(i => i.Id).ToList();
if (personTypes.Length > 0)
var allPeople = LibraryManager.GetPeople(new InternalPeopleQuery
{
people = people.Where(p =>
personTypes.Contains(p.Type ?? string.Empty, StringComparer.OrdinalIgnoreCase) ||
personTypes.Contains(p.Role ?? string.Empty, StringComparer.OrdinalIgnoreCase));
}
PersonTypes = personTypes.ToList()
});
return people;
return allPeople.Where(i => allIds.Contains(i.ItemId)).OrderBy(p => p.SortOrder ?? int.MaxValue).ThenBy(p => p.Type);
}
}
}

View File

@ -85,6 +85,13 @@ namespace MediaBrowser.Common.Implementations.Logging
{
rule.EnableLoggingForLevel(level);
}
foreach (var lev in rule.Levels.ToArray())
{
if (lev < level)
{
rule.DisableLoggingForLevel(lev);
}
}
}
}

View File

@ -6,7 +6,7 @@ namespace MediaBrowser.Controller.Entities
/// <summary>
/// Marker interface
/// </summary>
public interface IItemByName
public interface IItemByName : IHasMetadata
{
/// <summary>
/// Gets the tagged items.

View File

@ -0,0 +1,20 @@
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 InternalPeopleQuery()
{
PersonTypes = new List<string>();
ExcludePersonTypes = new List<string>();
}
}
}

View File

@ -99,6 +99,8 @@ namespace MediaBrowser.Controller.Entities
/// </summary>
public class PersonInfo
{
public Guid ItemId { get; set; }
/// <summary>
/// Gets or sets the name.
/// </summary>

View File

@ -1698,7 +1698,7 @@ namespace MediaBrowser.Controller.Entities
.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))))
{
return false;

View File

@ -420,12 +420,19 @@ namespace MediaBrowser.Controller.Library
/// <returns>List&lt;PersonInfo&gt;.</returns>
List<PersonInfo> GetPeople(BaseItem item);
/// <summary>
/// Gets the people.
/// </summary>
/// <param name="query">The query.</param>
/// <returns>List&lt;PersonInfo&gt;.</returns>
List<PersonInfo> GetPeople(InternalPeopleQuery query);
/// <summary>
/// Gets the people items.
/// </summary>
/// <param name="item">The item.</param>
/// <param name="query">The query.</param>
/// <returns>List&lt;Person&gt;.</returns>
List<Person> GetPeopleItems(BaseItem item);
List<Person> GetPeopleItems(InternalPeopleQuery query);
/// <summary>
/// Gets all people names.
@ -447,5 +454,12 @@ namespace MediaBrowser.Controller.Library
/// <param name="query">The query.</param>
/// <returns>List&lt;Guid&gt;.</returns>
List<Guid> GetItemIds(InternalItemsQuery query);
/// <summary>
/// Gets the people names.
/// </summary>
/// <param name="query">The query.</param>
/// <returns>List&lt;System.String&gt;.</returns>
List<string> GetPeopleNames(InternalPeopleQuery query);
}
}

View File

@ -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" />

View File

@ -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&lt;PersonInfo&gt;.</returns>
List<PersonInfo> GetPeople(Guid itemId);
List<PersonInfo> GetPeople(InternalPeopleQuery query);
/// <summary>
/// Updates the people.
@ -166,9 +166,9 @@ namespace MediaBrowser.Controller.Persistence
/// <summary>
/// Gets the people names.
/// </summary>
/// <param name="itemId">The item identifier.</param>
/// <param name="query">The query.</param>
/// <returns>List&lt;System.String&gt;.</returns>
List<string> GetPeopleNames(Guid itemId);
List<string> GetPeopleNames(InternalPeopleQuery query);
}
}

View File

@ -410,7 +410,11 @@ namespace MediaBrowser.Dlna.ContentDirectory
{
if (stubType.Value == StubType.People)
{
var items = _libraryManager.GetPeopleItems(item).ToArray();
var items = _libraryManager.GetPeopleItems(new InternalPeopleQuery
{
ItemId = item.Id
}).ToArray();
var result = new QueryResult<ServerItem>
{
@ -432,7 +436,7 @@ namespace MediaBrowser.Dlna.ContentDirectory
var person = item as Person;
if (person != null)
{
return await GetItemsFromPerson(person, user, startIndex, limit).ConfigureAwait(false);
return GetItemsFromPerson(person, user, startIndex, limit);
}
return ApplyPaging(new QueryResult<ServerItem>(), startIndex, limit);
@ -475,38 +479,19 @@ namespace MediaBrowser.Dlna.ContentDirectory
};
}
private async Task<QueryResult<ServerItem>> GetItemsFromPerson(Person person, User user, int? startIndex, int? limit)
private QueryResult<ServerItem> GetItemsFromPerson(Person person, User user, int? startIndex, int? limit)
{
var items = user.RootFolder.GetRecursiveChildren(user, i => i is Movie || i is Series && PeopleHelper.ContainsPerson(_libraryManager.GetPeople(i), person.Name))
.ToList();
var trailerResult = await _channelManager.GetAllMediaInternal(new AllChannelMediaQuery
var itemsWithPerson = _libraryManager.GetItems(new InternalItemsQuery
{
ContentTypes = new[] { ChannelMediaContentType.MovieExtra },
ExtraTypes = new[] { ExtraType.Trailer },
UserId = user.Id.ToString("N")
Person = person.Name
}, CancellationToken.None).ConfigureAwait(false);
}).Items;
var currentIds = items.Select(i => i.GetProviderId(MetadataProviders.Imdb))
var items = itemsWithPerson
.Where(i => i is Movie || i is Series || i is IChannelItem)
.Where(i => i.IsVisibleStandalone(user))
.ToList();
var trailersToAdd = trailerResult.Items
.Where(i => PeopleHelper.ContainsPerson(_libraryManager.GetPeople(i), person.Name))
.Where(i =>
{
// Try to filter out dupes using imdb id
var imdb = i.GetProviderId(MetadataProviders.Imdb);
if (!string.IsNullOrWhiteSpace(imdb) &&
currentIds.Contains(imdb, StringComparer.OrdinalIgnoreCase))
{
return false;
}
return true;
});
items.AddRange(trailersToAdd);
items = _libraryManager.Sort(items, user, new[] { ItemSortBy.SortName }, SortOrder.Ascending)
.Skip(startIndex ?? 0)
.Take(limit ?? int.MaxValue)
@ -558,7 +543,11 @@ namespace MediaBrowser.Dlna.ContentDirectory
private bool EnablePeopleDisplay(BaseItem item)
{
if (_libraryManager.GetPeople(item).Count > 0)
if (_libraryManager.GetPeopleNames(new InternalPeopleQuery
{
ItemId = item.Id
}).Count > 0)
{
return item is Movie;
}

View File

@ -834,7 +834,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
{
var heightParam = request.Height.Value.ToString(UsCulture);
filters.Add(string.Format("scale=trunc(oh*a*2)/2:{0}", heightParam));
filters.Add(string.Format("scale=trunc(oh*a/2)*2:{0}", heightParam));
}
// If a max width was requested
@ -850,7 +850,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
{
var maxHeightParam = request.MaxHeight.Value.ToString(UsCulture);
filters.Add(string.Format("scale=trunc(oh*a*2)/2:min(ih\\,{0})", maxHeightParam));
filters.Add(string.Format("scale=trunc(oh*a/2)*2:min(ih\\,{0})", maxHeightParam));
}
var output = string.Empty;

View File

@ -132,13 +132,7 @@ namespace MediaBrowser.Server.Implementations.Dto
{
if (options.Fields.Contains(ItemFields.ItemCounts))
{
var itemFilter = byName.GetItemFilter();
var libraryItems = user != null ?
user.RootFolder.GetRecursiveChildren(user, itemFilter) :
_libraryManager.RootFolder.GetRecursiveChildren(itemFilter);
SetItemByNameInfo(item, dto, libraryItems.ToList(), user);
SetItemByNameInfo(item, dto, GetTaggedItems(byName, user), user);
}
FillSyncInfo(dto, item, options, user, syncProgress);
@ -150,6 +144,33 @@ namespace MediaBrowser.Server.Implementations.Dto
return dto;
}
private List<BaseItem> GetTaggedItems(IItemByName byName, User user)
{
var person = byName as Person;
if (person != null)
{
var items = _libraryManager.GetItems(new InternalItemsQuery
{
Person = byName.Name
}).Items;
if (user != null)
{
return items.Where(i => i.IsVisibleStandalone(user)).ToList();
}
return items.ToList();
}
var itemFilter = byName.GetItemFilter();
return user != null ?
user.RootFolder.GetRecursiveChildren(user, itemFilter).ToList() :
_libraryManager.RootFolder.GetRecursiveChildren(itemFilter).ToList();
}
private SyncedItemProgress[] GetSyncedItemProgress(DtoOptions options)
{
if (!options.Fields.Contains(ItemFields.SyncInfo))

View File

@ -1,6 +1,6 @@
using MediaBrowser.Model.Logging;
using System;
using System.Net;
using System.Globalization;
using System.Text;
namespace MediaBrowser.Server.Implementations.HttpServer
@ -23,7 +23,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
//log.AppendLine("Headers: " + string.Join(",", response.Headers.AllKeys.Select(k => k + "=" + response.Headers[k])));
var responseTime = string.Format(". Response time: {0} ms.", duration.TotalMilliseconds);
var responseTime = string.Format(". Response time: {0} ms.", duration.TotalMilliseconds.ToString(CultureInfo.InvariantCulture));
var msg = "HTTP Response " + statusCode + " to " + endPoint + responseTime;

View File

@ -71,6 +71,12 @@ namespace MediaBrowser.Server.Implementations.Intros
var candidates = new List<ItemWithTrailer>();
var itemPeople = _libraryManager.GetPeople(item);
var allPeople = _libraryManager.GetPeople(new InternalPeopleQuery
{
AppearsInItemId = item.Id
});
if (config.EnableIntrosFromMoviesInLibrary)
{
var itemsWithTrailers = user.RootFolder
@ -94,6 +100,8 @@ namespace MediaBrowser.Server.Implementations.Intros
Type = ItemWithTrailerType.ItemWithTrailer,
User = user,
WatchingItem = item,
WatchingItemPeople = itemPeople,
AllPeople = allPeople,
Random = random,
LibraryManager = _libraryManager
}));
@ -135,6 +143,8 @@ namespace MediaBrowser.Server.Implementations.Intros
Type = ItemWithTrailerType.ChannelTrailer,
User = user,
WatchingItem = item,
WatchingItemPeople = itemPeople,
AllPeople = allPeople,
Random = random,
LibraryManager = _libraryManager
}));
@ -241,7 +251,7 @@ namespace MediaBrowser.Server.Implementations.Intros
return true;
}
internal static int GetSimiliarityScore(BaseItem item1, BaseItem item2, Random random, ILibraryManager libraryManager)
internal static int GetSimiliarityScore(BaseItem item1, List<PersonInfo> item1People, List<PersonInfo> allPeople, BaseItem item2, Random random, ILibraryManager libraryManager)
{
var points = 0;
@ -262,11 +272,13 @@ namespace MediaBrowser.Server.Implementations.Intros
// Find common studios
points += item1.Studios.Where(i => item2.Studios.Contains(i, StringComparer.OrdinalIgnoreCase)).Sum(i => 5);
var item2PeopleNames = libraryManager.GetPeople(item2).Select(i => i.Name)
.Distinct(StringComparer.OrdinalIgnoreCase)
var item2PeopleNames = allPeople.Where(i => i.ItemId == item2.Id)
.Select(i => i.Name)
.Where(i => !string.IsNullOrWhiteSpace(i))
.DistinctNames()
.ToDictionary(i => i, StringComparer.OrdinalIgnoreCase);
points += libraryManager.GetPeople(item1).Where(i => item2PeopleNames.ContainsKey(i.Name)).Sum(i =>
points += item1People.Where(i => item2PeopleNames.ContainsKey(i.Name)).Sum(i =>
{
if (string.Equals(i.Type, PersonType.Director, StringComparison.OrdinalIgnoreCase) || string.Equals(i.Role, PersonType.Director, StringComparison.OrdinalIgnoreCase))
{
@ -341,6 +353,8 @@ namespace MediaBrowser.Server.Implementations.Intros
internal ItemWithTrailerType Type;
internal User User;
internal BaseItem WatchingItem;
internal List<PersonInfo> WatchingItemPeople;
internal List<PersonInfo> AllPeople;
internal Random Random;
internal ILibraryManager LibraryManager;
@ -364,7 +378,7 @@ namespace MediaBrowser.Server.Implementations.Intros
{
if (!_score.HasValue)
{
_score = GetSimiliarityScore(WatchingItem, Item, Random, LibraryManager);
_score = GetSimiliarityScore(WatchingItem, WatchingItemPeople, AllPeople, Item, Random, LibraryManager);
}
return _score.Value;
}

View File

@ -2062,14 +2062,22 @@ namespace MediaBrowser.Server.Implementations.Library
}
}
public List<PersonInfo> GetPeople(BaseItem item)
public List<PersonInfo> GetPeople(InternalPeopleQuery query)
{
return item.People ?? ItemRepository.GetPeople(item.Id);
return ItemRepository.GetPeople(query);
}
public List<Person> GetPeopleItems(BaseItem item)
public List<PersonInfo> GetPeople(BaseItem item)
{
return ItemRepository.GetPeopleNames(item.Id).Select(i =>
return item.People ?? GetPeople(new InternalPeopleQuery
{
ItemId = item.Id
});
}
public List<Person> GetPeopleItems(InternalPeopleQuery query)
{
return ItemRepository.GetPeopleNames(query).Select(i =>
{
try
{
@ -2084,11 +2092,14 @@ namespace MediaBrowser.Server.Implementations.Library
}).Where(i => i != null).ToList();
}
public List<string> GetPeopleNames(InternalPeopleQuery query)
{
return ItemRepository.GetPeopleNames(query);
}
public List<PersonInfo> GetAllPeople()
{
return RootFolder.GetRecursiveChildren()
.SelectMany(GetPeople)
.Where(i => !string.IsNullOrWhiteSpace(i.Name))
return GetPeople(new InternalPeopleQuery())
.DistinctBy(i => i.Name, StringComparer.OrdinalIgnoreCase)
.ToList();
}

View File

@ -135,8 +135,8 @@ namespace MediaBrowser.Server.Implementations.Persistence
_connection.RunQueries(queries, _logger);
_connection.AddColumn(_logger, "TypedBaseItems", "Path", "Text");
_connection.AddColumn(_logger, "TypedBaseItems", "StartDate", "DATETIME");
_connection.AddColumn(_logger, "TypedBaseItems", "Path", "Text");
_connection.AddColumn(_logger, "TypedBaseItems", "StartDate", "DATETIME");
_connection.AddColumn(_logger, "TypedBaseItems", "EndDate", "DATETIME");
_connection.AddColumn(_logger, "TypedBaseItems", "ChannelId", "Text");
_connection.AddColumn(_logger, "TypedBaseItems", "IsMovie", "BIT");
@ -286,9 +286,9 @@ namespace MediaBrowser.Server.Implementations.Persistence
_saveItemCommand.GetParameter(index++).Value = item.GetType().FullName;
_saveItemCommand.GetParameter(index++).Value = _jsonSerializer.SerializeToBytes(item);
_saveItemCommand.GetParameter(index++).Value = item.Path;
_saveItemCommand.GetParameter(index++).Value = item.Path;
var hasStartDate = item as IHasStartDate;
var hasStartDate = item as IHasStartDate;
if (hasStartDate != null)
{
_saveItemCommand.GetParameter(index++).Value = hasStartDate.StartDate;
@ -329,7 +329,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
_saveItemCommand.GetParameter(index++).Value = item.ParentIndexNumber;
_saveItemCommand.GetParameter(index++).Value = item.PremiereDate;
_saveItemCommand.GetParameter(index++).Value = item.ProductionYear;
_saveItemCommand.Transaction = transaction;
_saveItemCommand.ExecuteNonQuery();
@ -1009,7 +1009,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
_deletePeopleCommand.GetParameter(0).Value = id;
_deletePeopleCommand.Transaction = transaction;
_deletePeopleCommand.ExecuteNonQuery();
// Delete the item
_deleteItemCommand.GetParameter(0).Value = id;
_deleteItemCommand.Transaction = transaction;
@ -1133,20 +1133,27 @@ namespace MediaBrowser.Server.Implementations.Persistence
return _mediaStreamsRepository.SaveMediaStreams(id, streams, cancellationToken);
}
public List<string> GetPeopleNames(Guid itemId)
public List<string> GetPeopleNames(InternalPeopleQuery query)
{
if (itemId == Guid.Empty)
if (query == null)
{
throw new ArgumentNullException("itemId");
throw new ArgumentNullException("query");
}
CheckDisposed();
using (var cmd = _connection.CreateCommand())
{
cmd.CommandText = "select Distinct Name from People where ItemId=@ItemId order by ListOrder";
cmd.CommandText = "select Distinct Name from People";
cmd.Parameters.Add(cmd, "@ItemId", DbType.Guid).Value = itemId;
var whereClauses = GetPeopleWhereClauses(query, cmd);
if (whereClauses.Count > 0)
{
cmd.CommandText += " where " + string.Join(" AND ", whereClauses.ToArray());
}
cmd.CommandText += " order by ListOrder";
var list = new List<string>();
@ -1162,20 +1169,27 @@ namespace MediaBrowser.Server.Implementations.Persistence
}
}
public List<PersonInfo> GetPeople(Guid itemId)
public List<PersonInfo> GetPeople(InternalPeopleQuery query)
{
if (itemId == Guid.Empty)
if (query == null)
{
throw new ArgumentNullException("itemId");
throw new ArgumentNullException("query");
}
CheckDisposed();
using (var cmd = _connection.CreateCommand())
{
cmd.CommandText = "select ItemId, Name, Role, PersonType, SortOrder from People where ItemId=@ItemId order by ListOrder";
cmd.CommandText = "select ItemId, Name, Role, PersonType, SortOrder from People";
cmd.Parameters.Add(cmd, "@ItemId", DbType.Guid).Value = itemId;
var whereClauses = GetPeopleWhereClauses(query, cmd);
if (whereClauses.Count > 0)
{
cmd.CommandText += " where " + string.Join(" AND ", whereClauses.ToArray());
}
cmd.CommandText += " order by ListOrder";
var list = new List<PersonInfo>();
@ -1191,6 +1205,51 @@ namespace MediaBrowser.Server.Implementations.Persistence
}
}
private List<string> GetPeopleWhereClauses(InternalPeopleQuery query, IDbCommand cmd)
{
var whereClauses = new List<string>();
if (query.ItemId != Guid.Empty)
{
whereClauses.Add("ItemId=@ItemId");
cmd.Parameters.Add(cmd, "@ItemId", DbType.Guid).Value = query.ItemId;
}
if (query.AppearsInItemId != Guid.Empty)
{
whereClauses.Add("Name in (Select Name from People where ItemId=@AppearsInItemId)");
cmd.Parameters.Add(cmd, "@AppearsInItemId", DbType.Guid).Value = query.AppearsInItemId;
}
if (query.PersonTypes.Count == 1)
{
whereClauses.Add("PersonType=@PersonType");
cmd.Parameters.Add(cmd, "@PersonType", DbType.String).Value = query.PersonTypes[0];
}
if (query.PersonTypes.Count > 1)
{
var val = string.Join(",", query.PersonTypes.Select(i => "'" + i + "'").ToArray());
whereClauses.Add("PersonType in (" + val + ")");
}
if (query.ExcludePersonTypes.Count == 1)
{
whereClauses.Add("PersonType<>@PersonType");
cmd.Parameters.Add(cmd, "@PersonType", DbType.String).Value = query.ExcludePersonTypes[0];
}
if (query.ExcludePersonTypes.Count > 1)
{
var val = string.Join(",", query.ExcludePersonTypes.Select(i => "'" + i + "'").ToArray());
whereClauses.Add("PersonType not in (" + val + ")");
}
if (query.MaxListOrder.HasValue)
{
whereClauses.Add("ListOrder<=@MaxListOrder");
cmd.Parameters.Add(cmd, "@MaxListOrder", DbType.Int32).Value = query.MaxListOrder.Value;
}
return whereClauses;
}
public async Task UpdatePeople(Guid itemId, List<PersonInfo> people)
{
if (itemId == Guid.Empty)
@ -1277,6 +1336,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
{
var item = new PersonInfo();
item.ItemId = reader.GetGuid(0);
item.Name = reader.GetString(1);
if (!reader.IsDBNull(2))

View File

@ -124,6 +124,15 @@ namespace MediaBrowser.WebDashboard.Api
var fullPath = Path.Combine(rootPath, virtualPath.Replace('/', Path.DirectorySeparatorChar));
try
{
fullPath = Path.GetFullPath(fullPath);
}
catch (Exception ex)
{
_logger.ErrorException("Error in Path.GetFullPath", ex);
}
// Don't allow file system access outside of the source folder
if (!_fileSystem.ContainsSubPath(rootPath, fullPath))
{
@ -654,7 +663,7 @@ namespace MediaBrowser.WebDashboard.Api
await AppendResource(memoryStream, "thirdparty/jquerymobile-1.4.5/jquery.mobile.custom.theme.min.css", newLineBytes).ConfigureAwait(false);
await AppendResource(memoryStream, "thirdparty/jquerymobile-1.4.5/jquery.mobile.custom.structure.min.css", newLineBytes).ConfigureAwait(false);
var files = new[]
{
"css/site.css",

View File

@ -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.2")]