mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-20 00:55:13 +01:00
support image stubbing
This commit is contained in:
@@ -8,6 +8,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Model.MediaInfo;
|
||||
|
||||
namespace MediaBrowser.Server.Implementations.Channels
|
||||
{
|
||||
@@ -35,24 +36,9 @@ namespace MediaBrowser.Server.Implementations.Channels
|
||||
|
||||
if (!string.IsNullOrEmpty(channelItem.ExternalImagePath))
|
||||
{
|
||||
var options = new HttpRequestOptions
|
||||
{
|
||||
CancellationToken = cancellationToken,
|
||||
Url = channelItem.ExternalImagePath
|
||||
};
|
||||
|
||||
var response = await _httpClient.GetResponse(options).ConfigureAwait(false);
|
||||
|
||||
if (response.ContentType.StartsWith("image/", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
imageResponse.HasImage = true;
|
||||
imageResponse.Stream = response.Content;
|
||||
imageResponse.SetFormatFromMimeType(response.ContentType);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Error("Provider did not return an image content type.");
|
||||
}
|
||||
imageResponse.Path = channelItem.ExternalImagePath;
|
||||
imageResponse.Protocol = MediaProtocol.Http;
|
||||
imageResponse.HasImage = true;
|
||||
}
|
||||
|
||||
return imageResponse;
|
||||
|
||||
@@ -1743,7 +1743,7 @@ namespace MediaBrowser.Server.Implementations.Dto
|
||||
{
|
||||
var imageInfo = item.GetImageInfo(ImageType.Primary, 0);
|
||||
|
||||
if (imageInfo == null)
|
||||
if (imageInfo == null || !imageInfo.IsLocalFile)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2354,5 +2354,17 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
|
||||
return ItemRepository.UpdatePeople(item.Id, people);
|
||||
}
|
||||
|
||||
private readonly SemaphoreSlim _dynamicImageResourcePool = new SemaphoreSlim(1,1);
|
||||
public async Task<ItemImageInfo> ConvertImageToLocal(IHasImages item, ItemImageInfo image, int imageIndex)
|
||||
{
|
||||
_logger.Debug("ConvertImageToLocal item {0}", item.Id);
|
||||
|
||||
await _providerManagerFactory().SaveImage(item, image.Path, _dynamicImageResourcePool, image.Type, imageIndex, CancellationToken.None).ConfigureAwait(false);
|
||||
|
||||
await item.UpdateToRepository(ItemUpdateType.ImageUpdate, CancellationToken.None).ConfigureAwait(false);
|
||||
|
||||
return item.GetImageInfo(image.Type, imageIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1446,7 +1446,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
||||
{
|
||||
dto.ChannelName = channel.Name;
|
||||
|
||||
if (!string.IsNullOrEmpty(channel.PrimaryImagePath))
|
||||
if (channel.HasImage(ImageType.Primary))
|
||||
{
|
||||
dto.ChannelPrimaryImageTag = _tvDtoService.GetImageTag(channel);
|
||||
}
|
||||
@@ -1512,7 +1512,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
||||
{
|
||||
dto.ChannelName = channel.Name;
|
||||
|
||||
if (!string.IsNullOrEmpty(channel.PrimaryImagePath))
|
||||
if (channel.HasImage(ImageType.Primary))
|
||||
{
|
||||
dto.ChannelPrimaryImageTag = _tvDtoService.GetImageTag(channel);
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Model.MediaInfo;
|
||||
|
||||
namespace MediaBrowser.Server.Implementations.LiveTv
|
||||
{
|
||||
@@ -40,24 +41,9 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
||||
{
|
||||
if (liveTvItem.ExternalImagePath.StartsWith("http", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var options = new HttpRequestOptions
|
||||
{
|
||||
CancellationToken = cancellationToken,
|
||||
Url = liveTvItem.ExternalImagePath
|
||||
};
|
||||
|
||||
var response = await _httpClient.GetResponse(options).ConfigureAwait(false);
|
||||
|
||||
if (response.ContentType.StartsWith("image/", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
imageResponse.HasImage = true;
|
||||
imageResponse.Stream = response.Content;
|
||||
imageResponse.SetFormatFromMimeType(response.ContentType);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Error("Provider did not return an image content type.");
|
||||
}
|
||||
imageResponse.Path = liveTvItem.ExternalImagePath;
|
||||
imageResponse.Protocol = MediaProtocol.Http;
|
||||
imageResponse.HasImage = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -125,7 +125,22 @@ namespace MediaBrowser.Server.Implementations.Photos
|
||||
protected virtual IEnumerable<string> GetStripCollageImagePaths(IHasImages primaryItem, IEnumerable<BaseItem> items)
|
||||
{
|
||||
return items
|
||||
.Select(i => i.GetImagePath(ImageType.Primary) ?? i.GetImagePath(ImageType.Thumb))
|
||||
.Select(i =>
|
||||
{
|
||||
var image = i.GetImageInfo(ImageType.Primary, 0);
|
||||
|
||||
if (image != null && image.IsLocalFile)
|
||||
{
|
||||
return image.Path;
|
||||
}
|
||||
image = i.GetImageInfo(ImageType.Thumb, 0);
|
||||
|
||||
if (image != null && image.IsLocalFile)
|
||||
{
|
||||
return image.Path;
|
||||
}
|
||||
return null;
|
||||
})
|
||||
.Where(i => !string.IsNullOrWhiteSpace(i));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user