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


C# BaseItem.GetPreferredMetadataLanguage方法代码示例

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


在下文中一共展示了BaseItem.GetPreferredMetadataLanguage方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FetchImages

        /// <summary>
        /// Fetches the images.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="jsonSerializer">The json serializer.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>Task{MovieImages}.</returns>
        private async Task<MovieDbProvider.Images> FetchImages(BaseItem item, IJsonSerializer jsonSerializer,
            CancellationToken cancellationToken)
        {
            var tmdbId = item.GetProviderId(MetadataProviders.Tmdb);
            var language = item.GetPreferredMetadataLanguage();

            if (string.IsNullOrEmpty(tmdbId))
            {
                return null;
            }

            await MovieDbProvider.Current.EnsureMovieInfo(tmdbId, language, cancellationToken).ConfigureAwait(false);

            var path = MovieDbProvider.Current.GetDataFilePath(tmdbId, language);

            if (!string.IsNullOrEmpty(path))
            {
                var fileInfo = new FileInfo(path);

                if (fileInfo.Exists)
                {
                    return jsonSerializer.DeserializeFromFile<MovieDbProvider.CompleteMovieData>(path).images;
                }
            }

            return null;
        }
开发者ID:bigjohn322,项目名称:MediaBrowser,代码行数:34,代码来源:MovieDbImageProvider.cs

示例2: ShouldFetchGenres

        private bool ShouldFetchGenres(BaseItem item)
        {
            var lang = item.GetPreferredMetadataLanguage();

            // The data isn't localized and so can only be used for english users
            return string.Equals(lang, "en", StringComparison.OrdinalIgnoreCase);
        }
开发者ID:redteamcpu,项目名称:Emby,代码行数:7,代码来源:OmdbProvider.cs

示例3: ProcessMainInfo


//.........这里部分代码省略.........
                                               : !string.IsNullOrEmpty(usRelease.certification)
                                                     ? usRelease.certification
                                                     : !string.IsNullOrEmpty(minimunRelease.certification)
                                                           ? minimunRelease.iso_3166_1 + "-" + minimunRelease.certification
                                                           : null;
                }
            }

            if (movieData.release_date.Year != 1)
            {
                //no specific country release info at all
                movie.PremiereDate = movieData.release_date.ToUniversalTime();
                movie.ProductionYear = movieData.release_date.Year;
            }

            // If that didn't find a rating and we are a boxset, use the one from our first child
            if (movie.OfficialRating == null && movie is BoxSet && !movie.LockedFields.Contains(MetadataFields.OfficialRating))
            {
                var boxset = movie as BoxSet;
                Logger.Info("MovieDbProvider - Using rating of first child of boxset...");

                var firstChild = boxset.Children.Concat(boxset.GetLinkedChildren()).FirstOrDefault();

                boxset.OfficialRating = firstChild != null ? firstChild.OfficialRating : null;
            }

            //studios
            if (movieData.production_companies != null && !movie.LockedFields.Contains(MetadataFields.Studios))
            {
                movie.Studios.Clear();

                foreach (var studio in movieData.production_companies.Select(c => c.name))
                {
                    movie.AddStudio(studio);
                }
            }

            // genres
            // Movies get this from imdb
            var genres = movieData.genres ?? new List<GenreItem>();
            if (!movie.LockedFields.Contains(MetadataFields.Genres))
            {
                // Only grab them if a boxset or there are no genres.
                // For movies and trailers we'll use imdb via omdb
                // But omdb data is for english users only so fetch if language is not english
                if (!(movie is Movie) || movie.Genres.Count == 0 || !string.Equals(movie.GetPreferredMetadataLanguage(), "en", StringComparison.OrdinalIgnoreCase))
                {
                    movie.Genres.Clear();

                    foreach (var genre in genres.Select(g => g.name))
                    {
                        movie.AddGenre(genre);
                    }
                }
            }

            if (!movie.LockedFields.Contains(MetadataFields.Cast))
            {
                movie.People.Clear();

                //Actors, Directors, Writers - all in People
                //actors come from cast
                if (movieData.casts != null && movieData.casts.cast != null)
                {
                    foreach (var actor in movieData.casts.cast.OrderBy(a => a.order)) movie.AddPerson(new PersonInfo { Name = actor.name.Trim(), Role = actor.character, Type = PersonType.Actor, SortOrder = actor.order });
                }

                //and the rest from crew
                if (movieData.casts != null && movieData.casts.crew != null)
                {
                    foreach (var person in movieData.casts.crew) movie.AddPerson(new PersonInfo { Name = person.name.Trim(), Role = person.job, Type = person.department });
                }
            }

            if (movieData.keywords != null && movieData.keywords.keywords != null && !movie.LockedFields.Contains(MetadataFields.Keywords))
            {
                var hasTags = movie as IHasKeywords;
                if (hasTags != null)
                {
                    hasTags.Keywords = movieData.keywords.keywords.Select(i => i.name).ToList();
                }
            }

            if (movieData.trailers != null && movieData.trailers.youtube != null &&
                movieData.trailers.youtube.Count > 0)
            {
                var hasTrailers = movie as IHasTrailers;
                if (hasTrailers != null)
                {
                    hasTrailers.RemoteTrailers = movieData.trailers.youtube.Select(i => new MediaUrl
                    {
                        Url = string.Format("http://www.youtube.com/watch?v={0}", i.source),
                        IsDirectLink = false,
                        Name = i.name,
                        VideoSize = string.Equals("hd", i.size, StringComparison.OrdinalIgnoreCase) ? VideoSize.HighDefinition : VideoSize.StandardDefinition

                    }).ToList();
                }
            }
        }
