本文整理汇总了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);
}
}