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


C# Series.ValidateChildren方法代码示例

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


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

示例1: Run

        public async Task Run(Series series, CancellationToken cancellationToken)
        {
            var tvdbId = series.GetProviderId(MetadataProviders.Tvdb);

            // Can't proceed without a tvdb id
            if (string.IsNullOrEmpty(tvdbId))
            {
                return;
            }

            var seriesDataPath = TvdbSeriesProvider.GetSeriesDataPath(_config.ApplicationPaths, tvdbId);

            var episodeFiles = Directory.EnumerateFiles(seriesDataPath, "*.xml", SearchOption.TopDirectoryOnly)
                .Select(Path.GetFileNameWithoutExtension)
                .Where(i => i.StartsWith("episode-", StringComparison.OrdinalIgnoreCase))
                .ToList();

            var episodeLookup = episodeFiles
                .Select(i =>
                {
                    var parts = i.Split('-');

                    if (parts.Length == 3)
                    {
                        int seasonNumber;

                        if (int.TryParse(parts[1], NumberStyles.Integer, UsCulture, out seasonNumber))
                        {
                            int episodeNumber;

                            if (int.TryParse(parts[2], NumberStyles.Integer, UsCulture, out episodeNumber))
                            {
                                return new Tuple<int, int>(seasonNumber, episodeNumber);
                            }
                        }
                    }

                    return new Tuple<int, int>(-1, -1);
                })
                .Where(i => i.Item1 != -1 && i.Item2 != -1)
                .ToList();

            var anySeasonsRemoved = await RemoveObsoleteOrMissingSeasons(series, episodeLookup, cancellationToken)
                .ConfigureAwait(false);

            var anyEpisodesRemoved = await RemoveObsoleteOrMissingEpisodes(series, episodeLookup, cancellationToken)
                .ConfigureAwait(false);

            var hasNewEpisodes = false;
            var hasNewSeasons = false;

            if (series.ContainsEpisodesWithoutSeasonFolders)
            {
                hasNewSeasons = await AddDummySeasonFolders(series, cancellationToken).ConfigureAwait(false);
            }

            if (_config.Configuration.EnableInternetProviders)
            {
                hasNewEpisodes = await AddMissingEpisodes(series, seriesDataPath, episodeLookup, cancellationToken)
                    .ConfigureAwait(false);
            }

            if (hasNewSeasons || hasNewEpisodes || anySeasonsRemoved || anyEpisodesRemoved)
            {
                await series.RefreshMetadata(cancellationToken, true)
                    .ConfigureAwait(false);

                await series.ValidateChildren(new Progress<double>(), cancellationToken, true)
                    .ConfigureAwait(false);
            }
        }
开发者ID:RomanDengin,项目名称:MediaBrowser,代码行数:71,代码来源:SeriesPostScanTask.cs


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