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

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