Extension lookup tv icons

This commit is contained in:
Max 2024-11-19 15:43:22 -05:00
parent d1d5ea9c80
commit 96cf13060d

View File

@ -200,11 +200,25 @@ namespace MediaBrowser.Providers.Manager
// TODO: Isolate this hack into the tvh plugin
if (string.IsNullOrEmpty(contentType))
{
// First, check for imagecache special case
if (url.Contains("/imagecache/", StringComparison.OrdinalIgnoreCase))
{
contentType = MediaTypeNames.Image.Png;
contentType = "image/png";
return;
}
else
// Deduce content type from file extension
var fileExtension = Path.GetExtension(url)?.ToLowerInvariant();
contentType = fileExtension switch
{
".jpg" or ".jpeg" => "image/jpeg",
".png" => "image/png",
".gif" => "image/gif",
".webp" => "image/webp",
_ => null
};
if (string.IsNullOrEmpty(contentType))
{
throw new HttpRequestException("Invalid image received: contentType not set.", null, response.StatusCode);
}