Added Images to MetadataFields

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

@ -41,6 +41,10 @@ namespace MediaBrowser.Model.Entities
/// <summary> /// <summary>
/// The official rating /// The official rating
/// </summary> /// </summary>
OfficialRating OfficialRating,
/// <summary>
/// The images
/// </summary>
Images
} }
} }

@ -132,7 +132,9 @@ namespace MediaBrowser.Providers.Movies
} }
// Don't refresh if we already have both poster and backdrop and we're not refreshing images // Don't refresh if we already have both poster and backdrop and we're not refreshing images
if (item.HasImage(ImageType.Primary) && item.BackdropImagePaths.Count >= ConfigurationManager.Configuration.MaxBackdrops) if (item.HasImage(ImageType.Primary) &&
item.BackdropImagePaths.Count >= ConfigurationManager.Configuration.MaxBackdrops &&
!item.LockedFields.Contains(MetadataFields.Images))
{ {
return false; return false;
} }
@ -166,9 +168,11 @@ namespace MediaBrowser.Providers.Movies
/// <returns>Task{System.Boolean}.</returns> /// <returns>Task{System.Boolean}.</returns>
public override async Task<bool> FetchAsync(BaseItem item, bool force, BaseProviderInfo providerInfo, CancellationToken cancellationToken) public override async Task<bool> FetchAsync(BaseItem item, bool force, BaseProviderInfo providerInfo, CancellationToken cancellationToken)
{ {
var images = await _providerManager.GetAvailableRemoteImages(item, cancellationToken, ManualMovieDbImageProvider.ProviderName).ConfigureAwait(false); if (!item.LockedFields.Contains(MetadataFields.Images))
{
await ProcessImages(item, images.ToList(), cancellationToken).ConfigureAwait(false); var images = await _providerManager.GetAvailableRemoteImages(item, cancellationToken, ManualMovieDbImageProvider.ProviderName).ConfigureAwait(false);
await ProcessImages(item, images.ToList(), cancellationToken).ConfigureAwait(false);
}
SetLastRefreshed(item, DateTime.UtcNow, providerInfo); SetLastRefreshed(item, DateTime.UtcNow, providerInfo);
return true; return true;

@ -163,9 +163,11 @@ namespace MediaBrowser.Providers.Movies
/// <returns>Task{System.Boolean}.</returns> /// <returns>Task{System.Boolean}.</returns>
public override async Task<bool> FetchAsync(BaseItem item, bool force, BaseProviderInfo providerInfo, CancellationToken cancellationToken) public override async Task<bool> FetchAsync(BaseItem item, bool force, BaseProviderInfo providerInfo, CancellationToken cancellationToken)
{ {
var images = await _providerManager.GetAvailableRemoteImages(item, cancellationToken, ManualMovieDbPersonImageProvider.ProviderName).ConfigureAwait(false); if (!item.LockedFields.Contains(MetadataFields.Images))
{
await ProcessImages(item, images.ToList(), cancellationToken).ConfigureAwait(false); var images = await _providerManager.GetAvailableRemoteImages(item, cancellationToken, ManualMovieDbPersonImageProvider.ProviderName).ConfigureAwait(false);
await ProcessImages(item, images.ToList(), cancellationToken).ConfigureAwait(false);
}
SetLastRefreshed(item, DateTime.UtcNow, providerInfo); SetLastRefreshed(item, DateTime.UtcNow, providerInfo);
return true; return true;

@ -154,9 +154,11 @@ namespace MediaBrowser.Providers.Music
/// <returns>Task{System.Boolean}.</returns> /// <returns>Task{System.Boolean}.</returns>
public override async Task<bool> FetchAsync(BaseItem item, bool force, BaseProviderInfo providerInfo, CancellationToken cancellationToken) public override async Task<bool> FetchAsync(BaseItem item, bool force, BaseProviderInfo providerInfo, CancellationToken cancellationToken)
{ {
var images = await _providerManager.GetAvailableRemoteImages(item, cancellationToken, ManualFanartAlbumProvider.ProviderName).ConfigureAwait(false); if (!item.LockedFields.Contains(MetadataFields.Images))
{
await FetchFromXml(item, images.ToList(), cancellationToken).ConfigureAwait(false); var images = await _providerManager.GetAvailableRemoteImages(item, cancellationToken, ManualFanartAlbumProvider.ProviderName).ConfigureAwait(false);
await FetchFromXml(item, images.ToList(), cancellationToken).ConfigureAwait(false);
}
SetLastRefreshed(item, DateTime.UtcNow, providerInfo); SetLastRefreshed(item, DateTime.UtcNow, providerInfo);

@ -212,14 +212,14 @@ namespace MediaBrowser.Providers.Music
await DownloadArtistXml(artistDataPath, musicBrainzId, cancellationToken).ConfigureAwait(false); await DownloadArtistXml(artistDataPath, musicBrainzId, cancellationToken).ConfigureAwait(false);
} }
if (ConfigurationManager.Configuration.DownloadMusicArtistImages.Art || if (!item.LockedFields.Contains(MetadataFields.Images) &&
ConfigurationManager.Configuration.DownloadMusicArtistImages.Backdrops || (ConfigurationManager.Configuration.DownloadMusicArtistImages.Art ||
ConfigurationManager.Configuration.DownloadMusicArtistImages.Banner || ConfigurationManager.Configuration.DownloadMusicArtistImages.Backdrops ||
ConfigurationManager.Configuration.DownloadMusicArtistImages.Logo || ConfigurationManager.Configuration.DownloadMusicArtistImages.Banner ||
ConfigurationManager.Configuration.DownloadMusicArtistImages.Primary) ConfigurationManager.Configuration.DownloadMusicArtistImages.Logo ||
ConfigurationManager.Configuration.DownloadMusicArtistImages.Primary))
{ {
var images = await _providerManager.GetAvailableRemoteImages(item, cancellationToken, ManualFanartArtistProvider.ProviderName).ConfigureAwait(false); var images = await _providerManager.GetAvailableRemoteImages(item, cancellationToken, ManualFanartArtistProvider.ProviderName).ConfigureAwait(false);
await FetchFromXml(item, images.ToList(), cancellationToken).ConfigureAwait(false); await FetchFromXml(item, images.ToList(), cancellationToken).ConfigureAwait(false);
} }

@ -90,7 +90,7 @@ namespace MediaBrowser.Providers.Music
? ConfigurationManager.Configuration.DownloadMusicAlbumImages ? ConfigurationManager.Configuration.DownloadMusicAlbumImages
: ConfigurationManager.Configuration.DownloadMusicArtistImages; : ConfigurationManager.Configuration.DownloadMusicArtistImages;
if (configSetting.Primary && !item.HasImage(ImageType.Primary)) if (configSetting.Primary && !item.HasImage(ImageType.Primary) && !item.LockedFields.Contains(MetadataFields.Images))
{ {
var image = images.FirstOrDefault(i => i.Type == ImageType.Primary); var image = images.FirstOrDefault(i => i.Type == ImageType.Primary);

@ -103,10 +103,12 @@ namespace MediaBrowser.Providers.TV
var season = (Season)item; var season = (Season)item;
// Process images if (!item.LockedFields.Contains(MetadataFields.Images))
var images = await _providerManager.GetAvailableRemoteImages(item, cancellationToken, ManualFanartSeasonImageProvider.ProviderName).ConfigureAwait(false); {
// Process images
await FetchImages(season, images.ToList(), cancellationToken).ConfigureAwait(false); var images = await _providerManager.GetAvailableRemoteImages(item, cancellationToken, ManualFanartSeasonImageProvider.ProviderName).ConfigureAwait(false);
await FetchImages(season, images.ToList(), cancellationToken).ConfigureAwait(false);
}
SetLastRefreshed(item, DateTime.UtcNow, providerInfo); SetLastRefreshed(item, DateTime.UtcNow, providerInfo);
return true; return true;

@ -167,7 +167,7 @@ namespace MediaBrowser.Providers.TV
var seriesId = item.GetProviderId(MetadataProviders.Tvdb); var seriesId = item.GetProviderId(MetadataProviders.Tvdb);
if (!string.IsNullOrEmpty(seriesId)) if (!string.IsNullOrEmpty(seriesId) && !item.LockedFields.Contains(MetadataFields.Images))
{ {
var xmlPath = GetFanartXmlPath(seriesId); var xmlPath = GetFanartXmlPath(seriesId);

@ -75,9 +75,10 @@ namespace MediaBrowser.Providers.TV
SetLastRefreshed(item, DateTime.UtcNow, providerInfo); SetLastRefreshed(item, DateTime.UtcNow, providerInfo);
return true; return true;
} }
private async Task DownloadImages(BaseItem item, List<RemoteImageInfo> images, CancellationToken cancellationToken) private async Task DownloadImages(BaseItem item, List<RemoteImageInfo> images, CancellationToken cancellationToken)
{ {
if (!item.HasImage(ImageType.Primary)) if (!item.HasImage(ImageType.Primary) && !item.LockedFields.Contains(MetadataFields.Images))
{ {
var image = images.FirstOrDefault(i => i.Type == ImageType.Primary); var image = images.FirstOrDefault(i => i.Type == ImageType.Primary);

@ -147,11 +147,14 @@ namespace MediaBrowser.Providers.TV
{ {
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
var images = await _providerManager.GetAvailableRemoteImages(item, cancellationToken, ManualTvdbSeasonImageProvider.ProviderName).ConfigureAwait(false); if (!item.LockedFields.Contains(MetadataFields.Images))
{
var images = await _providerManager.GetAvailableRemoteImages(item, cancellationToken, ManualTvdbSeasonImageProvider.ProviderName).ConfigureAwait(false);
const int backdropLimit = 1; const int backdropLimit = 1;
await DownloadImages(item, images.ToList(), backdropLimit, cancellationToken).ConfigureAwait(false); await DownloadImages(item, images.ToList(), backdropLimit, cancellationToken).ConfigureAwait(false);
}
SetLastRefreshed(item, DateTime.UtcNow, providerInfo); SetLastRefreshed(item, DateTime.UtcNow, providerInfo);
return true; return true;

@ -155,11 +155,14 @@ namespace MediaBrowser.Providers.TV
{ {
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
var images = await _providerManager.GetAvailableRemoteImages(item, cancellationToken, ManualTvdbSeriesImageProvider.ProviderName).ConfigureAwait(false); if (!item.LockedFields.Contains(MetadataFields.Images))
{
var images = await _providerManager.GetAvailableRemoteImages(item, cancellationToken, ManualTvdbSeriesImageProvider.ProviderName).ConfigureAwait(false);
const int backdropLimit = 1; const int backdropLimit = 1;
await DownloadImages(item, images.ToList(), backdropLimit, cancellationToken).ConfigureAwait(false); await DownloadImages(item, images.ToList(), backdropLimit, cancellationToken).ConfigureAwait(false);
}
SetLastRefreshed(item, DateTime.UtcNow, providerInfo); SetLastRefreshed(item, DateTime.UtcNow, providerInfo);
return true; return true;

Loading…
Cancel
Save