add image download setting

This commit is contained in:
Luke Pulverenti
2016-02-25 23:09:42 -05:00
parent 1661c21152
commit 2c3113ced7
4 changed files with 50 additions and 6 deletions

View File

@@ -283,12 +283,7 @@ namespace MediaBrowser.Providers.Manager
if (!string.IsNullOrWhiteSpace(person.ImageUrl) && !personEntity.HasImage(ImageType.Primary))
{
personEntity.SetImage(new ItemImageInfo
{
Path = person.ImageUrl,
Type = ImageType.Primary,
IsPlaceholder = true
}, 0);
await AddPersonImage(personEntity, person.ImageUrl, cancellationToken).ConfigureAwait(false);
saveEntity = true;
updateType = updateType | ItemUpdateType.ImageUpdate;
@@ -302,6 +297,23 @@ namespace MediaBrowser.Providers.Manager
}
}
private async Task AddPersonImage(Person personEntity, string imageUrl, CancellationToken cancellationToken)
{
if (ServerConfigurationManager.Configuration.DownloadImagesInAdvance)
{
await ProviderManager.SaveImage(personEntity, imageUrl, null, ImageType.Primary, null, cancellationToken).ConfigureAwait(false);
}
else
{
personEntity.SetImage(new ItemImageInfo
{
Path = imageUrl,
Type = ImageType.Primary,
IsPlaceholder = true
}, 0);
}
}
private readonly Task _cachedTask = Task.FromResult(true);
protected virtual Task AfterMetadataRefresh(TItemType item, MetadataRefreshOptions refreshOptions, CancellationToken cancellationToken)
{