开发者ID:jscorrea,项目名称:MediaBrowser,代码行数:101,代码来源:MovieDbProvider.cs

示例4: ShouldFetchGenres

        private bool ShouldFetchGenres(BaseItem item)
        {
            var lang = item.GetPreferredMetadataLanguage();

            // The data isn't localized and so can only be used for english users
            if (!string.Equals(lang, "en", StringComparison.OrdinalIgnoreCase))
            {
                return false;
            }

            // Only fetch if other providers didn't get anything
            if (item is Trailer)
            {
                return item.Genres.Count == 0;
            }

            return item is Series || item is Movie;
        }
开发者ID:jscorrea,项目名称:MediaBrowser,代码行数:18,代码来源:OpenMovieDatabaseProvider.cs

示例5: GetDataFilePath

        /// <summary>
        /// Gets the data file path.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <returns>System.String.</returns>
        internal string GetDataFilePath(BaseItem item)
        {
            var id = item.GetProviderId(MetadataProviders.Tmdb);

            if (string.IsNullOrEmpty(id))
            {
                return null;
            }

            return GetDataFilePath(item is BoxSet, id, item.GetPreferredMetadataLanguage());
        }
开发者ID:jscorrea,项目名称:MediaBrowser,代码行数:16,代码来源:MovieDbProvider.cs

示例6: EnsureMovieInfo

        internal Task EnsureMovieInfo(BaseItem item, CancellationToken cancellationToken)
        {
            var path = GetDataFilePath(item);

            var fileInfo = _fileSystem.GetFileSystemInfo(path);

            if (fileInfo.Exists)
            {
                // If it's recent or automatic updates are enabled, don't re-download
                if (ConfigurationManager.Configuration.EnableTmdbUpdates || (DateTime.UtcNow - _fileSystem.GetLastWriteTimeUtc(fileInfo)).TotalDays <= 7)
                {
                    return Task.FromResult(true);
                }
            }

            var id = item.GetProviderId(MetadataProviders.Tmdb);

            if (string.IsNullOrEmpty(id))
            {
                return Task.FromResult(true);
            }

            return DownloadMovieInfo(id, item is BoxSet, item.GetPreferredMetadataLanguage(), cancellationToken);
        }
开发者ID:jscorrea,项目名称:MediaBrowser,代码行数:24,代码来源:MovieDbProvider.cs

示例7: FetchMovieData

        /// <summary>
        /// Fetches the movie data.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="id">The id.</param>
        /// <param name="isForcedRefresh">if set to <c>true</c> [is forced refresh].</param>
        /// <param name="cancellationToken">The cancellation token</param>
        /// <returns>Task.</returns>
        private async Task FetchMovieData(BaseItem item, string id, bool isForcedRefresh, CancellationToken cancellationToken)
        {
            // Id could be ImdbId or TmdbId

            var language = item.GetPreferredMetadataLanguage();
            var country = item.GetPreferredMetadataCountryCode();

            var dataFilePath = GetDataFilePath(item);

            var tmdbId = item.GetProviderId(MetadataProviders.Tmdb);

            var isBoxSet = item is BoxSet;

            if (string.IsNullOrEmpty(dataFilePath) || !File.Exists(dataFilePath))
            {
                var mainResult = await FetchMainResult(id, isBoxSet, language, cancellationToken).ConfigureAwait(false);

                if (mainResult == null) return;

                tmdbId = mainResult.id.ToString(_usCulture);

                dataFilePath = GetDataFilePath(isBoxSet, tmdbId, language);

                var directory = Path.GetDirectoryName(dataFilePath);

                Directory.CreateDirectory(directory);

                JsonSerializer.SerializeToFile(mainResult, dataFilePath);
            }

            if (isForcedRefresh || ConfigurationManager.Configuration.EnableTmdbUpdates || !HasAltMeta(item))
            {
                dataFilePath = GetDataFilePath(isBoxSet, tmdbId, language);

                if (!string.IsNullOrEmpty(dataFilePath))
                {
                    var mainResult = JsonSerializer.DeserializeFromFile<CompleteMovieData>(dataFilePath);

                    ProcessMainInfo(item, mainResult);
                }
            }
        }
