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


C# BaseItem.HasLocalImage方法代码示例

本文整理汇总了C#中BaseItem.HasLocalImage方法的典型用法代码示例。如果您正苦于以下问题:C# BaseItem.HasLocalImage方法的具体用法?C# BaseItem.HasLocalImage怎么用?C# BaseItem.HasLocalImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BaseItem的用法示例。


在下文中一共展示了BaseItem.HasLocalImage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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>
        protected virtual async Task<ProviderRefreshStatus> ProcessImages(BaseItem item, MovieImages images, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            var status = ProviderRefreshStatus.Success;

            //        poster
            if (images.posters != null && images.posters.Count > 0 && !item.HasImage(ImageType.Primary))
            {
                var tmdbSettings = await MovieDbProvider.Current.GetTmdbSettings(cancellationToken).ConfigureAwait(false);

                var tmdbImageUrl = tmdbSettings.images.base_url + ConfigurationManager.Configuration.TmdbFetchedPosterSize;
                // get highest rated poster for our language

                var postersSortedByVote = images.posters.OrderByDescending(i => i.vote_average);

                var poster = postersSortedByVote.FirstOrDefault(p => p.iso_639_1 != null && p.iso_639_1.Equals(ConfigurationManager.Configuration.PreferredMetadataLanguage, StringComparison.OrdinalIgnoreCase));
                if (poster == null && !ConfigurationManager.Configuration.PreferredMetadataLanguage.Equals("en"))
                {
                    // couldn't find our specific language, find english (if that wasn't our language)
                    poster = postersSortedByVote.FirstOrDefault(p => p.iso_639_1 != null && p.iso_639_1.Equals("en", StringComparison.OrdinalIgnoreCase));
                }
                if (poster == null)
                {
                    //still couldn't find it - try highest rated null one
                    poster = postersSortedByVote.FirstOrDefault(p => p.iso_639_1 == null);
                }
                if (poster == null)
                {
                    //finally - just get the highest rated one
                    poster = postersSortedByVote.FirstOrDefault();
                }
                if (poster != null)
                {
                    var img = await MovieDbProvider.Current.GetMovieDbResponse(new HttpRequestOptions
                    {
                        Url = tmdbImageUrl + poster.file_path,
                        CancellationToken = cancellationToken

                    }).ConfigureAwait(false);

                    await _providerManager.SaveImage(item, img, MimeTypes.GetMimeType(poster.file_path), ImageType.Primary, null, cancellationToken)
                                        .ConfigureAwait(false);

                }
            }

            cancellationToken.ThrowIfCancellationRequested();

            // backdrops - only download if earlier providers didn't find any (fanart)
            if (images.backdrops != null && images.backdrops.Count > 0 && ConfigurationManager.Configuration.DownloadMovieImages.Backdrops && item.BackdropImagePaths.Count == 0)
            {
                var tmdbSettings = await MovieDbProvider.Current.GetTmdbSettings(cancellationToken).ConfigureAwait(false);

                var tmdbImageUrl = tmdbSettings.images.base_url + ConfigurationManager.Configuration.TmdbFetchedBackdropSize;

                for (var i = 0; i < images.backdrops.Count; i++)
                {
                    var bdName = "backdrop" + (i == 0 ? "" : i.ToString(CultureInfo.InvariantCulture));

                    var hasLocalBackdrop = item.LocationType == LocationType.FileSystem && ConfigurationManager.Configuration.SaveLocalMeta ? item.HasLocalImage(bdName) : item.BackdropImagePaths.Count > i;

                    if (!hasLocalBackdrop)
                    {
                        var img = await MovieDbProvider.Current.GetMovieDbResponse(new HttpRequestOptions
                        {
                            Url = tmdbImageUrl + images.backdrops[i].file_path,
                            CancellationToken = cancellationToken

                        }).ConfigureAwait(false);

                        await _providerManager.SaveImage(item, img, MimeTypes.GetMimeType(images.backdrops[i].file_path), ImageType.Backdrop, item.BackdropImagePaths.Count, cancellationToken)
                          .ConfigureAwait(false);
                    }

                    if (item.BackdropImagePaths.Count >= ConfigurationManager.Configuration.MaxBackdrops)
                    {
                        break;
                    }
                }
            }

            return status;
        }
开发者ID:0sm0,项目名称:MediaBrowser,代码行数:91,代码来源:MovieDbImagesProvider.cs


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