mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-03-20 17:16:42 +00:00
update dynamic images
This commit is contained in:
@@ -37,7 +37,6 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
||||
public class LiveTvManager : ILiveTvManager, IDisposable
|
||||
{
|
||||
private readonly IServerConfigurationManager _config;
|
||||
private readonly IFileSystem _fileSystem;
|
||||
private readonly ILogger _logger;
|
||||
private readonly IItemRepository _itemRepo;
|
||||
private readonly IUserManager _userManager;
|
||||
@@ -63,10 +62,9 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
||||
|
||||
private readonly SemaphoreSlim _refreshSemaphore = new SemaphoreSlim(1, 1);
|
||||
|
||||
public LiveTvManager(IApplicationHost appHost, IServerConfigurationManager config, IFileSystem fileSystem, ILogger logger, IItemRepository itemRepo, IImageProcessor imageProcessor, IUserDataManager userDataManager, IDtoService dtoService, IUserManager userManager, ILibraryManager libraryManager, ITaskManager taskManager, ILocalizationManager localization, IJsonSerializer jsonSerializer, IProviderManager providerManager)
|
||||
public LiveTvManager(IApplicationHost appHost, IServerConfigurationManager config, ILogger logger, IItemRepository itemRepo, IImageProcessor imageProcessor, IUserDataManager userDataManager, IDtoService dtoService, IUserManager userManager, ILibraryManager libraryManager, ITaskManager taskManager, ILocalizationManager localization, IJsonSerializer jsonSerializer, IProviderManager providerManager)
|
||||
{
|
||||
_config = config;
|
||||
_fileSystem = fileSystem;
|
||||
_logger = logger;
|
||||
_itemRepo = itemRepo;
|
||||
_userManager = userManager;
|
||||
@@ -474,11 +472,11 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
||||
return item;
|
||||
}
|
||||
|
||||
private LiveTvProgram GetProgram(ProgramInfo info, ChannelType channelType, string serviceName, CancellationToken cancellationToken)
|
||||
private async Task<LiveTvProgram> GetProgram(ProgramInfo info, ChannelType channelType, string serviceName, CancellationToken cancellationToken)
|
||||
{
|
||||
var id = _tvDtoService.GetInternalProgramId(serviceName, info.Id);
|
||||
|
||||
var item = _itemRepo.RetrieveItem(id) as LiveTvProgram;
|
||||
var item = _libraryManager.GetItemById(id) as LiveTvProgram;
|
||||
|
||||
if (item == null)
|
||||
{
|
||||
@@ -521,6 +519,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
||||
item.StartDate = info.StartDate;
|
||||
item.ProductionYear = info.ProductionYear;
|
||||
|
||||
await item.UpdateToRepository(ItemUpdateType.MetadataImport, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
@@ -992,9 +992,10 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
||||
|
||||
var channelPrograms = await service.GetProgramsAsync(currentChannel.ExternalId, start, end, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
var programEntities = channelPrograms.Select(program => GetProgram(program, currentChannel.ChannelType, service.Name, cancellationToken));
|
||||
|
||||
programs.AddRange(programEntities);
|
||||
foreach (var program in channelPrograms)
|
||||
{
|
||||
programs.Add(await GetProgram(program, currentChannel.ChannelType, service.Name, cancellationToken).ConfigureAwait(false));
|
||||
}
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace MediaBrowser.Server.Implementations.Photos
|
||||
protected async Task<ItemUpdateType> FetchAsync(IHasImages item, ImageType imageType, MetadataRefreshOptions options, CancellationToken cancellationToken)
|
||||
{
|
||||
var items = await GetItemsWithImages(item).ConfigureAwait(false);
|
||||
var cacheKey = GetConfigurationCacheKey(items);
|
||||
var cacheKey = GetConfigurationCacheKey(items, item.Name);
|
||||
|
||||
if (!HasChanged(item, imageType, cacheKey))
|
||||
{
|
||||
@@ -110,7 +110,7 @@ namespace MediaBrowser.Server.Implementations.Photos
|
||||
public async Task<DynamicImageResponse> GetImage(IHasImages item, ImageType type, CancellationToken cancellationToken)
|
||||
{
|
||||
var items = await GetItemsWithImages(item).ConfigureAwait(false);
|
||||
var cacheKey = GetConfigurationCacheKey(items);
|
||||
var cacheKey = GetConfigurationCacheKey(items, item.Name);
|
||||
|
||||
var result = await CreateImageAsync(item, items, type, 0).ConfigureAwait(false);
|
||||
|
||||
@@ -126,9 +126,9 @@ namespace MediaBrowser.Server.Implementations.Photos
|
||||
protected abstract Task<List<BaseItem>> GetItemsWithImages(IHasImages item);
|
||||
|
||||
private const string Version = "3";
|
||||
protected string GetConfigurationCacheKey(List<BaseItem> items)
|
||||
protected string GetConfigurationCacheKey(List<BaseItem> items, string itemName)
|
||||
{
|
||||
return (Version + "_" + string.Join(",", items.Select(i => i.Id.ToString("N")).ToArray())).GetMD5().ToString("N");
|
||||
return (Version + "_" + (itemName ?? string.Empty) + "_" + string.Join(",", items.Select(i => i.Id.ToString("N")).ToArray())).GetMD5().ToString("N");
|
||||
}
|
||||
|
||||
protected Task<Stream> GetThumbCollage(List<BaseItem> items)
|
||||
@@ -185,7 +185,7 @@ namespace MediaBrowser.Server.Implementations.Photos
|
||||
}
|
||||
|
||||
var items = GetItemsWithImages(item).Result;
|
||||
var cacheKey = GetConfigurationCacheKey(items);
|
||||
var cacheKey = GetConfigurationCacheKey(items, item.Name);
|
||||
|
||||
return HasChanged(item, ImageType.Primary, cacheKey) || HasChanged(item, ImageType.Thumb, cacheKey);
|
||||
}
|
||||
|
||||
@@ -227,7 +227,9 @@ namespace MediaBrowser.Server.Implementations.UserViews
|
||||
CollectionType.BoxSets,
|
||||
CollectionType.Playlists,
|
||||
CollectionType.Channels,
|
||||
CollectionType.LiveTv
|
||||
CollectionType.LiveTv,
|
||||
CollectionType.Books,
|
||||
CollectionType.Photos
|
||||
};
|
||||
|
||||
return collectionStripViewTypes.Contains(view.ViewType ?? string.Empty);
|
||||
@@ -235,6 +237,11 @@ namespace MediaBrowser.Server.Implementations.UserViews
|
||||
|
||||
protected override Task<Stream> CreateImageAsync(IHasImages item, List<BaseItem> itemsWithImages, ImageType imageType, int imageIndex)
|
||||
{
|
||||
if (itemsWithImages.Count == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var view = (UserView)item;
|
||||
if (imageType == ImageType.Primary && IsUsingCollectionStrip(view))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user