move download images in advance option from global to per library
This commit is contained in:
parent
d87cfdb260
commit
0f760af82c
|
@ -8,6 +8,7 @@
|
||||||
public int SchemaVersion { get; set; }
|
public int SchemaVersion { get; set; }
|
||||||
public bool EnableChapterImageExtraction { get; set; }
|
public bool EnableChapterImageExtraction { get; set; }
|
||||||
public bool ExtractChapterImagesDuringLibraryScan { get; set; }
|
public bool ExtractChapterImagesDuringLibraryScan { get; set; }
|
||||||
|
public bool DownloadImagesInAdvance { get; set; }
|
||||||
|
|
||||||
public LibraryOptions()
|
public LibraryOptions()
|
||||||
{
|
{
|
||||||
|
|
|
@ -191,8 +191,6 @@ namespace MediaBrowser.Model.Configuration
|
||||||
public int SchemaVersion { get; set; }
|
public int SchemaVersion { get; set; }
|
||||||
public int SqliteCacheSize { get; set; }
|
public int SqliteCacheSize { get; set; }
|
||||||
|
|
||||||
public bool DownloadImagesInAdvance { get; set; }
|
|
||||||
|
|
||||||
public bool EnableAnonymousUsageReporting { get; set; }
|
public bool EnableAnonymousUsageReporting { get; set; }
|
||||||
public bool EnableStandaloneMusicKeys { get; set; }
|
public bool EnableStandaloneMusicKeys { get; set; }
|
||||||
public bool EnableLocalizedGuids { get; set; }
|
public bool EnableLocalizedGuids { get; set; }
|
||||||
|
|
|
@ -56,7 +56,7 @@ namespace MediaBrowser.Providers.Manager
|
||||||
return hasChanges;
|
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))
|
if (refreshOptions.IsReplacingImage(ImageType.Backdrop))
|
||||||
{
|
{
|
||||||
|
@ -84,7 +84,7 @@ namespace MediaBrowser.Providers.Manager
|
||||||
|
|
||||||
if (remoteProvider != null)
|
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());
|
providerIds.Add(provider.GetType().FullName.GetMD5());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -249,7 +249,7 @@ namespace MediaBrowser.Providers.Manager
|
||||||
/// <param name="result">The result.</param>
|
/// <param name="result">The result.</param>
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
/// <returns>Task.</returns>
|
/// <returns>Task.</returns>
|
||||||
private async Task RefreshFromProvider(IHasImages item,
|
private async Task RefreshFromProvider(IHasImages item, LibraryOptions libraryOptions,
|
||||||
IRemoteImageProvider provider,
|
IRemoteImageProvider provider,
|
||||||
ImageRefreshOptions refreshOptions,
|
ImageRefreshOptions refreshOptions,
|
||||||
MetadataOptions savedOptions,
|
MetadataOptions savedOptions,
|
||||||
|
@ -293,7 +293,7 @@ namespace MediaBrowser.Providers.Manager
|
||||||
if (!HasImage(item, imageType) || (refreshOptions.IsReplacingImage(imageType) && !downloadedImages.Contains(imageType)))
|
if (!HasImage(item, imageType) || (refreshOptions.IsReplacingImage(imageType) && !downloadedImages.Contains(imageType)))
|
||||||
{
|
{
|
||||||
minWidth = savedOptions.GetMinWidth(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)
|
if (downloaded)
|
||||||
{
|
{
|
||||||
|
@ -305,7 +305,7 @@ namespace MediaBrowser.Providers.Manager
|
||||||
if (!item.LockedFields.Contains(MetadataFields.Backdrops))
|
if (!item.LockedFields.Contains(MetadataFields.Backdrops))
|
||||||
{
|
{
|
||||||
minWidth = savedOptions.GetMinWidth(ImageType.Backdrop);
|
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))
|
if (!item.LockedFields.Contains(MetadataFields.Screenshots))
|
||||||
|
@ -314,7 +314,7 @@ namespace MediaBrowser.Providers.Manager
|
||||||
if (hasScreenshots != null)
|
if (hasScreenshots != null)
|
||||||
{
|
{
|
||||||
minWidth = savedOptions.GetMinWidth(ImageType.Screenshot);
|
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;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<bool> DownloadImage(IHasImages item,
|
private async Task<bool> DownloadImage(IHasImages item, LibraryOptions libraryOptions,
|
||||||
IRemoteImageProvider provider,
|
IRemoteImageProvider provider,
|
||||||
RefreshResult result,
|
RefreshResult result,
|
||||||
IEnumerable<RemoteImageInfo> images,
|
IEnumerable<RemoteImageInfo> images,
|
||||||
|
@ -484,7 +484,7 @@ namespace MediaBrowser.Providers.Manager
|
||||||
.Where(i => i.Type == type && !(i.Width.HasValue && i.Width.Value < minWidth))
|
.Where(i => i.Type == type && !(i.Width.HasValue && i.Width.Value < minWidth))
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
if (EnableImageStub(item, type) && eligibleImages.Count > 0)
|
if (EnableImageStub(item, type, libraryOptions) && eligibleImages.Count > 0)
|
||||||
{
|
{
|
||||||
SaveImageStub(item, type, eligibleImages.Select(i => i.Url));
|
SaveImageStub(item, type, eligibleImages.Select(i => i.Url));
|
||||||
result.UpdateType = result.UpdateType | ItemUpdateType.ImageUpdate;
|
result.UpdateType = result.UpdateType | ItemUpdateType.ImageUpdate;
|
||||||
|
@ -518,14 +518,14 @@ namespace MediaBrowser.Providers.Manager
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool EnableImageStub(IHasImages item, ImageType type)
|
private bool EnableImageStub(IHasImages item, ImageType type, LibraryOptions libraryOptions)
|
||||||
{
|
{
|
||||||
if (item is LiveTvProgram)
|
if (item is LiveTvProgram)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_config.Configuration.DownloadImagesInAdvance)
|
if (libraryOptions.DownloadImagesInAdvance)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -585,7 +585,7 @@ namespace MediaBrowser.Providers.Manager
|
||||||
}, newIndex);
|
}, 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))
|
foreach (var image in images.Where(i => i.Type == imageType))
|
||||||
{
|
{
|
||||||
|
@ -601,7 +601,7 @@ namespace MediaBrowser.Providers.Manager
|
||||||
|
|
||||||
var url = image.Url;
|
var url = image.Url;
|
||||||
|
|
||||||
if (EnableImageStub(item, imageType))
|
if (EnableImageStub(item, imageType, libraryOptions))
|
||||||
{
|
{
|
||||||
SaveImageStub(item, imageType, new[] { url });
|
SaveImageStub(item, imageType, new[] { url });
|
||||||
result.UpdateType = result.UpdateType | ItemUpdateType.ImageUpdate;
|
result.UpdateType = result.UpdateType | ItemUpdateType.ImageUpdate;
|
||||||
|
|
|
@ -11,6 +11,7 @@ using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using CommonIO;
|
using CommonIO;
|
||||||
|
using MediaBrowser.Model.Configuration;
|
||||||
using MediaBrowser.Model.Providers;
|
using MediaBrowser.Model.Providers;
|
||||||
|
|
||||||
namespace MediaBrowser.Providers.Manager
|
namespace MediaBrowser.Providers.Manager
|
||||||
|
@ -120,6 +121,8 @@ namespace MediaBrowser.Providers.Manager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LibraryOptions libraryOptions = null;
|
||||||
|
|
||||||
// Next run remote image providers, but only if local image providers didn't throw an exception
|
// Next run remote image providers, but only if local image providers didn't throw an exception
|
||||||
if (!localImagesFailed && refreshOptions.ImageRefreshMode != ImageRefreshMode.ValidationOnly)
|
if (!localImagesFailed && refreshOptions.ImageRefreshMode != ImageRefreshMode.ValidationOnly)
|
||||||
{
|
{
|
||||||
|
@ -127,7 +130,12 @@ namespace MediaBrowser.Providers.Manager
|
||||||
|
|
||||||
if (providers.Count > 0)
|
if (providers.Count > 0)
|
||||||
{
|
{
|
||||||
var result = await itemImageProvider.RefreshImages(itemOfType, providers, refreshOptions, config, cancellationToken).ConfigureAwait(false);
|
if (libraryOptions == null)
|
||||||
|
{
|
||||||
|
libraryOptions = LibraryManager.GetLibraryOptions((BaseItem)item) ?? new LibraryOptions();
|
||||||
|
}
|
||||||
|
|
||||||
|
var result = await itemImageProvider.RefreshImages(itemOfType, libraryOptions, providers, refreshOptions, config, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
updateType = updateType | result.UpdateType;
|
updateType = updateType | result.UpdateType;
|
||||||
if (result.Failures == 0)
|
if (result.Failures == 0)
|
||||||
|
@ -180,8 +188,13 @@ namespace MediaBrowser.Providers.Manager
|
||||||
item.DateLastRefreshed = default(DateTime);
|
item.DateLastRefreshed = default(DateTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (libraryOptions == null)
|
||||||
|
{
|
||||||
|
libraryOptions = LibraryManager.GetLibraryOptions((BaseItem)item) ?? new LibraryOptions();
|
||||||
|
}
|
||||||
|
|
||||||
// Save to database
|
// Save to database
|
||||||
await SaveItem(metadataResult, updateType, cancellationToken).ConfigureAwait(false);
|
await SaveItem(metadataResult, libraryOptions, updateType, cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
await AfterMetadataRefresh(itemOfType, refreshOptions, cancellationToken).ConfigureAwait(false);
|
await AfterMetadataRefresh(itemOfType, refreshOptions, cancellationToken).ConfigureAwait(false);
|
||||||
|
@ -196,17 +209,19 @@ namespace MediaBrowser.Providers.Manager
|
||||||
lookupInfo.Year = result.ProductionYear;
|
lookupInfo.Year = result.ProductionYear;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async Task SaveItem(MetadataResult<TItemType> result, ItemUpdateType reason, CancellationToken cancellationToken)
|
protected async Task SaveItem(MetadataResult<TItemType> result, LibraryOptions libraryOptions, ItemUpdateType reason, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
if (result.Item.SupportsPeople && result.People != null)
|
if (result.Item.SupportsPeople && result.People != null)
|
||||||
{
|
{
|
||||||
await LibraryManager.UpdatePeople(result.Item as BaseItem, result.People.ToList());
|
var baseItem = result.Item as BaseItem;
|
||||||
await SavePeopleMetadata(result.People, cancellationToken).ConfigureAwait(false);
|
|
||||||
|
await LibraryManager.UpdatePeople(baseItem, result.People.ToList());
|
||||||
|
await SavePeopleMetadata(result.People, libraryOptions, cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
await result.Item.UpdateToRepository(reason, cancellationToken).ConfigureAwait(false);
|
await result.Item.UpdateToRepository(reason, cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task SavePeopleMetadata(List<PersonInfo> people, CancellationToken cancellationToken)
|
private async Task SavePeopleMetadata(List<PersonInfo> people, LibraryOptions libraryOptions, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
foreach (var person in people)
|
foreach (var person in people)
|
||||||
{
|
{
|
||||||
|
@ -229,7 +244,7 @@ namespace MediaBrowser.Providers.Manager
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(person.ImageUrl) && !personEntity.HasImage(ImageType.Primary))
|
if (!string.IsNullOrWhiteSpace(person.ImageUrl) && !personEntity.HasImage(ImageType.Primary))
|
||||||
{
|
{
|
||||||
await AddPersonImage(personEntity, person.ImageUrl, cancellationToken).ConfigureAwait(false);
|
await AddPersonImage(personEntity, libraryOptions, person.ImageUrl, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
saveEntity = true;
|
saveEntity = true;
|
||||||
updateType = updateType | ItemUpdateType.ImageUpdate;
|
updateType = updateType | ItemUpdateType.ImageUpdate;
|
||||||
|
@ -243,9 +258,9 @@ namespace MediaBrowser.Providers.Manager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task AddPersonImage(Person personEntity, string imageUrl, CancellationToken cancellationToken)
|
private async Task AddPersonImage(Person personEntity, LibraryOptions libraryOptions, string imageUrl, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
if (ServerConfigurationManager.Configuration.DownloadImagesInAdvance)
|
if (libraryOptions.DownloadImagesInAdvance)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
|
@ -345,6 +345,7 @@ namespace MediaBrowser.Server.Startup.Common
|
||||||
{
|
{
|
||||||
var name = entryPoint.GetType().FullName;
|
var name = entryPoint.GetType().FullName;
|
||||||
Logger.Info("Starting entry point {0}", name);
|
Logger.Info("Starting entry point {0}", name);
|
||||||
|
var now = DateTime.UtcNow;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
entryPoint.Run();
|
entryPoint.Run();
|
||||||
|
@ -353,7 +354,7 @@ namespace MediaBrowser.Server.Startup.Common
|
||||||
{
|
{
|
||||||
Logger.ErrorException("Error in {0}", ex, name);
|
Logger.ErrorException("Error in {0}", ex, name);
|
||||||
}
|
}
|
||||||
Logger.Info("Entry point completed: {0}", name);
|
Logger.Info("Entry point completed: {0}. Duration: {1} seconds", name, (DateTime.UtcNow - now).TotalSeconds.ToString(CultureInfo.InvariantCulture));
|
||||||
}
|
}
|
||||||
Logger.Info("All entry points have started");
|
Logger.Info("All entry points have started");
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user