开发者ID:jscorrea,项目名称:MediaBrowser,代码行数:50,代码来源:MovieDbProvider.cs

示例8: FindId

        /// <summary>
        /// Finds the id.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="cancellationToken">The cancellation token</param>
        /// <returns>Task{System.String}.</returns>
        public async Task<string> FindId(BaseItem item, CancellationToken cancellationToken)
        {
            int? yearInName;
            string name = item.Name;
            NameParser.ParseName(name, out name, out yearInName);

            var year = item.ProductionYear ?? yearInName;

            Logger.Info("MovieDbProvider: Finding id for item: " + name);
            var language = item.GetPreferredMetadataLanguage().ToLower();

            //if we are a boxset - look at our first child
            var boxset = item as BoxSet;
            if (boxset != null)
            {
                // See if any movies have a collection id already
                var collId = boxset.Children.Concat(boxset.GetLinkedChildren()).OfType<Video>()
                    .Select(i => i.GetProviderId(MetadataProviders.TmdbCollection))
                   .FirstOrDefault(i => i != null);

                if (collId != null) return collId;

            }

            //nope - search for it
            var searchType = item is BoxSet ? "collection" : "movie";
            var id = await AttemptFindId(name, searchType, year, language, cancellationToken).ConfigureAwait(false);
            if (id == null)
            {
                //try in english if wasn't before
                if (language != "en")
                {
                    id = await AttemptFindId(name, searchType, year, "en", cancellationToken).ConfigureAwait(false);
                }
                else
                {
                    // try with dot and _ turned to space
                    var originalName = name;

                    name = name.Replace(",", " ");
                    name = name.Replace(".", " ");
                    name = name.Replace("_", " ");
                    name = name.Replace("-", " ");

                    // Search again if the new name is different
                    if (!string.Equals(name, originalName))
                    {
                        id = await AttemptFindId(name, searchType, year, language, cancellationToken).ConfigureAwait(false);

                        if (id == null && language != "en")
                        {
                            //one more time, in english
                            id = await AttemptFindId(name, searchType, year, "en", cancellationToken).ConfigureAwait(false);

                        }
                    }

                    if (id == null && item.LocationType == LocationType.FileSystem)
                    {
                        //last resort - try using the actual folder name
                        var pathName = Path.GetFileName(item.ResolveArgs.Path);

                        // Only search if it's a name we haven't already tried.
                        if (!string.Equals(pathName, name, StringComparison.OrdinalIgnoreCase)
                            && !string.Equals(pathName, originalName, StringComparison.OrdinalIgnoreCase))
                        {
                            id = await AttemptFindId(pathName, searchType, year, "en", cancellationToken).ConfigureAwait(false);
                        }
                    }
                }
            }

            return id;
        }
开发者ID:jscorrea,项目名称:MediaBrowser,代码行数:80,代码来源:MovieDbProvider.cs

示例9: GetAvailableRemoteImages

        /// <summary>
        /// Gets the available remote images.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <param name="providerName">Name of the provider.</param>
        /// <param name="type">The type.</param>
        /// <returns>Task{IEnumerable{RemoteImageInfo}}.</returns>
        public async Task<IEnumerable<RemoteImageInfo>> GetAvailableRemoteImages(BaseItem item, CancellationToken cancellationToken, string providerName = null, ImageType? type = null)
        {
            var providers = GetImageProviders(item);

            if (!string.IsNullOrEmpty(providerName))
            {
                providers = providers.Where(i => string.Equals(i.Name, providerName, StringComparison.OrdinalIgnoreCase));
            }

            var preferredLanguage = item.GetPreferredMetadataLanguage();

            var tasks = providers.Select(i => GetImages(item, cancellationToken, i, preferredLanguage, type));

            var results = await Task.WhenAll(tasks).ConfigureAwait(false);

            return results.SelectMany(i => i);
        }
开发者ID:jscorrea,项目名称:MediaBrowser,代码行数:25,代码来源:ProviderManager.cs


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