mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
Merge pull request #3196 from ferferga/images-advance
Remove "download images in advance" option
This commit is contained in:
commit
cdf979efef
@ -23,7 +23,8 @@ namespace Jellyfin.Server.Migrations
|
|||||||
typeof(Routines.AddDefaultPluginRepository),
|
typeof(Routines.AddDefaultPluginRepository),
|
||||||
typeof(Routines.MigrateUserDb),
|
typeof(Routines.MigrateUserDb),
|
||||||
typeof(Routines.ReaddDefaultPluginRepository),
|
typeof(Routines.ReaddDefaultPluginRepository),
|
||||||
typeof(Routines.MigrateDisplayPreferencesDb)
|
typeof(Routines.MigrateDisplayPreferencesDb),
|
||||||
|
typeof(Routines.RemoveDownloadImagesInAdvance)
|
||||||
};
|
};
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -0,0 +1,46 @@
|
|||||||
|
using System;
|
||||||
|
using MediaBrowser.Controller.Entities;
|
||||||
|
using MediaBrowser.Controller.Library;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace Jellyfin.Server.Migrations.Routines
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Removes the old 'RemoveDownloadImagesInAdvance' from library options.
|
||||||
|
/// </summary>
|
||||||
|
internal class RemoveDownloadImagesInAdvance : IMigrationRoutine
|
||||||
|
{
|
||||||
|
private readonly ILogger<RemoveDownloadImagesInAdvance> _logger;
|
||||||
|
private readonly ILibraryManager _libraryManager;
|
||||||
|
|
||||||
|
public RemoveDownloadImagesInAdvance(ILogger<RemoveDownloadImagesInAdvance> logger, ILibraryManager libraryManager)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_libraryManager = libraryManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public Guid Id => Guid.Parse("{A81F75E0-8F43-416F-A5E8-516CCAB4D8CC}");
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public string Name => "RemoveDownloadImagesInAdvance";
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public bool PerformOnNewInstall => false;
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public void Perform()
|
||||||
|
{
|
||||||
|
var virtualFolders = _libraryManager.GetVirtualFolders(false);
|
||||||
|
_logger.LogInformation("Removing 'RemoveDownloadImagesInAdvance' settings in all the libraries");
|
||||||
|
foreach (var virtualFolder in virtualFolders)
|
||||||
|
{
|
||||||
|
var libraryOptions = virtualFolder.LibraryOptions;
|
||||||
|
var collectionFolder = (CollectionFolder)_libraryManager.GetItemById(virtualFolder.ItemId);
|
||||||
|
// The property no longer exists in LibraryOptions, so we just re-save the options to get old data removed.
|
||||||
|
collectionFolder.UpdateLibraryOptions(libraryOptions);
|
||||||
|
_logger.LogInformation("Removed from '{VirtualFolder}'", virtualFolder.Name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -17,8 +17,6 @@ namespace MediaBrowser.Model.Configuration
|
|||||||
|
|
||||||
public bool ExtractChapterImagesDuringLibraryScan { get; set; }
|
public bool ExtractChapterImagesDuringLibraryScan { get; set; }
|
||||||
|
|
||||||
public bool DownloadImagesInAdvance { get; set; }
|
|
||||||
|
|
||||||
public MediaPathInfo[] PathInfos { get; set; }
|
public MediaPathInfo[] PathInfos { get; set; }
|
||||||
|
|
||||||
public bool SaveLocalMetadata { get; set; }
|
public bool SaveLocalMetadata { get; set; }
|
||||||
|
@ -517,13 +517,8 @@ namespace MediaBrowser.Providers.Manager
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// We always want to use prefetched images
|
||||||
if (libraryOptions.DownloadImagesInAdvance)
|
return false;
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SaveImageStub(BaseItem item, ImageType imageType, IEnumerable<string> urls)
|
private void SaveImageStub(BaseItem item, ImageType imageType, IEnumerable<string> urls)
|
||||||
|
@ -252,7 +252,13 @@ namespace MediaBrowser.Providers.Manager
|
|||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(person.ImageUrl) && !personEntity.HasImage(ImageType.Primary))
|
if (!string.IsNullOrWhiteSpace(person.ImageUrl) && !personEntity.HasImage(ImageType.Primary))
|
||||||
{
|
{
|
||||||
await AddPersonImageAsync(personEntity, libraryOptions, person.ImageUrl, cancellationToken).ConfigureAwait(false);
|
personEntity.SetImage(
|
||||||
|
new ItemImageInfo
|
||||||
|
{
|
||||||
|
Path = person.ImageUrl,
|
||||||
|
Type = ImageType.Primary
|
||||||
|
},
|
||||||
|
0);
|
||||||
|
|
||||||
saveEntity = true;
|
saveEntity = true;
|
||||||
updateType |= ItemUpdateType.ImageUpdate;
|
updateType |= ItemUpdateType.ImageUpdate;
|
||||||
@ -266,30 +272,6 @@ namespace MediaBrowser.Providers.Manager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task AddPersonImageAsync(Person personEntity, LibraryOptions libraryOptions, string imageUrl, CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
if (libraryOptions.DownloadImagesInAdvance)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
await ProviderManager.SaveImage(personEntity, imageUrl, ImageType.Primary, null, cancellationToken).ConfigureAwait(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Logger.LogError(ex, "Error in AddPersonImage");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
personEntity.SetImage(
|
|
||||||
new ItemImageInfo
|
|
||||||
{
|
|
||||||
Path = imageUrl,
|
|
||||||
Type = ImageType.Primary
|
|
||||||
},
|
|
||||||
0);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected virtual Task AfterMetadataRefresh(TItemType item, MetadataRefreshOptions refreshOptions, CancellationToken cancellationToken)
|
protected virtual Task AfterMetadataRefresh(TItemType item, MetadataRefreshOptions refreshOptions, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
item.AfterMetadataRefresh();
|
item.AfterMetadataRefresh();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user