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


C# BaseItem.AddGenre方法代码示例

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


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

示例1: ProcessMainInfo


//.........这里部分代码省略.........
                        if (usRelease.release_date.Year != 1)
                        {
                            movie.PremiereDate = usRelease.release_date.ToUniversalTime();
                            movie.ProductionYear = usRelease.release_date.Year;
                        }
                    }
                    else if (minimunRelease.release_date != default(DateTime))
                    {
                        if (minimunRelease.release_date.Year != 1)
                        {

                            movie.PremiereDate = minimunRelease.release_date.ToUniversalTime();
                            movie.ProductionYear = minimunRelease.release_date.Year;
                        }
                    }
                }
                else
                {
                    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)
                {
                    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;
                }

                if (movieData.runtime > 0)
                    movie.OriginalRunTimeTicks = TimeSpan.FromMinutes(movieData.runtime).Ticks;

                //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
                if (movieData.genres != null && !movie.LockedFields.Contains(MetadataFields.Genres))
                {
                    movie.Genres.Clear();

                    foreach (var genre in movieData.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 });
                    }

                    //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.Tags))
                {
                    movie.Tags = movieData.keywords.keywords.Select(i => i.name).ToList();
                }

                if (movieData.trailers != null && movieData.trailers.youtube != null &&
                    movieData.trailers.youtube.Count > 0)
                {
                    movie.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:rrb008,项目名称:MediaBrowser,代码行数:101,代码来源:MovieDbProvider.cs

示例2: 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

示例3: ParseAdditionalMetadata

        private void ParseAdditionalMetadata(BaseItem item, RootObject result)
        {
            // Grab series genres because imdb data is better than tvdb. Leave movies alone
            // But only do it if english is the preferred language because this data will not be localized
            if (ShouldFetchGenres(item) &&
                !string.IsNullOrWhiteSpace(result.Genre) &&
                !string.Equals(result.Genre, "n/a", StringComparison.OrdinalIgnoreCase))
            {
                item.Genres.Clear();

                foreach (var genre in result.Genre
                    .Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
                    .Select(i => i.Trim())
                    .Where(i => !string.IsNullOrWhiteSpace(i)))
                {
                    item.AddGenre(genre);
                }
            }

            var hasMetascore = item as IHasMetascore;
            if (hasMetascore != null)
            {
                float metascore;

                if (!string.IsNullOrEmpty(result.Metascore) && float.TryParse(result.Metascore, NumberStyles.Any, _usCulture, out metascore) && metascore >= 0)
                {
                    hasMetascore.Metascore = metascore;
                }
            }

            var hasAwards = item as IHasAwards;
            if (hasAwards != null && !string.IsNullOrEmpty(result.Awards) &&
                !string.Equals(result.Awards, "n/a", StringComparison.OrdinalIgnoreCase))
            {
                hasAwards.AwardSummary = WebUtility.HtmlDecode(result.Awards);
            }

            var hasShortOverview = item as IHasShortOverview;
            if (hasShortOverview != null)
            {
                // Imdb plots are usually pretty short
                hasShortOverview.ShortOverview = result.Plot;
            }
        }
开发者ID:redteamcpu,项目名称:Emby,代码行数:44,代码来源:OmdbProvider.cs

示例4: ParseAdditionalMetadata

        private void ParseAdditionalMetadata(BaseItem item, RootObject result)
        {
            // Grab series genres because imdb data is better than tvdb. Leave movies alone
            // But only do it if english is the preferred language because this data will not be localized
            if (!item.LockedFields.Contains(MetadataFields.Genres) &&
                item is Series &&
                !string.IsNullOrWhiteSpace(result.Genre) &&
                !string.Equals(result.Genre, "n/a", StringComparison.OrdinalIgnoreCase)
                && string.Equals(ConfigurationManager.Configuration.PreferredMetadataLanguage, "en"))
            {
                item.Genres.Clear();

                foreach (var genre in result.Genre
                    .Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
                    .Select(i => i.Trim())
                    .Where(i => !string.IsNullOrWhiteSpace(i)))
                {
                    item.AddGenre(genre);
                }
            }
        }
开发者ID:Kampari,项目名称:MediaBrowser,代码行数:21,代码来源:OpenMovieDatabaseProvider.cs


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