Merge pull request #5852 from cvium/fix-person-creation

Add Person to TypedBaseItems if it's new
pull/5864/head
Bond-009 4 years ago committed by GitHub
commit 4eeb69233d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -223,13 +223,13 @@ namespace MediaBrowser.Providers.Manager
var baseItem = result.Item; var baseItem = result.Item;
LibraryManager.UpdatePeople(baseItem, result.People); LibraryManager.UpdatePeople(baseItem, result.People);
await SavePeopleMetadataAsync(result.People, libraryOptions, cancellationToken).ConfigureAwait(false); await SavePeopleMetadataAsync(result.People, cancellationToken).ConfigureAwait(false);
} }
await result.Item.UpdateToRepositoryAsync(reason, cancellationToken).ConfigureAwait(false); await result.Item.UpdateToRepositoryAsync(reason, cancellationToken).ConfigureAwait(false);
} }
private async Task SavePeopleMetadataAsync(List<PersonInfo> people, LibraryOptions libraryOptions, CancellationToken cancellationToken) private async Task SavePeopleMetadataAsync(IEnumerable<PersonInfo> people, CancellationToken cancellationToken)
{ {
var personsToSave = new List<BaseItem>(); var personsToSave = new List<BaseItem>();
@ -237,11 +237,17 @@ namespace MediaBrowser.Providers.Manager
{ {
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
if (person.ProviderIds.Count > 0 || !string.IsNullOrWhiteSpace(person.ImageUrl))
{
var itemUpdateType = ItemUpdateType.MetadataDownload; var itemUpdateType = ItemUpdateType.MetadataDownload;
var saveEntity = false; var saveEntity = false;
var personEntity = LibraryManager.GetPerson(person.Name); var personEntity = LibraryManager.GetPerson(person.Name);
// if PresentationUniqueKey is empty it's likely a new item.
if (string.IsNullOrEmpty(personEntity.PresentationUniqueKey))
{
personEntity.PresentationUniqueKey = personEntity.CreatePresentationUniqueKey();
saveEntity = true;
}
foreach (var id in person.ProviderIds) foreach (var id in person.ProviderIds)
{ {
if (!string.Equals(personEntity.GetProviderId(id.Key), id.Value, StringComparison.OrdinalIgnoreCase)) if (!string.Equals(personEntity.GetProviderId(id.Key), id.Value, StringComparison.OrdinalIgnoreCase))
@ -271,7 +277,6 @@ namespace MediaBrowser.Providers.Manager
await LibraryManager.RunMetadataSavers(personEntity, itemUpdateType).ConfigureAwait(false); await LibraryManager.RunMetadataSavers(personEntity, itemUpdateType).ConfigureAwait(false);
} }
} }
}
LibraryManager.CreateItems(personsToSave, null, CancellationToken.None); LibraryManager.CreateItems(personsToSave, null, CancellationToken.None);
} }

Loading…
Cancel
Save