diff --git a/MediaBrowser.Providers/ImageFromMediaLocationProvider.cs b/MediaBrowser.Providers/ImageFromMediaLocationProvider.cs
index 65eee0f3a6..f278a90893 100644
--- a/MediaBrowser.Providers/ImageFromMediaLocationProvider.cs
+++ b/MediaBrowser.Providers/ImageFromMediaLocationProvider.cs
@@ -101,8 +101,6 @@ namespace MediaBrowser.Providers
{
cancellationToken.ThrowIfCancellationRequested();
- var args = GetResolveArgsContainingImages(item);
-
// Make sure current image paths still exist
item.ValidateImages();
@@ -114,6 +112,8 @@ namespace MediaBrowser.Providers
cancellationToken.ThrowIfCancellationRequested();
+ var args = GetResolveArgsContainingImages(item);
+
PopulateBaseItemImages(item, args);
SetLastRefreshed(item, DateTime.UtcNow);
diff --git a/MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs b/MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs
index f61057fe6c..683dd42310 100644
--- a/MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs
+++ b/MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs
@@ -123,6 +123,8 @@ namespace MediaBrowser.Providers.MediaInfo
/// Task{System.Boolean}.
public override async Task FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
{
+ item.ValidateImages();
+
var audio = (Audio)item;
if (string.IsNullOrEmpty(audio.PrimaryImagePath) && audio.MediaStreams.Any(s => s.Type == MediaStreamType.Video))
diff --git a/MediaBrowser.Providers/MediaInfo/VideoImageProvider.cs b/MediaBrowser.Providers/MediaInfo/VideoImageProvider.cs
index 7aea484fd8..b577420428 100644
--- a/MediaBrowser.Providers/MediaInfo/VideoImageProvider.cs
+++ b/MediaBrowser.Providers/MediaInfo/VideoImageProvider.cs
@@ -173,6 +173,8 @@ namespace MediaBrowser.Providers.MediaInfo
/// Task{System.Boolean}.
public override async Task FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
{
+ item.ValidateImages();
+
var video = (Video)item;
// Double check this here in case force was used
diff --git a/MediaBrowser.Providers/Movies/FanArtMovieProvider.cs b/MediaBrowser.Providers/Movies/FanArtMovieProvider.cs
index 39908c3eef..be195d6d2e 100644
--- a/MediaBrowser.Providers/Movies/FanArtMovieProvider.cs
+++ b/MediaBrowser.Providers/Movies/FanArtMovieProvider.cs
@@ -15,6 +15,8 @@ using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
+using MediaBrowser.Model.Net;
+using System.Net;
namespace MediaBrowser.Providers.Movies
{
@@ -253,72 +255,42 @@ namespace MediaBrowser.Providers.Movies
if (ConfigurationManager.Configuration.DownloadMovieImages.Primary && !item.HasImage(ImageType.Primary))
{
- var image = images.FirstOrDefault(i => i.Type == ImageType.Primary);
-
- if (image != null)
- {
- await _providerManager.SaveImage(item, image.Url, FanArtResourcePool, ImageType.Primary, null, cancellationToken).ConfigureAwait(false);
- }
+ await SaveImage(item, images, ImageType.Primary, cancellationToken).ConfigureAwait(false);
}
cancellationToken.ThrowIfCancellationRequested();
if (ConfigurationManager.Configuration.DownloadMovieImages.Logo && !item.HasImage(ImageType.Logo))
{
- var image = images.FirstOrDefault(i => i.Type == ImageType.Logo);
-
- if (image != null)
- {
- await _providerManager.SaveImage(item, image.Url, FanArtResourcePool, ImageType.Logo, null, cancellationToken).ConfigureAwait(false);
- }
+ await SaveImage(item, images, ImageType.Logo, cancellationToken).ConfigureAwait(false);
}
cancellationToken.ThrowIfCancellationRequested();
if (ConfigurationManager.Configuration.DownloadMovieImages.Art && !item.HasImage(ImageType.Art))
{
- var image = images.FirstOrDefault(i => i.Type == ImageType.Art);
-
- if (image != null)
- {
- await _providerManager.SaveImage(item, image.Url, FanArtResourcePool, ImageType.Art, null, cancellationToken).ConfigureAwait(false);
- }
+ await SaveImage(item, images, ImageType.Art, cancellationToken).ConfigureAwait(false);
}
cancellationToken.ThrowIfCancellationRequested();
if (ConfigurationManager.Configuration.DownloadMovieImages.Disc && !item.HasImage(ImageType.Disc))
{
- var image = images.FirstOrDefault(i => i.Type == ImageType.Disc);
-
- if (image != null)
- {
- await _providerManager.SaveImage(item, image.Url, FanArtResourcePool, ImageType.Disc, null, cancellationToken).ConfigureAwait(false);
- }
+ await SaveImage(item, images, ImageType.Disc, cancellationToken).ConfigureAwait(false);
}
cancellationToken.ThrowIfCancellationRequested();
if (ConfigurationManager.Configuration.DownloadMovieImages.Banner && !item.HasImage(ImageType.Banner))
{
- var image = images.FirstOrDefault(i => i.Type == ImageType.Banner);
-
- if (image != null)
- {
- await _providerManager.SaveImage(item, image.Url, FanArtResourcePool, ImageType.Banner, null, cancellationToken).ConfigureAwait(false);
- }
+ await SaveImage(item, images, ImageType.Banner, cancellationToken).ConfigureAwait(false);
}
cancellationToken.ThrowIfCancellationRequested();
if (ConfigurationManager.Configuration.DownloadMovieImages.Thumb && !item.HasImage(ImageType.Thumb))
{
- var image = images.FirstOrDefault(i => i.Type == ImageType.Thumb);
-
- if (image != null)
- {
- await _providerManager.SaveImage(item, image.Url, FanArtResourcePool, ImageType.Thumb, null, cancellationToken).ConfigureAwait(false);
- }
+ await SaveImage(item, images, ImageType.Thumb, cancellationToken).ConfigureAwait(false);
}
cancellationToken.ThrowIfCancellationRequested();
@@ -336,5 +308,25 @@ namespace MediaBrowser.Providers.Movies
}
}
}
+
+ private async Task SaveImage(BaseItem item, List images, ImageType type, CancellationToken cancellationToken)
+ {
+ foreach (var image in images.Where(i => i.Type == type))
+ {
+ try
+ {
+ await _providerManager.SaveImage(item, image.Url, FanArtResourcePool, type, null, cancellationToken).ConfigureAwait(false);
+ break;
+ }
+ catch (HttpException ex)
+ {
+ // Sometimes fanart has bad url's in their xml
+ if (ex.StatusCode.HasValue && ex.StatusCode.Value == HttpStatusCode.NotFound)
+ {
+ continue;
+ }
+ }
+ }
+ }
}
}
diff --git a/MediaBrowser.Providers/Music/FanArtAlbumProvider.cs b/MediaBrowser.Providers/Music/FanArtAlbumProvider.cs
index f67e2b5091..a49de9a29e 100644
--- a/MediaBrowser.Providers/Music/FanArtAlbumProvider.cs
+++ b/MediaBrowser.Providers/Music/FanArtAlbumProvider.cs
@@ -14,6 +14,8 @@ using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
+using MediaBrowser.Model.Net;
+using System.Net;
namespace MediaBrowser.Providers.Music
{
@@ -174,23 +176,33 @@ namespace MediaBrowser.Providers.Music
if (ConfigurationManager.Configuration.DownloadMusicAlbumImages.Primary && !item.HasImage(ImageType.Primary))
{
- var image = images.FirstOrDefault(i => i.Type == ImageType.Primary);
-
- if (image != null)
- {
- await _providerManager.SaveImage(item, image.Url, FanArtResourcePool, ImageType.Primary, null, cancellationToken).ConfigureAwait(false);
- }
+ await SaveImage(item, images, ImageType.Primary, cancellationToken).ConfigureAwait(false);
}
cancellationToken.ThrowIfCancellationRequested();
if (ConfigurationManager.Configuration.DownloadMusicAlbumImages.Disc && !item.HasImage(ImageType.Disc))
{
- var image = images.FirstOrDefault(i => i.Type == ImageType.Disc);
+ await SaveImage(item, images, ImageType.Disc, cancellationToken).ConfigureAwait(false);
+ }
+ }
- if (image != null)
+ private async Task SaveImage(BaseItem item, List images, ImageType type, CancellationToken cancellationToken)
+ {
+ foreach (var image in images.Where(i => i.Type == type))
+ {
+ try
+ {
+ await _providerManager.SaveImage(item, image.Url, FanArtResourcePool, type, null, cancellationToken).ConfigureAwait(false);
+ break;
+ }
+ catch (HttpException ex)
{
- await _providerManager.SaveImage(item, image.Url, FanArtResourcePool, ImageType.Disc, null, cancellationToken).ConfigureAwait(false);
+ // Sometimes fanart has bad url's in their xml
+ if (ex.StatusCode.HasValue && ex.StatusCode.Value == HttpStatusCode.NotFound)
+ {
+ continue;
+ }
}
}
}
diff --git a/MediaBrowser.Providers/Music/FanArtArtistProvider.cs b/MediaBrowser.Providers/Music/FanArtArtistProvider.cs
index 6df21b61d9..1b0a80d9a9 100644
--- a/MediaBrowser.Providers/Music/FanArtArtistProvider.cs
+++ b/MediaBrowser.Providers/Music/FanArtArtistProvider.cs
@@ -16,6 +16,8 @@ using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
+using MediaBrowser.Model.Net;
+using System.Net;
namespace MediaBrowser.Providers.Music
{
@@ -270,48 +272,28 @@ namespace MediaBrowser.Providers.Music
if (ConfigurationManager.Configuration.DownloadMusicArtistImages.Primary && !item.HasImage(ImageType.Primary))
{
- var image = images.FirstOrDefault(i => i.Type == ImageType.Primary);
-
- if (image != null)
- {
- await _providerManager.SaveImage(item, image.Url, FanArtResourcePool, ImageType.Primary, null, cancellationToken).ConfigureAwait(false);
- }
+ await SaveImage(item, images, ImageType.Primary, cancellationToken).ConfigureAwait(false);
}
cancellationToken.ThrowIfCancellationRequested();
if (ConfigurationManager.Configuration.DownloadMusicArtistImages.Logo && !item.HasImage(ImageType.Logo))
{
- var image = images.FirstOrDefault(i => i.Type == ImageType.Logo);
-
- if (image != null)
- {
- await _providerManager.SaveImage(item, image.Url, FanArtResourcePool, ImageType.Logo, null, cancellationToken).ConfigureAwait(false);
- }
+ await SaveImage(item, images, ImageType.Logo, cancellationToken).ConfigureAwait(false);
}
cancellationToken.ThrowIfCancellationRequested();
if (ConfigurationManager.Configuration.DownloadMusicArtistImages.Art && !item.HasImage(ImageType.Art))
{
- var image = images.FirstOrDefault(i => i.Type == ImageType.Art);
-
- if (image != null)
- {
- await _providerManager.SaveImage(item, image.Url, FanArtResourcePool, ImageType.Art, null, cancellationToken).ConfigureAwait(false);
- }
+ await SaveImage(item, images, ImageType.Art, cancellationToken).ConfigureAwait(false);
}
cancellationToken.ThrowIfCancellationRequested();
if (ConfigurationManager.Configuration.DownloadMusicArtistImages.Banner && !item.HasImage(ImageType.Banner))
{
- var image = images.FirstOrDefault(i => i.Type == ImageType.Banner);
-
- if (image != null)
- {
- await _providerManager.SaveImage(item, image.Url, FanArtResourcePool, ImageType.Banner, null, cancellationToken).ConfigureAwait(false);
- }
+ await SaveImage(item, images, ImageType.Banner, cancellationToken).ConfigureAwait(false);
}
cancellationToken.ThrowIfCancellationRequested();
@@ -329,5 +311,25 @@ namespace MediaBrowser.Providers.Music
}
}
}
+
+ private async Task SaveImage(BaseItem item, List images, ImageType type, CancellationToken cancellationToken)
+ {
+ foreach (var image in images.Where(i => i.Type == type))
+ {
+ try
+ {
+ await _providerManager.SaveImage(item, image.Url, FanArtResourcePool, type, null, cancellationToken).ConfigureAwait(false);
+ break;
+ }
+ catch (HttpException ex)
+ {
+ // Sometimes fanart has bad url's in their xml
+ if (ex.StatusCode.HasValue && ex.StatusCode.Value == HttpStatusCode.NotFound)
+ {
+ continue;
+ }
+ }
+ }
+ }
}
}
diff --git a/MediaBrowser.Providers/TV/FanArtSeasonProvider.cs b/MediaBrowser.Providers/TV/FanArtSeasonProvider.cs
index 2a5b16bef4..bf52ca349c 100644
--- a/MediaBrowser.Providers/TV/FanArtSeasonProvider.cs
+++ b/MediaBrowser.Providers/TV/FanArtSeasonProvider.cs
@@ -13,6 +13,8 @@ using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
+using MediaBrowser.Model.Net;
+using System.Net;
namespace MediaBrowser.Providers.TV
{
@@ -121,11 +123,26 @@ namespace MediaBrowser.Providers.TV
{
if (ConfigurationManager.Configuration.DownloadSeasonImages.Thumb && !season.HasImage(ImageType.Thumb))
{
- var image = images.FirstOrDefault(i => i.Type == ImageType.Thumb);
+ await SaveImage(season, images, ImageType.Thumb, cancellationToken).ConfigureAwait(false);
+ }
+ }
- if (image != null)
+ private async Task SaveImage(BaseItem item, List images, ImageType type, CancellationToken cancellationToken)
+ {
+ foreach (var image in images.Where(i => i.Type == type))
+ {
+ try
+ {
+ await _providerManager.SaveImage(item, image.Url, FanArtResourcePool, type, null, cancellationToken).ConfigureAwait(false);
+ break;
+ }
+ catch (HttpException ex)
{
- await _providerManager.SaveImage(season, image.Url, FanArtResourcePool, ImageType.Thumb, null, cancellationToken).ConfigureAwait(false);
+ // Sometimes fanart has bad url's in their xml
+ if (ex.StatusCode.HasValue && ex.StatusCode.Value == HttpStatusCode.NotFound)
+ {
+ continue;
+ }
}
}
}
diff --git a/MediaBrowser.Providers/TV/FanArtTVProvider.cs b/MediaBrowser.Providers/TV/FanArtTVProvider.cs
index 1f20140c50..037e0b5bc5 100644
--- a/MediaBrowser.Providers/TV/FanArtTVProvider.cs
+++ b/MediaBrowser.Providers/TV/FanArtTVProvider.cs
@@ -16,6 +16,8 @@ using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
+using MediaBrowser.Model.Net;
+using System.Net;
namespace MediaBrowser.Providers.TV
{
@@ -198,60 +200,35 @@ namespace MediaBrowser.Providers.TV
if (ConfigurationManager.Configuration.DownloadSeriesImages.Primary && !item.HasImage(ImageType.Primary))
{
- var image = images.FirstOrDefault(i => i.Type == ImageType.Primary);
-
- if (image != null)
- {
- await _providerManager.SaveImage(item, image.Url, FanArtResourcePool, ImageType.Primary, null, cancellationToken).ConfigureAwait(false);
- }
+ await SaveImage(item, images, ImageType.Primary, cancellationToken).ConfigureAwait(false);
}
cancellationToken.ThrowIfCancellationRequested();
if (ConfigurationManager.Configuration.DownloadSeriesImages.Logo && !item.HasImage(ImageType.Logo))
{
- var image = images.FirstOrDefault(i => i.Type == ImageType.Logo);
-
- if (image != null)
- {
- await _providerManager.SaveImage(item, image.Url, FanArtResourcePool, ImageType.Logo, null, cancellationToken).ConfigureAwait(false);
- }
+ await SaveImage(item, images, ImageType.Logo, cancellationToken).ConfigureAwait(false);
}
cancellationToken.ThrowIfCancellationRequested();
if (ConfigurationManager.Configuration.DownloadSeriesImages.Art && !item.HasImage(ImageType.Art))
{
- var image = images.FirstOrDefault(i => i.Type == ImageType.Art);
-
- if (image != null)
- {
- await _providerManager.SaveImage(item, image.Url, FanArtResourcePool, ImageType.Art, null, cancellationToken).ConfigureAwait(false);
- }
+ await SaveImage(item, images, ImageType.Art, cancellationToken).ConfigureAwait(false);
}
cancellationToken.ThrowIfCancellationRequested();
if (ConfigurationManager.Configuration.DownloadSeriesImages.Thumb && !item.HasImage(ImageType.Thumb))
{
- var image = images.FirstOrDefault(i => i.Type == ImageType.Thumb);
-
- if (image != null)
- {
- await _providerManager.SaveImage(item, image.Url, FanArtResourcePool, ImageType.Thumb, null, cancellationToken).ConfigureAwait(false);
- }
+ await SaveImage(item, images, ImageType.Thumb, cancellationToken).ConfigureAwait(false);
}
cancellationToken.ThrowIfCancellationRequested();
if (ConfigurationManager.Configuration.DownloadSeriesImages.Banner && !item.HasImage(ImageType.Banner))
{
- var image = images.FirstOrDefault(i => i.Type == ImageType.Banner);
-
- if (image != null)
- {
- await _providerManager.SaveImage(item, image.Url, FanArtResourcePool, ImageType.Banner, null, cancellationToken).ConfigureAwait(false);
- }
+ await SaveImage(item, images, ImageType.Banner, cancellationToken).ConfigureAwait(false);
}
cancellationToken.ThrowIfCancellationRequested();
@@ -271,6 +248,26 @@ namespace MediaBrowser.Providers.TV
}
+ private async Task SaveImage(BaseItem item, List images, ImageType type, CancellationToken cancellationToken)
+ {
+ foreach (var image in images.Where(i => i.Type == type))
+ {
+ try
+ {
+ await _providerManager.SaveImage(item, image.Url, FanArtResourcePool, type, null, cancellationToken).ConfigureAwait(false);
+ break;
+ }
+ catch (HttpException ex)
+ {
+ // Sometimes fanart has bad url's in their xml
+ if (ex.StatusCode.HasValue && ex.StatusCode.Value == HttpStatusCode.NotFound)
+ {
+ continue;
+ }
+ }
+ }
+ }
+
///
/// Downloads the series XML.
///