mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-03-13 05:36:36 +00:00
start people update
This commit is contained in:
@@ -636,7 +636,7 @@ namespace MediaBrowser.Server.Implementations.Dto
|
||||
// Ordering by person type to ensure actors and artists are at the front.
|
||||
// This is taking advantage of the fact that they both begin with A
|
||||
// This should be improved in the future
|
||||
var people = item.People.OrderBy(i => i.SortOrder ?? int.MaxValue)
|
||||
var people = _libraryManager.GetPeople(item).OrderBy(i => i.SortOrder ?? int.MaxValue)
|
||||
.ThenBy(i =>
|
||||
{
|
||||
if (i.IsType(PersonType.Actor))
|
||||
|
||||
@@ -94,7 +94,8 @@ namespace MediaBrowser.Server.Implementations.Intros
|
||||
Type = ItemWithTrailerType.ItemWithTrailer,
|
||||
User = user,
|
||||
WatchingItem = item,
|
||||
Random = random
|
||||
Random = random,
|
||||
LibraryManager = _libraryManager
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -134,7 +135,8 @@ namespace MediaBrowser.Server.Implementations.Intros
|
||||
Type = ItemWithTrailerType.ChannelTrailer,
|
||||
User = user,
|
||||
WatchingItem = item,
|
||||
Random = random
|
||||
Random = random,
|
||||
LibraryManager = _libraryManager
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -239,7 +241,7 @@ namespace MediaBrowser.Server.Implementations.Intros
|
||||
return true;
|
||||
}
|
||||
|
||||
internal static int GetSimiliarityScore(BaseItem item1, BaseItem item2, Random random)
|
||||
internal static int GetSimiliarityScore(BaseItem item1, BaseItem item2, Random random, ILibraryManager libraryManager)
|
||||
{
|
||||
var points = 0;
|
||||
|
||||
@@ -260,11 +262,11 @@ namespace MediaBrowser.Server.Implementations.Intros
|
||||
// Find common studios
|
||||
points += item1.Studios.Where(i => item2.Studios.Contains(i, StringComparer.OrdinalIgnoreCase)).Sum(i => 5);
|
||||
|
||||
var item2PeopleNames = item2.People.Select(i => i.Name)
|
||||
var item2PeopleNames = libraryManager.GetPeople(item2).Select(i => i.Name)
|
||||
.Distinct(StringComparer.OrdinalIgnoreCase)
|
||||
.ToDictionary(i => i, StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
points += item1.People.Where(i => item2PeopleNames.ContainsKey(i.Name)).Sum(i =>
|
||||
points += libraryManager.GetPeople(item1).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))
|
||||
{
|
||||
@@ -340,6 +342,7 @@ namespace MediaBrowser.Server.Implementations.Intros
|
||||
internal User User;
|
||||
internal BaseItem WatchingItem;
|
||||
internal Random Random;
|
||||
internal ILibraryManager LibraryManager;
|
||||
|
||||
private bool? _isPlayed;
|
||||
public bool IsPlayed
|
||||
@@ -361,7 +364,7 @@ namespace MediaBrowser.Server.Implementations.Intros
|
||||
{
|
||||
if (!_score.HasValue)
|
||||
{
|
||||
_score = GetSimiliarityScore(WatchingItem, Item, Random);
|
||||
_score = GetSimiliarityScore(WatchingItem, Item, Random, LibraryManager);
|
||||
}
|
||||
return _score.Value;
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MoreLinq;
|
||||
using SortOrder = MediaBrowser.Model.Entities.SortOrder;
|
||||
|
||||
namespace MediaBrowser.Server.Implementations.Library
|
||||
@@ -2055,5 +2056,26 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
item.ExtraType = ExtraType.Clip;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public List<PersonInfo> GetPeople(BaseItem item)
|
||||
{
|
||||
return item.People ?? new List<PersonInfo>();
|
||||
}
|
||||
|
||||
public List<PersonInfo> GetAllPeople()
|
||||
{
|
||||
return RootFolder.GetRecursiveChildren()
|
||||
.SelectMany(GetPeople)
|
||||
.Where(i => !string.IsNullOrWhiteSpace(i.Name))
|
||||
.DistinctBy(i => i.Name, StringComparer.OrdinalIgnoreCase)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public Task UpdatePeople(BaseItem item, List<PersonInfo> people)
|
||||
{
|
||||
item.People = people;
|
||||
return item.UpdateToRepository(ItemUpdateType.MetadataEdit, CancellationToken.None);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -257,7 +257,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
if (query.IncludePeople)
|
||||
{
|
||||
// Find persons
|
||||
var persons = items.SelectMany(i => i.People)
|
||||
var persons = items.SelectMany(i => _libraryManager.GetPeople(i))
|
||||
.Select(i => i.Name)
|
||||
.Where(i => !string.IsNullOrWhiteSpace(i))
|
||||
.Distinct(StringComparer.OrdinalIgnoreCase)
|
||||
|
||||
@@ -72,39 +72,6 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||
return options.DownloadOtherPeopleMetadata;
|
||||
}
|
||||
|
||||
private IEnumerable<PersonInfo> GetPeopleToValidate(BaseItem item, PeopleMetadataOptions options)
|
||||
{
|
||||
return item.People.Where(i =>
|
||||
{
|
||||
if (i.IsType(PersonType.Actor))
|
||||
{
|
||||
return options.DownloadActorMetadata;
|
||||
}
|
||||
if (i.IsType(PersonType.Director))
|
||||
{
|
||||
return options.DownloadDirectorMetadata;
|
||||
}
|
||||
if (i.IsType(PersonType.Composer))
|
||||
{
|
||||
return options.DownloadComposerMetadata;
|
||||
}
|
||||
if (i.IsType(PersonType.Writer))
|
||||
{
|
||||
return options.DownloadWriterMetadata;
|
||||
}
|
||||
if (i.IsType(PersonType.Producer))
|
||||
{
|
||||
return options.DownloadProducerMetadata;
|
||||
}
|
||||
if (i.IsType(PersonType.GuestStar))
|
||||
{
|
||||
return options.DownloadGuestStarMetadata;
|
||||
}
|
||||
|
||||
return options.DownloadOtherPeopleMetadata;
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validates the people.
|
||||
/// </summary>
|
||||
@@ -119,10 +86,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||
|
||||
var peopleOptions = _config.Configuration.PeopleMetadataOptions;
|
||||
|
||||
var people = _libraryManager.RootFolder.GetRecursiveChildren()
|
||||
.SelectMany(i => i.People)
|
||||
.Where(i => !string.IsNullOrWhiteSpace(i.Name))
|
||||
.ToList();
|
||||
var people = _libraryManager.GetAllPeople();
|
||||
|
||||
var dict = new Dictionary<string, bool>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
|
||||
@@ -143,6 +143,12 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||
_connection.AddColumn(_logger, "TypedBaseItems", "Name", "Text");
|
||||
_connection.AddColumn(_logger, "TypedBaseItems", "OfficialRating", "Text");
|
||||
|
||||
_connection.AddColumn(_logger, "TypedBaseItems", "MediaType", "Text");
|
||||
_connection.AddColumn(_logger, "TypedBaseItems", "Overview", "Text");
|
||||
_connection.AddColumn(_logger, "TypedBaseItems", "ParentIndexNumber", "INT");
|
||||
_connection.AddColumn(_logger, "TypedBaseItems", "PremiereDate", "DATETIME");
|
||||
_connection.AddColumn(_logger, "TypedBaseItems", "ProductionYear", "INT");
|
||||
|
||||
PrepareStatements();
|
||||
|
||||
_mediaStreamsRepository.Initialize();
|
||||
@@ -176,10 +182,15 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||
"IndexNumber",
|
||||
"IsLocked",
|
||||
"Name",
|
||||
"OfficialRating"
|
||||
"OfficialRating",
|
||||
"MediaType",
|
||||
"Overview",
|
||||
"ParentIndexNumber",
|
||||
"PremiereDate",
|
||||
"ProductionYear"
|
||||
};
|
||||
_saveItemCommand = _connection.CreateCommand();
|
||||
_saveItemCommand.CommandText = "replace into TypedBaseItems (" + string.Join(",", saveColumns.ToArray()) + ") values (@1, @2, @3, @4, @5, @6, @7, @8, @9, @10, @11, @12, @13, @14, @15, @16)";
|
||||
_saveItemCommand.CommandText = "replace into TypedBaseItems (" + string.Join(",", saveColumns.ToArray()) + ") values (@1, @2, @3, @4, @5, @6, @7, @8, @9, @10, @11, @12, @13, @14, @15, @16, @17, @18, @19, @20, @21)";
|
||||
for (var i = 1; i <= saveColumns.Count; i++)
|
||||
{
|
||||
_saveItemCommand.Parameters.Add(_saveItemCommand, "@" + i.ToString(CultureInfo.InvariantCulture));
|
||||
@@ -293,6 +304,12 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||
|
||||
_saveItemCommand.GetParameter(index++).Value = item.Name;
|
||||
_saveItemCommand.GetParameter(index++).Value = item.OfficialRating;
|
||||
|
||||
_saveItemCommand.GetParameter(index++).Value = item.MediaType;
|
||||
_saveItemCommand.GetParameter(index++).Value = item.Overview;
|
||||
_saveItemCommand.GetParameter(index++).Value = item.ParentIndexNumber;
|
||||
_saveItemCommand.GetParameter(index++).Value = item.PremiereDate;
|
||||
_saveItemCommand.GetParameter(index++).Value = item.ProductionYear;
|
||||
|
||||
_saveItemCommand.Transaction = transaction;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user