浏览代码

fixes #313 - Corrupt TVDB source causing issue?

Luke Pulverenti 12 年之前
父节点
当前提交
e57deb61ae
共有 1 个文件被更改,包括 25 次插入10 次删除
  1. 25 10
      MediaBrowser.Controller/Providers/TV/RemoteSeasonProvider.cs

+ 25 - 10
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;
+                            }
+                        }
                     }
                 }
             }