Added Backdrops and Screenshots to MetadataFields

pull/702/head
Thomas Gillen 11 years ago
parent 08b7f88b22
commit f0d0e1b94d

@ -45,6 +45,14 @@ namespace MediaBrowser.Model.Entities
/// <summary>
/// The images
/// </summary>
Images
Images,
/// <summary>
/// The backdrops
/// </summary>
Backdrops,
/// <summary>
/// The screenshots
/// </summary>
Screenshots
}
}

@ -167,12 +167,9 @@ namespace MediaBrowser.Providers.Movies
/// <param name="cancellationToken">The cancellation token</param>
/// <returns>Task{System.Boolean}.</returns>
public override async Task<bool> FetchAsync(BaseItem item, bool force, BaseProviderInfo providerInfo, CancellationToken cancellationToken)
{
if (!item.LockedFields.Contains(MetadataFields.Images))
{
var images = await _providerManager.GetAvailableRemoteImages(item, cancellationToken, ManualMovieDbImageProvider.ProviderName).ConfigureAwait(false);
await ProcessImages(item, images.ToList(), cancellationToken).ConfigureAwait(false);
}
SetLastRefreshed(item, DateTime.UtcNow, providerInfo);
return true;
@ -194,7 +191,7 @@ namespace MediaBrowser.Providers.Movies
.ToList();
// poster
if (eligiblePosters.Count > 0 && !item.HasImage(ImageType.Primary))
if (eligiblePosters.Count > 0 && !item.HasImage(ImageType.Primary) && !item.LockedFields.Contains(MetadataFields.Images))
{
var poster = eligiblePosters[0];
@ -220,7 +217,10 @@ namespace MediaBrowser.Providers.Movies
var backdropLimit = ConfigurationManager.Configuration.MaxBackdrops;
// backdrops - only download if earlier providers didn't find any (fanart)
if (eligibleBackdrops.Count > 0 && ConfigurationManager.Configuration.DownloadMovieImages.Backdrops && item.BackdropImagePaths.Count < backdropLimit)
if (eligibleBackdrops.Count > 0 &&
ConfigurationManager.Configuration.DownloadMovieImages.Backdrops &&
item.BackdropImagePaths.Count < backdropLimit &&
!item.LockedFields.Contains(MetadataFields.Backdrops))
{
for (var i = 0; i < eligibleBackdrops.Count; i++)
{

@ -162,12 +162,9 @@ namespace MediaBrowser.Providers.Movies
/// <param name="cancellationToken">The cancellation token</param>
/// <returns>Task{System.Boolean}.</returns>
public override async Task<bool> FetchAsync(BaseItem item, bool force, BaseProviderInfo providerInfo, CancellationToken cancellationToken)
{
if (!item.LockedFields.Contains(MetadataFields.Images))
{
var images = await _providerManager.GetAvailableRemoteImages(item, cancellationToken, ManualMovieDbPersonImageProvider.ProviderName).ConfigureAwait(false);
await ProcessImages(item, images.ToList(), cancellationToken).ConfigureAwait(false);
}
SetLastRefreshed(item, DateTime.UtcNow, providerInfo);
return true;
@ -189,7 +186,7 @@ namespace MediaBrowser.Providers.Movies
.ToList();
// poster
if (eligiblePosters.Count > 0 && !item.HasImage(ImageType.Primary))
if (eligiblePosters.Count > 0 && !item.HasImage(ImageType.Primary) && !item.LockedFields.Contains(MetadataFields.Images))
{
var poster = eligiblePosters[0];

@ -212,12 +212,11 @@ namespace MediaBrowser.Providers.Music
await DownloadArtistXml(artistDataPath, musicBrainzId, cancellationToken).ConfigureAwait(false);
}
if (!item.LockedFields.Contains(MetadataFields.Images) &&
(ConfigurationManager.Configuration.DownloadMusicArtistImages.Art ||
if (ConfigurationManager.Configuration.DownloadMusicArtistImages.Art ||
ConfigurationManager.Configuration.DownloadMusicArtistImages.Backdrops ||
ConfigurationManager.Configuration.DownloadMusicArtistImages.Banner ||
ConfigurationManager.Configuration.DownloadMusicArtistImages.Logo ||
ConfigurationManager.Configuration.DownloadMusicArtistImages.Primary))
ConfigurationManager.Configuration.DownloadMusicArtistImages.Primary)
{
var images = await _providerManager.GetAvailableRemoteImages(item, cancellationToken, ManualFanartArtistProvider.ProviderName).ConfigureAwait(false);
await FetchFromXml(item, images.ToList(), cancellationToken).ConfigureAwait(false);
@ -267,6 +266,8 @@ namespace MediaBrowser.Providers.Music
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
private async Task FetchFromXml(BaseItem item, List<RemoteImageInfo> images , CancellationToken cancellationToken)
{
if (!item.LockedFields.Contains(MetadataFields.Images))
{
cancellationToken.ThrowIfCancellationRequested();
@ -295,7 +296,10 @@ namespace MediaBrowser.Providers.Music
{
await SaveImage(item, images, ImageType.Banner, cancellationToken).ConfigureAwait(false);
}
}
if (!item.LockedFields.Contains(MetadataFields.Backdrops))
{
cancellationToken.ThrowIfCancellationRequested();
var backdropLimit = ConfigurationManager.Configuration.MaxBackdrops;
@ -311,6 +315,7 @@ namespace MediaBrowser.Providers.Music
}
}
}
}
private async Task SaveImage(BaseItem item, List<RemoteImageInfo> images, ImageType type, CancellationToken cancellationToken)
{

@ -103,12 +103,9 @@ namespace MediaBrowser.Providers.TV
var season = (Season) item;
if (!item.LockedFields.Contains(MetadataFields.Images))
{
// Process images
var images = await _providerManager.GetAvailableRemoteImages(item, cancellationToken, ManualFanartSeasonImageProvider.ProviderName).ConfigureAwait(false);
await FetchImages(season, images.ToList(), cancellationToken).ConfigureAwait(false);
}
SetLastRefreshed(item, DateTime.UtcNow, providerInfo);
return true;
@ -123,7 +120,7 @@ namespace MediaBrowser.Providers.TV
/// <returns>Task.</returns>
private async Task FetchImages(Season season, List<RemoteImageInfo> images, CancellationToken cancellationToken)
{
if (ConfigurationManager.Configuration.DownloadSeasonImages.Thumb && !season.HasImage(ImageType.Thumb))
if (ConfigurationManager.Configuration.DownloadSeasonImages.Thumb && !season.HasImage(ImageType.Thumb) && !season.LockedFields.Contains(MetadataFields.Images))
{
await SaveImage(season, images, ImageType.Thumb, cancellationToken).ConfigureAwait(false);
}

@ -167,7 +167,7 @@ namespace MediaBrowser.Providers.TV
var seriesId = item.GetProviderId(MetadataProviders.Tvdb);
if (!string.IsNullOrEmpty(seriesId) && !item.LockedFields.Contains(MetadataFields.Images))
if (!string.IsNullOrEmpty(seriesId))
{
var xmlPath = GetFanartXmlPath(seriesId);
@ -195,6 +195,8 @@ namespace MediaBrowser.Providers.TV
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
private async Task FetchFromXml(BaseItem item, List<RemoteImageInfo> images, CancellationToken cancellationToken)
{
if (!item.LockedFields.Contains(MetadataFields.Images))
{
cancellationToken.ThrowIfCancellationRequested();
@ -230,7 +232,10 @@ namespace MediaBrowser.Providers.TV
{
await SaveImage(item, images, ImageType.Banner, cancellationToken).ConfigureAwait(false);
}
}
if (!item.LockedFields.Contains(MetadataFields.Backdrops))
{
cancellationToken.ThrowIfCancellationRequested();
var backdropLimit = ConfigurationManager.Configuration.MaxBackdrops;
@ -245,7 +250,7 @@ namespace MediaBrowser.Providers.TV
if (item.BackdropImagePaths.Count >= backdropLimit) break;
}
}
}
}
private async Task SaveImage(BaseItem item, List<RemoteImageInfo> images, ImageType type, CancellationToken cancellationToken)

@ -147,20 +147,19 @@ namespace MediaBrowser.Providers.TV
{
cancellationToken.ThrowIfCancellationRequested();
if (!item.LockedFields.Contains(MetadataFields.Images))
{
var images = await _providerManager.GetAvailableRemoteImages(item, cancellationToken, ManualTvdbSeasonImageProvider.ProviderName).ConfigureAwait(false);
const int backdropLimit = 1;
await DownloadImages(item, images.ToList(), backdropLimit, cancellationToken).ConfigureAwait(false);
}
SetLastRefreshed(item, DateTime.UtcNow, providerInfo);
return true;
}
private async Task DownloadImages(BaseItem item, List<RemoteImageInfo> images, int backdropLimit, CancellationToken cancellationToken)
{
if (!item.LockedFields.Contains(MetadataFields.Images))
{
if (!item.HasImage(ImageType.Primary))
{
@ -171,8 +170,9 @@ namespace MediaBrowser.Providers.TV
{
await SaveImage(item, images, ImageType.Banner, cancellationToken).ConfigureAwait(false);
}
}
if (ConfigurationManager.Configuration.DownloadSeasonImages.Backdrops && item.BackdropImagePaths.Count < backdropLimit)
if (ConfigurationManager.Configuration.DownloadSeasonImages.Backdrops && item.BackdropImagePaths.Count < backdropLimit && !item.LockedFields.Contains(MetadataFields.Backdrops))
{
foreach (var backdrop in images.Where(i => i.Type == ImageType.Backdrop))
{

@ -155,20 +155,19 @@ namespace MediaBrowser.Providers.TV
{
cancellationToken.ThrowIfCancellationRequested();
if (!item.LockedFields.Contains(MetadataFields.Images))
{
var images = await _providerManager.GetAvailableRemoteImages(item, cancellationToken, ManualTvdbSeriesImageProvider.ProviderName).ConfigureAwait(false);
const int backdropLimit = 1;
await DownloadImages(item, images.ToList(), backdropLimit, cancellationToken).ConfigureAwait(false);
}
SetLastRefreshed(item, DateTime.UtcNow, providerInfo);
return true;
}
private async Task DownloadImages(BaseItem item, List<RemoteImageInfo> images, int backdropLimit, CancellationToken cancellationToken)
{
if (!item.LockedFields.Contains(MetadataFields.Images))
{
if (!item.HasImage(ImageType.Primary))
{
@ -191,8 +190,9 @@ namespace MediaBrowser.Providers.TV
.ConfigureAwait(false);
}
}
}
if (ConfigurationManager.Configuration.DownloadSeriesImages.Backdrops && item.BackdropImagePaths.Count < backdropLimit)
if (ConfigurationManager.Configuration.DownloadSeriesImages.Backdrops && item.BackdropImagePaths.Count < backdropLimit && !item.LockedFields.Contains(MetadataFields.Backdrops))
{
foreach (var backdrop in images.Where(i => i.Type == ImageType.Backdrop &&
(!i.Width.HasValue ||

Loading…
Cancel
Save