當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。