From e57deb61ae1e0deef6b29f015fcfdbec382421e0 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 26 May 2013 10:51:48 -0400 Subject: [PATCH] fixes #313 - Corrupt TVDB source causing issue? --- .../Providers/TV/RemoteSeasonProvider.cs | 35 +++++++++++++------ 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/MediaBrowser.Controller/Providers/TV/RemoteSeasonProvider.cs b/MediaBrowser.Controller/Providers/TV/RemoteSeasonProvider.cs index 5e1f5f8dd9..00f81ec192 100644 --- a/MediaBrowser.Controller/Providers/TV/RemoteSeasonProvider.cs +++ b/MediaBrowser.Controller/Providers/TV/RemoteSeasonProvider.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Common.Extensions; +using System.Net; +using MediaBrowser.Common.Extensions; using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.TV; @@ -10,6 +11,7 @@ using System.IO; using System.Threading; using System.Threading.Tasks; using System.Xml; +using MediaBrowser.Model.Net; namespace MediaBrowser.Controller.Providers.TV { @@ -244,15 +246,28 @@ namespace MediaBrowser.Controller.Providers.TV n = n.SelectSingleNode("./BannerPath"); if (n != null) { - var bannerImagePath = - await _providerManager.DownloadAndSaveImage(season, - TVUtils.BannerUrl + n.InnerText, - "banner" + - Path.GetExtension(n.InnerText), - ConfigurationManager.Configuration.SaveLocalMeta, RemoteSeriesProvider.Current.TvDbResourcePool, cancellationToken). - ConfigureAwait(false); - - season.SetImage(ImageType.Banner, bannerImagePath); + try + { + var bannerImagePath = + await _providerManager.DownloadAndSaveImage(season, + TVUtils.BannerUrl + n.InnerText, + "banner" + + Path.GetExtension(n.InnerText), + ConfigurationManager.Configuration.SaveLocalMeta, RemoteSeriesProvider.Current.TvDbResourcePool, cancellationToken). + ConfigureAwait(false); + + season.SetImage(ImageType.Banner, bannerImagePath); + } + catch (HttpException ex) + { + Logger.ErrorException("Error downloading season banner for {0}", ex, season.Path); + + // Sometimes banners will come up not found even though they're reported in tvdb xml + if (ex.StatusCode.HasValue && ex.StatusCode.Value != HttpStatusCode.NotFound) + { + throw; + } + } } } }