本文整理汇总了C#中BaseItem.ContainsImageWithSourceUrl方法的典型用法代码示例。如果您正苦于以下问题:C# BaseItem.ContainsImageWithSourceUrl方法的具体用法?C# BaseItem.ContainsImageWithSourceUrl怎么用?C# BaseItem.ContainsImageWithSourceUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseItem
的用法示例。
在下文中一共展示了BaseItem.ContainsImageWithSourceUrl方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessImages
/// <summary>
/// Processes the images.
/// </summary>
/// <param name="item">The item.</param>
/// <param name="images">The images.</param>
/// <param name="cancellationToken">The cancellation token</param>
/// <returns>Task.</returns>
private async Task ProcessImages(BaseItem item, List<RemoteImageInfo> images, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
var eligiblePosters = images
.Where(i => i.Type == ImageType.Primary)
.ToList();
// poster
if (eligiblePosters.Count > 0 && !item.HasImage(ImageType.Primary) && !item.LockedFields.Contains(MetadataFields.Images))
{
var poster = eligiblePosters[0];
var url = poster.Url;
var img = await MovieDbProvider.Current.GetMovieDbResponse(new HttpRequestOptions
{
Url = url,
CancellationToken = cancellationToken
}).ConfigureAwait(false);
await _providerManager.SaveImage(item, img, MimeTypes.GetMimeType(url), ImageType.Primary, null, url, cancellationToken)
.ConfigureAwait(false);
}
cancellationToken.ThrowIfCancellationRequested();
var eligibleBackdrops = images
.Where(i => i.Type == ImageType.Backdrop && i.Width.HasValue && i.Width.Value >= ConfigurationManager.Configuration.MinMovieBackdropDownloadWidth)
.ToList();
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 &&
!item.LockedFields.Contains(MetadataFields.Backdrops))
{
for (var i = 0; i < eligibleBackdrops.Count; i++)
{
var url = eligibleBackdrops[i].Url;
if (!item.ContainsImageWithSourceUrl(url))
{
var img = await MovieDbProvider.Current.GetMovieDbResponse(new HttpRequestOptions
{
Url = url,
CancellationToken = cancellationToken
}).ConfigureAwait(false);
await _providerManager.SaveImage(item, img, MimeTypes.GetMimeType(url), ImageType.Backdrop, null, url, cancellationToken)
.ConfigureAwait(false);
}
if (item.BackdropImagePaths.Count >= backdropLimit)
{
break;
}
}
}
}
示例2: DownloadImages
private async Task DownloadImages(BaseItem item, List<RemoteImageInfo> images, int backdropLimit, CancellationToken cancellationToken)
{
if (!item.LockedFields.Contains(MetadataFields.Images))
{
if (!item.HasImage(ImageType.Primary))
{
var image = images.FirstOrDefault(i => i.Type == ImageType.Primary);
if (image != null)
{
await _providerManager.SaveImage(item, image.Url, TvdbSeriesProvider.Current.TvDbResourcePool, ImageType.Primary, null, cancellationToken)
.ConfigureAwait(false);
}
}
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, TvdbSeriesProvider.Current.TvDbResourcePool, ImageType.Banner, null, cancellationToken)
.ConfigureAwait(false);
}
}
}
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 ||
i.Width.Value >= ConfigurationManager.Configuration.TvOptions.MinBackdropWidth)))
{
var url = backdrop.Url;
if (item.ContainsImageWithSourceUrl(url))
{
continue;
}
await _providerManager.SaveImage(item, url, TvdbSeriesProvider.Current.TvDbResourcePool, ImageType.Backdrop, null, cancellationToken).ConfigureAwait(false);
if (item.BackdropImagePaths.Count >= backdropLimit) break;
}
}
}
示例3: DownloadImages
private async Task DownloadImages(BaseItem item, List<RemoteImageInfo> images, int backdropLimit, CancellationToken cancellationToken)
{
if (!item.HasImage(ImageType.Primary))
{
await SaveImage(item, images, ImageType.Primary, cancellationToken).ConfigureAwait(false);
}
if (ConfigurationManager.Configuration.DownloadSeasonImages.Banner && !item.HasImage(ImageType.Banner))
{
await SaveImage(item, images, ImageType.Banner, cancellationToken).ConfigureAwait(false);
}
if (ConfigurationManager.Configuration.DownloadSeasonImages.Backdrops && item.BackdropImagePaths.Count < backdropLimit)
{
foreach (var backdrop in images.Where(i => i.Type == ImageType.Backdrop))
{
var url = backdrop.Url;
if (item.ContainsImageWithSourceUrl(url))
{
continue;
}
await _providerManager.SaveImage(item, url, TvdbSeriesProvider.Current.TvDbResourcePool, ImageType.Backdrop, null, cancellationToken).ConfigureAwait(false);
if (item.BackdropImagePaths.Count >= backdropLimit) break;
}
}
}