|
|
|
@ -56,7 +56,7 @@ namespace MediaBrowser.Providers.Manager
|
|
|
|
|
return hasChanges;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<RefreshResult> RefreshImages(IHasImages item, IEnumerable<IImageProvider> imageProviders, ImageRefreshOptions refreshOptions, MetadataOptions savedOptions, CancellationToken cancellationToken)
|
|
|
|
|
public async Task<RefreshResult> RefreshImages(IHasImages item, LibraryOptions libraryOptions, IEnumerable<IImageProvider> imageProviders, ImageRefreshOptions refreshOptions, MetadataOptions savedOptions, CancellationToken cancellationToken)
|
|
|
|
|
{
|
|
|
|
|
if (refreshOptions.IsReplacingImage(ImageType.Backdrop))
|
|
|
|
|
{
|
|
|
|
@ -84,7 +84,7 @@ namespace MediaBrowser.Providers.Manager
|
|
|
|
|
|
|
|
|
|
if (remoteProvider != null)
|
|
|
|
|
{
|
|
|
|
|
await RefreshFromProvider(item, remoteProvider, refreshOptions, savedOptions, backdropLimit, screenshotLimit, downloadedImages, result, cancellationToken).ConfigureAwait(false);
|
|
|
|
|
await RefreshFromProvider(item, libraryOptions, remoteProvider, refreshOptions, savedOptions, backdropLimit, screenshotLimit, downloadedImages, result, cancellationToken).ConfigureAwait(false);
|
|
|
|
|
providerIds.Add(provider.GetType().FullName.GetMD5());
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
@ -249,7 +249,7 @@ namespace MediaBrowser.Providers.Manager
|
|
|
|
|
/// <param name="result">The result.</param>
|
|
|
|
|
/// <param name="cancellationToken">The cancellation token.</param>
|
|
|
|
|
/// <returns>Task.</returns>
|
|
|
|
|
private async Task RefreshFromProvider(IHasImages item,
|
|
|
|
|
private async Task RefreshFromProvider(IHasImages item, LibraryOptions libraryOptions,
|
|
|
|
|
IRemoteImageProvider provider,
|
|
|
|
|
ImageRefreshOptions refreshOptions,
|
|
|
|
|
MetadataOptions savedOptions,
|
|
|
|
@ -293,7 +293,7 @@ namespace MediaBrowser.Providers.Manager
|
|
|
|
|
if (!HasImage(item, imageType) || (refreshOptions.IsReplacingImage(imageType) && !downloadedImages.Contains(imageType)))
|
|
|
|
|
{
|
|
|
|
|
minWidth = savedOptions.GetMinWidth(imageType);
|
|
|
|
|
var downloaded = await DownloadImage(item, provider, result, list, minWidth, imageType, cancellationToken).ConfigureAwait(false);
|
|
|
|
|
var downloaded = await DownloadImage(item, libraryOptions, provider, result, list, minWidth, imageType, cancellationToken).ConfigureAwait(false);
|
|
|
|
|
|
|
|
|
|
if (downloaded)
|
|
|
|
|
{
|
|
|
|
@ -305,7 +305,7 @@ namespace MediaBrowser.Providers.Manager
|
|
|
|
|
if (!item.LockedFields.Contains(MetadataFields.Backdrops))
|
|
|
|
|
{
|
|
|
|
|
minWidth = savedOptions.GetMinWidth(ImageType.Backdrop);
|
|
|
|
|
await DownloadBackdrops(item, ImageType.Backdrop, backdropLimit, provider, result, list, minWidth, cancellationToken).ConfigureAwait(false);
|
|
|
|
|
await DownloadBackdrops(item, libraryOptions, ImageType.Backdrop, backdropLimit, provider, result, list, minWidth, cancellationToken).ConfigureAwait(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!item.LockedFields.Contains(MetadataFields.Screenshots))
|
|
|
|
@ -314,7 +314,7 @@ namespace MediaBrowser.Providers.Manager
|
|
|
|
|
if (hasScreenshots != null)
|
|
|
|
|
{
|
|
|
|
|
minWidth = savedOptions.GetMinWidth(ImageType.Screenshot);
|
|
|
|
|
await DownloadBackdrops(item, ImageType.Screenshot, screenshotLimit, provider, result, list, minWidth, cancellationToken).ConfigureAwait(false);
|
|
|
|
|
await DownloadBackdrops(item, libraryOptions, ImageType.Screenshot, screenshotLimit, provider, result, list, minWidth, cancellationToken).ConfigureAwait(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -472,7 +472,7 @@ namespace MediaBrowser.Providers.Manager
|
|
|
|
|
return changed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async Task<bool> DownloadImage(IHasImages item,
|
|
|
|
|
private async Task<bool> DownloadImage(IHasImages item, LibraryOptions libraryOptions,
|
|
|
|
|
IRemoteImageProvider provider,
|
|
|
|
|
RefreshResult result,
|
|
|
|
|
IEnumerable<RemoteImageInfo> images,
|
|
|
|
@ -484,7 +484,7 @@ namespace MediaBrowser.Providers.Manager
|
|
|
|
|
.Where(i => i.Type == type && !(i.Width.HasValue && i.Width.Value < minWidth))
|
|
|
|
|
.ToList();
|
|
|
|
|
|
|
|
|
|
if (EnableImageStub(item, type) && eligibleImages.Count > 0)
|
|
|
|
|
if (EnableImageStub(item, type, libraryOptions) && eligibleImages.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
SaveImageStub(item, type, eligibleImages.Select(i => i.Url));
|
|
|
|
|
result.UpdateType = result.UpdateType | ItemUpdateType.ImageUpdate;
|
|
|
|
@ -518,14 +518,14 @@ namespace MediaBrowser.Providers.Manager
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool EnableImageStub(IHasImages item, ImageType type)
|
|
|
|
|
private bool EnableImageStub(IHasImages item, ImageType type, LibraryOptions libraryOptions)
|
|
|
|
|
{
|
|
|
|
|
if (item is LiveTvProgram)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (_config.Configuration.DownloadImagesInAdvance)
|
|
|
|
|
if (libraryOptions.DownloadImagesInAdvance)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
@ -585,7 +585,7 @@ namespace MediaBrowser.Providers.Manager
|
|
|
|
|
}, newIndex);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async Task DownloadBackdrops(IHasImages item, ImageType imageType, int limit, IRemoteImageProvider provider, RefreshResult result, IEnumerable<RemoteImageInfo> images, int minWidth, CancellationToken cancellationToken)
|
|
|
|
|
private async Task DownloadBackdrops(IHasImages item, LibraryOptions libraryOptions, ImageType imageType, int limit, IRemoteImageProvider provider, RefreshResult result, IEnumerable<RemoteImageInfo> images, int minWidth, CancellationToken cancellationToken)
|
|
|
|
|
{
|
|
|
|
|
foreach (var image in images.Where(i => i.Type == imageType))
|
|
|
|
|
{
|
|
|
|
@ -601,7 +601,7 @@ namespace MediaBrowser.Providers.Manager
|
|
|
|
|
|
|
|
|
|
var url = image.Url;
|
|
|
|
|
|
|
|
|
|
if (EnableImageStub(item, imageType))
|
|
|
|
|
if (EnableImageStub(item, imageType, libraryOptions))
|
|
|
|
|
{
|
|
|
|
|
SaveImageStub(item, imageType, new[] { url });
|
|
|
|
|
result.UpdateType = result.UpdateType | ItemUpdateType.ImageUpdate;
|
|
|
|
|