From ca16a55a476f0a2a20ed0c3cf497a1b1f32c6b42 Mon Sep 17 00:00:00 2001 From: Joe Rogers <1337joe@gmail.com> Date: Tue, 29 Mar 2022 21:42:54 +0200 Subject: [PATCH] Add fallback for image downloads with bad MediaType --- MediaBrowser.Providers/Manager/ProviderManager.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/MediaBrowser.Providers/Manager/ProviderManager.cs b/MediaBrowser.Providers/Manager/ProviderManager.cs index 0c31d460f..01ff473f0 100644 --- a/MediaBrowser.Providers/Manager/ProviderManager.cs +++ b/MediaBrowser.Providers/Manager/ProviderManager.cs @@ -30,6 +30,7 @@ using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Entities; using MediaBrowser.Model.Extensions; using MediaBrowser.Model.IO; +using MediaBrowser.Model.Net; using MediaBrowser.Model.Providers; using Microsoft.Extensions.Logging; using Priority_Queue; @@ -188,6 +189,12 @@ namespace MediaBrowser.Providers.Manager throw new HttpRequestException("Invalid image received.", null, HttpStatusCode.NotFound); } + // some iptv/epg providers don't correctly report media type, extract from url if no extension found + if (string.IsNullOrWhiteSpace(MimeTypes.ToExtension(contentType))) + { + contentType = MimeTypes.GetMimeType(url); + } + await using var stream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false); await SaveImage( item,