当前位置: 首页>>代码示例>>C#>>正文


C# BaseItem.ContainsImageWithSourceUrl方法代码示例

本文整理汇总了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;
                    }
                }
            }
        }
开发者ID:Brendon-MB3,项目名称:MediaBrowser,代码行数:71,代码来源:MovieDbImagesProvider.cs

示例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;
                }
            }
        }
开发者ID:jscorrea,项目名称:MediaBrowser,代码行数:46,代码来源:TvdbSeriesImageProvider.cs

示例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;
                }
            }
        }
开发者ID:RomanDengin,项目名称:MediaBrowser,代码行数:29,代码来源:TvdbSeasonProvider.cs


注:本文中的BaseItem.ContainsImageWithSourceUrl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。