support image stubbing

This commit is contained in:
Luke Pulverenti
2015-10-16 13:06:31 -04:00
parent 3741eb2426
commit d577e1c7b0
21 changed files with 196 additions and 107 deletions

View File

@@ -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);
}

View File

@@ -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
{