Merge pull request #6593 from Bond-009/ex

This commit is contained in:
Claus Vium 2021-09-22 09:21:41 +02:00 committed by GitHub
commit 1ebd3c9ac3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -486,7 +486,20 @@ namespace MediaBrowser.Providers.Manager
try
{
using var response = await provider.GetImageResponse(url, cancellationToken).ConfigureAwait(false);
response.EnsureSuccessStatusCode();
// Sometimes providers send back bad urls. Just move to the next image
if (response.StatusCode == HttpStatusCode.NotFound || response.StatusCode == HttpStatusCode.Forbidden)
{
_logger.LogDebug("{Url} returned {StatusCode}, ignoring", url, response.StatusCode);
continue;
}
if (!response.IsSuccessStatusCode)
{
_logger.LogWarning("{Url} returned {StatusCode}, skipping all remaining requests", url, response.StatusCode);
break;
}
await using var stream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
await _providerManager.SaveImage(
@ -500,15 +513,8 @@ namespace MediaBrowser.Providers.Manager
result.UpdateType |= ItemUpdateType.ImageUpdate;
return true;
}
catch (HttpRequestException ex)
catch (HttpRequestException)
{
// Sometimes providers send back bad url's. Just move to the next image
if (ex.StatusCode.HasValue
&& (ex.StatusCode.Value == HttpStatusCode.NotFound || ex.StatusCode.Value == HttpStatusCode.Forbidden))
{
continue;
}
break;
}
}
@ -588,6 +594,19 @@ namespace MediaBrowser.Providers.Manager
{
using var response = await provider.GetImageResponse(url, cancellationToken).ConfigureAwait(false);
// Sometimes providers send back bad urls. Just move to the next image
if (response.StatusCode == HttpStatusCode.NotFound || response.StatusCode == HttpStatusCode.Forbidden)
{
_logger.LogDebug("{Url} returned {StatusCode}, ignoring", url, response.StatusCode);
continue;
}
if (!response.IsSuccessStatusCode)
{
_logger.LogWarning("{Url} returned {StatusCode}, skipping all remaining requests", url, response.StatusCode);
break;
}
// If there's already an image of the same size, skip it
if (response.Content.Headers.ContentLength.HasValue)
{
@ -615,15 +634,8 @@ namespace MediaBrowser.Providers.Manager
cancellationToken).ConfigureAwait(false);
result.UpdateType = result.UpdateType | ItemUpdateType.ImageUpdate;
}
catch (HttpRequestException ex)
catch (HttpRequestException)
{
// Sometimes providers send back bad urls. Just move onto the next image
if (ex.StatusCode.HasValue
&& (ex.StatusCode.Value == HttpStatusCode.NotFound || ex.StatusCode.Value == HttpStatusCode.Forbidden))
{
continue;
}
break;
}
}