Add fallback for image downloads with bad MediaType

This commit is contained in:
Joe Rogers 2022-03-29 21:42:54 +02:00
parent 5376c37d42
commit ca16a55a47
No known key found for this signature in database
GPG Key ID: 0074AD57B8FDBBB4

View File

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