Merge pull request #13076 from theguymadmax/tv-icon-image-fix
Some checks failed
Merge Conflict Labeler / Labeling (push) Has been cancelled
CodeQL / Analyze (csharp) (push) Has been cancelled
OpenAPI / OpenAPI - HEAD (push) Has been cancelled
OpenAPI / OpenAPI - BASE (push) Has been cancelled
Tests / run-tests (macos-latest) (push) Has been cancelled
Tests / run-tests (ubuntu-latest) (push) Has been cancelled
Tests / run-tests (windows-latest) (push) Has been cancelled
Project Automation / Project board (push) Has been cancelled
OpenAPI / OpenAPI - Difference (push) Has been cancelled
OpenAPI / OpenAPI - Publish Unstable Spec (push) Has been cancelled
OpenAPI / OpenAPI - Publish Stable Spec (push) Has been cancelled

Determine tv image type by extension if content-type is unavailable
This commit is contained in:
Bond-009 2024-12-08 12:17:36 +01:00 committed by GitHub
commit 6691380c04
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -200,11 +200,19 @@ namespace MediaBrowser.Providers.Manager
// TODO: Isolate this hack into the tvh plugin
if (string.IsNullOrEmpty(contentType))
{
// Special case for imagecache
if (url.Contains("/imagecache/", StringComparison.OrdinalIgnoreCase))
{
contentType = MediaTypeNames.Image.Png;
}
else
{
// Deduce content type from file extension
contentType = MimeTypes.GetMimeType(new Uri(url).GetLeftPart(UriPartial.Path));
}
// Throw if we still can't determine the content type
if (string.IsNullOrEmpty(contentType))
{
throw new HttpRequestException("Invalid image received: contentType not set.", null, response.StatusCode);
}