本文整理汇总了C#中MediaBrowser.Controller.Entities.TV.Series类的典型用法代码示例。如果您正苦于以下问题:C# Series类的具体用法?C# Series怎么用?C# Series使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Series类属于MediaBrowser.Controller.Entities.TV命名空间,在下文中一共展示了Series类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CleanupGenres
public static void CleanupGenres(Series series)
{
PluginConfiguration config = PluginConfiguration.Instance();
if (config.TidyGenreList)
{
series.Genres = RemoveRedundantGenres(series.Genres)
.Where(g => !"Animation".Equals(g) && !"Anime".Equals(g))
.Distinct()
.ToList();
TidyGenres(series);
}
if (config.MaxGenres > 0)
{
if (config.MoveExcessGenresToTags)
{
foreach (string genre in series.Genres.Skip(config.MaxGenres - 1))
{
if (!series.Tags.Contains(genre))
series.Tags.Add(genre);
}
}
series.Genres = series.Genres.Take(config.MaxGenres - 1).ToList();
}
if (!series.Genres.Contains("Anime"))
series.Genres.Add("Anime");
}
示例2: Convert
public static Series Convert(MazeSeries mazeSeries)
{
var series = new Series();
SetProviderIds(series, mazeSeries.externals, mazeSeries.id);
series.Name = mazeSeries.name;
series.Genres = mazeSeries.genres.ToList();
// TODO: Do we have a Series property for original language?
//series = mazeSeries.language;
if (mazeSeries.network != null && !string.IsNullOrWhiteSpace(mazeSeries.network.name))
{
var networkName = mazeSeries.network.name;
if (mazeSeries.network.country != null && !string.IsNullOrWhiteSpace(mazeSeries.network.country.code))
{
networkName = string.Format("{0} ({1})", mazeSeries.network.name, mazeSeries.network.country.code);
}
series.Studios.Add(networkName);
}
if (mazeSeries.premiered.HasValue)
{
series.PremiereDate = mazeSeries.premiered.Value;
series.ProductionYear = mazeSeries.premiered.Value.Year;
}
if (mazeSeries.rating != null && mazeSeries.rating.average.HasValue)
{
series.CommunityRating = (float)mazeSeries.rating.average.Value;
}
if (mazeSeries.runtime.HasValue)
{
series.RunTimeTicks = TimeSpan.FromMinutes(mazeSeries.runtime.Value).Ticks;
}
switch (mazeSeries.status.ToLower())
{
case "running":
series.Status = SeriesStatus.Continuing;
break;
case "ended":
series.Status = SeriesStatus.Ended;
break;
}
series.Overview = StripHtml(mazeSeries.summary);
series.HomePageUrl = mazeSeries.url.ToString();
return series;
}
示例3: GetImageFromSeriesData
private RemoteImageInfo GetImageFromSeriesData(Series series, string personName, CancellationToken cancellationToken)
{
var tvdbPath = TvdbSeriesProvider.GetSeriesDataPath(_config.ApplicationPaths, series.GetProviderId(MetadataProviders.Tvdb));
var actorXmlPath = Path.Combine(tvdbPath, "actors.xml");
try
{
return GetImageInfo(actorXmlPath, personName, cancellationToken);
}
catch (FileNotFoundException)
{
return null;
}
}
示例4: Run
public async Task Run(Series series, CancellationToken cancellationToken)
{
await RemoveObsoleteSeasons(series).ConfigureAwait(false);
var hasNewSeasons = await AddDummySeasonFolders(series, cancellationToken).ConfigureAwait(false);
if (hasNewSeasons)
{
var directoryService = new DirectoryService(_fileSystem);
//await series.RefreshMetadata(new MetadataRefreshOptions(directoryService), cancellationToken).ConfigureAwait(false);
//await series.ValidateChildren(new Progress<double>(), cancellationToken, new MetadataRefreshOptions(directoryService))
// .ConfigureAwait(false);
}
}
示例5: CleanupGenres
public static void CleanupGenres(Series series)
{
PluginConfiguration config = PluginConfiguration.Instance();
if (config.TidyGenreList)
{
series.Genres = RemoveRedundantGenres(series.Genres)
.Distinct()
.ToList();
TidyGenres(series);
}
var max = config.MaxGenres;
if (config.AddAnimeGenre)
{
series.Genres.Remove("Animation");
series.Genres.Remove("Anime");
max = Math.Max(max - 1, 0);
}
if (config.MaxGenres > 0)
{
if (config.MoveExcessGenresToTags)
{
foreach (string genre in series.Genres.Skip(max))
{
if (!series.Tags.Contains(genre))
series.Tags.Add(genre);
}
}
series.Genres = series.Genres.Take(max).ToList();
}
if (!series.Genres.Contains("Anime") && config.AddAnimeGenre)
{
if (series.Genres.Contains("Animation"))
series.Genres.Remove("Animation");
series.AddGenre("Anime");
}
series.Genres.Sort();
}
示例6: AddDummySeasonFolders
private async Task<bool> AddDummySeasonFolders(Series series, CancellationToken cancellationToken)
{
var episodesInSeriesFolder = series.GetRecursiveChildren()
.OfType<Episode>()
.Where(i => !i.IsInSeasonFolder)
.ToList();
var hasChanges = false;
// Loop through the unique season numbers
foreach (var seasonNumber in episodesInSeriesFolder.Select(i => i.ParentIndexNumber ?? -1)
.Where(i => i >= 0)
.Distinct()
.ToList())
{
var hasSeason = series.Children.OfType<Season>()
.Any(i => i.IndexNumber.HasValue && i.IndexNumber.Value == seasonNumber);
if (!hasSeason)
{
await AddSeason(series, seasonNumber, cancellationToken).ConfigureAwait(false);
hasChanges = true;
}
}
// Unknown season - create a dummy season to put these under
if (episodesInSeriesFolder.Any(i => !i.ParentIndexNumber.HasValue))
{
var hasSeason = series.Children.OfType<Season>()
.Any(i => !i.IndexNumber.HasValue);
if (!hasSeason)
{
await AddSeason(series, null, cancellationToken).ConfigureAwait(false);
hasChanges = true;
}
}
return hasChanges;
}
示例7: TestScrapePage
public async Task TestScrapePage()
{
var data = File.ReadAllText("TestData/anilist/9756.html", Encoding.UTF8);
var series = new Series();
AniListSeriesProvider.ParseTitle(series, data, "en");
AniListSeriesProvider.ParseSummary(series, data);
AniListSeriesProvider.ParseStudio(series, data);
AniListSeriesProvider.ParseRating(series, data);
AniListSeriesProvider.ParseGenres(series, data);
AniListSeriesProvider.ParseDuration(series, data);
AniListSeriesProvider.ParseAirDates(series, data);
Assert.That(series.Name, Is.EqualTo("Mahou Shoujo Madoka★Magica"));
Assert.That(series.Genres, Contains.Item("Drama"));
Assert.That(series.Genres, Contains.Item("Fantasy"));
Assert.That(series.Genres, Contains.Item("Psychological Thriller"));
Assert.That(series.Genres, Contains.Item("Thriller"));
Assert.That(series.PremiereDate, Is.EqualTo(new DateTime(2011, 1, 7)));
Assert.That(series.EndDate, Is.EqualTo(new DateTime(2011, 4, 22)));
}
示例8: DownloadImageFromSeries
/// <summary>
/// Downloads the image from series.
/// </summary>
/// <param name="item">The item.</param>
/// <param name="series">The series.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
private async Task DownloadImageFromSeries(BaseItem item, Series series, CancellationToken cancellationToken)
{
var tvdbPath = RemoteSeriesProvider.GetSeriesDataPath(ConfigurationManager.ApplicationPaths, series.GetProviderId(MetadataProviders.Tvdb));
var actorXmlPath = Path.Combine(tvdbPath, "actors.xml");
var xmlDoc = new XmlDocument();
xmlDoc.Load(actorXmlPath);
var actorNodes = xmlDoc.SelectNodes("//Actor");
if (actorNodes == null)
{
return;
}
foreach (var actorNode in actorNodes.OfType<XmlNode>())
{
var name = actorNode.SafeGetString("Name");
if (string.Equals(item.Name, name, StringComparison.OrdinalIgnoreCase))
{
var image = actorNode.SafeGetString("Image");
if (!string.IsNullOrEmpty(image))
{
var url = TVUtils.BannerUrl + image;
await _providerManager.SaveImage(item, url, RemoteSeriesProvider.Current.TvDbResourcePool,
ImageType.Primary, null, cancellationToken).ConfigureAwait(false);
}
break;
}
}
}
示例9: GetOtherDuplicatePaths
private List<string> GetOtherDuplicatePaths(string targetPath, Series series, int seasonNumber, int episodeNumber, int? endingEpisodeNumber)
{
var episodePaths = series.RecursiveChildren
.OfType<Episode>()
.Where(i =>
{
var locationType = i.LocationType;
// Must be file system based and match exactly
if (locationType != LocationType.Remote &&
locationType != LocationType.Virtual &&
i.ParentIndexNumber.HasValue &&
i.ParentIndexNumber.Value == seasonNumber &&
i.IndexNumber.HasValue &&
i.IndexNumber.Value == episodeNumber)
{
if (endingEpisodeNumber.HasValue || i.IndexNumberEnd.HasValue)
{
return endingEpisodeNumber.HasValue && i.IndexNumberEnd.HasValue &&
endingEpisodeNumber.Value == i.IndexNumberEnd.Value;
}
return true;
}
return false;
})
.Select(i => i.Path)
.ToList();
var folder = Path.GetDirectoryName(targetPath);
var targetFileNameWithoutExtension = Path.GetFileNameWithoutExtension(targetPath);
try
{
var filesOfOtherExtensions = Directory.EnumerateFiles(folder, "*", SearchOption.TopDirectoryOnly)
.Where(i => EntityResolutionHelper.IsVideoFile(i) && string.Equals(Path.GetFileNameWithoutExtension(i), targetFileNameWithoutExtension, StringComparison.OrdinalIgnoreCase));
episodePaths.AddRange(filesOfOtherExtensions);
}
catch (DirectoryNotFoundException)
{
// No big deal. Maybe the season folder doesn't already exist.
}
return episodePaths.Where(i => !string.Equals(i, targetPath, StringComparison.OrdinalIgnoreCase))
.Distinct(StringComparer.OrdinalIgnoreCase)
.ToList();
}
示例10: OrganizeEpisode
private async Task OrganizeEpisode(string sourcePath, Series series, int seasonNumber, int episodeNumber, int? endingEpiosdeNumber, TvFileOrganizationOptions options, bool overwriteExisting, FileOrganizationResult result, CancellationToken cancellationToken)
{
_logger.Info("Sorting file {0} into series {1}", sourcePath, series.Path);
// Proceed to sort the file
var newPath = await GetNewPath(sourcePath, series, seasonNumber, episodeNumber, endingEpiosdeNumber, options, cancellationToken).ConfigureAwait(false);
if (string.IsNullOrEmpty(newPath))
{
var msg = string.Format("Unable to sort {0} because target path could not be determined.", sourcePath);
result.Status = FileSortingStatus.Failure;
result.StatusMessage = msg;
_logger.Warn(msg);
return;
}
_logger.Info("Sorting file {0} to new path {1}", sourcePath, newPath);
result.TargetPath = newPath;
var fileExists = File.Exists(result.TargetPath);
var otherDuplicatePaths = GetOtherDuplicatePaths(result.TargetPath, series, seasonNumber, episodeNumber, endingEpiosdeNumber);
if (!overwriteExisting)
{
if (fileExists || otherDuplicatePaths.Count > 0)
{
result.Status = FileSortingStatus.SkippedExisting;
result.StatusMessage = string.Empty;
result.DuplicatePaths = otherDuplicatePaths;
return;
}
if (options.CopyOriginalFile && fileExists && IsSameEpisode(sourcePath, newPath))
{
_logger.Info("File {0} already copied to new path {1}, stopping organization", sourcePath, newPath);
result.Status = FileSortingStatus.SkippedExisting;
result.StatusMessage = string.Empty;
return;
}
}
PerformFileSorting(options, result);
if (overwriteExisting)
{
foreach (var path in otherDuplicatePaths)
{
_logger.Debug("Removing duplicate episode {0}", path);
_libraryMonitor.ReportFileSystemChangeBeginning(path);
try
{
File.Delete(path);
}
catch (IOException ex)
{
_logger.ErrorException("Error removing duplicate episode", ex, path);
}
finally
{
_libraryMonitor.ReportFileSystemChangeComplete(path, true);
}
}
}
}
示例11: AddEpisode
/// <summary>
/// Adds the episode.
/// </summary>
/// <param name="series">The series.</param>
/// <param name="seasonNumber">The season number.</param>
/// <param name="episodeNumber">The episode number.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
private async Task AddEpisode(Series series, int seasonNumber, int episodeNumber, CancellationToken cancellationToken)
{
var season = series.Children.OfType<Season>()
.FirstOrDefault(i => i.IndexNumber.HasValue && i.IndexNumber.Value == seasonNumber);
if (season == null)
{
season = await AddSeason(series, seasonNumber, cancellationToken).ConfigureAwait(false);
}
var name = string.Format("Episode {0}", episodeNumber.ToString(UsCulture));
var episode = new Episode
{
Name = name,
IndexNumber = episodeNumber,
ParentIndexNumber = seasonNumber,
Parent = season,
DisplayMediaType = typeof(Episode).Name,
Id = (series.Id + seasonNumber.ToString(UsCulture) + name).GetMBId(typeof(Episode))
};
await season.AddChild(episode, cancellationToken).ConfigureAwait(false);
await episode.RefreshMetadata(new MetadataRefreshOptions
{
}, cancellationToken).ConfigureAwait(false);
}
示例12: SaveSmartMatchString
private void SaveSmartMatchString(string matchString, Series series, AutoOrganizeOptions options)
{
if (string.IsNullOrEmpty(matchString) || matchString.Length < 3)
{
return;
}
SmartMatchInfo info = options.SmartMatchInfos.FirstOrDefault(i => string.Equals(i.ItemName, series.Name, StringComparison.OrdinalIgnoreCase));
if (info == null)
{
info = new SmartMatchInfo();
info.ItemName = series.Name;
info.OrganizerType = FileOrganizerType.Episode;
info.DisplayName = series.Name;
var list = options.SmartMatchInfos.ToList();
list.Add(info);
options.SmartMatchInfos = list.ToArray();
}
if (!info.MatchStrings.Contains(matchString, StringComparer.OrdinalIgnoreCase))
{
var list = info.MatchStrings.ToList();
list.Add(matchString);
info.MatchStrings = list.ToArray();
_config.SaveAutoOrganizeOptions(options);
}
}
示例13: GetNewPath
/// <summary>
/// Gets the new path.
/// </summary>
/// <param name="sourcePath">The source path.</param>
/// <param name="series">The series.</param>
/// <param name="seasonNumber">The season number.</param>
/// <param name="episodeNumber">The episode number.</param>
/// <param name="endingEpisodeNumber">The ending episode number.</param>
/// <param name="premiereDate">The premiere date.</param>
/// <param name="options">The options.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>System.String.</returns>
private async Task<string> GetNewPath(string sourcePath,
Series series,
int? seasonNumber,
int? episodeNumber,
int? endingEpisodeNumber,
DateTime? premiereDate,
TvFileOrganizationOptions options,
CancellationToken cancellationToken)
{
var episodeInfo = new EpisodeInfo
{
IndexNumber = episodeNumber,
IndexNumberEnd = endingEpisodeNumber,
MetadataCountryCode = series.GetPreferredMetadataCountryCode(),
MetadataLanguage = series.GetPreferredMetadataLanguage(),
ParentIndexNumber = seasonNumber,
SeriesProviderIds = series.ProviderIds,
PremiereDate = premiereDate
};
var searchResults = await _providerManager.GetRemoteSearchResults<Episode, EpisodeInfo>(new RemoteSearchQuery<EpisodeInfo>
{
SearchInfo = episodeInfo
}, cancellationToken).ConfigureAwait(false);
var episode = searchResults.FirstOrDefault();
if (episode == null)
{
var msg = string.Format("No provider metadata found for {0} season {1} episode {2}", series.Name, seasonNumber, episodeNumber);
_logger.Warn(msg);
return null;
}
var episodeName = episode.Name;
//if (string.IsNullOrWhiteSpace(episodeName))
//{
// var msg = string.Format("No provider metadata found for {0} season {1} episode {2}", series.Name, seasonNumber, episodeNumber);
// _logger.Warn(msg);
// return null;
//}
seasonNumber = seasonNumber ?? episode.ParentIndexNumber;
episodeNumber = episodeNumber ?? episode.IndexNumber;
var newPath = GetSeasonFolderPath(series, seasonNumber.Value, options);
// MAX_PATH - trailing <NULL> charachter - drive component: 260 - 1 - 3 = 256
// Usually newPath would include the drive component, but use 256 to be sure
var maxFilenameLength = 256 - newPath.Length;
if (!newPath.EndsWith(@"\"))
{
// Remove 1 for missing backslash combining path and filename
maxFilenameLength--;
}
// Remove additional 4 chars to prevent PathTooLongException for downloaded subtitles (eg. filename.ext.eng.srt)
maxFilenameLength -= 4;
var episodeFileName = GetEpisodeFileName(sourcePath, series.Name, seasonNumber.Value, episodeNumber.Value, endingEpisodeNumber, episodeName, options, maxFilenameLength);
if (string.IsNullOrEmpty(episodeFileName))
{
// cause failure
return string.Empty;
}
newPath = Path.Combine(newPath, episodeFileName);
return newPath;
}
示例14: OrganizeWithCorrection
public async Task<FileOrganizationResult> OrganizeWithCorrection(EpisodeFileOrganizationRequest request, AutoOrganizeOptions options, CancellationToken cancellationToken)
{
var result = _organizationService.GetResult(request.ResultId);
Series series = null;
if (request.NewSeriesProviderIds.Count > 0)
{
// We're having a new series here
SeriesInfo seriesRequest = new SeriesInfo();
seriesRequest.ProviderIds = request.NewSeriesProviderIds;
var refreshOptions = new MetadataRefreshOptions(_fileSystem);
series = new Series();
series.Id = Guid.NewGuid();
series.Name = request.NewSeriesName;
int year;
if (int.TryParse(request.NewSeriesYear, out year))
{
series.ProductionYear = year;
}
var seriesFolderName = series.Name;
if (series.ProductionYear.HasValue)
{
seriesFolderName = string.Format("{0} ({1})", seriesFolderName, series.ProductionYear);
}
series.Path = Path.Combine(request.TargetFolder, seriesFolderName);
series.ProviderIds = request.NewSeriesProviderIds;
await series.RefreshMetadata(refreshOptions, cancellationToken);
}
if (series == null)
{
// Existing Series
series = (Series)_libraryManager.GetItemById(new Guid(request.SeriesId));
}
await OrganizeEpisode(result.OriginalPath,
series,
request.SeasonNumber,
request.EpisodeNumber,
request.EndingEpisodeNumber,
null,
options,
true,
request.RememberCorrection,
result,
cancellationToken).ConfigureAwait(false);
await _organizationService.SaveResult(result, CancellationToken.None).ConfigureAwait(false);
return result;
}
示例15: SendLibraryUpdateAsync
/// <summary>
/// Add or remove a Show(Series) to/from the users trakt.tv library
/// </summary>
/// <param name="show">The show to remove</param>
/// <param name="traktUser">The user who's library is being updated</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <param name="eventType"></param>
/// <returns>Task{TraktResponseDataContract}.</returns>
public async Task<TraktSyncResponse> SendLibraryUpdateAsync(Series show, TraktUser traktUser, CancellationToken cancellationToken, EventType eventType)
{
if (show == null)
throw new ArgumentNullException("show");
if (traktUser == null)
throw new ArgumentNullException("traktUser");
if (eventType == EventType.Update) return null;
var showPayload = new List<TraktShowCollected>
{
new TraktShowCollected
{
Title = show.Name,
Year = show.ProductionYear,
Ids = new TraktShowId
{
Tvdb = show.GetProviderId(MetadataProviders.Tvdb).ConvertToInt(),
Imdb = show.GetProviderId(MetadataProviders.Imdb),
TvRage = show.GetProviderId(MetadataProviders.TvRage).ConvertToInt()
},
}
};
var data = new TraktSyncCollected
{
Shows = showPayload.ToList()
};
var url = eventType == EventType.Add ? TraktUris.SyncCollectionAdd : TraktUris.SyncCollectionRemove;
var response = await PostToTrakt(url, data, cancellationToken, traktUser);
return _jsonSerializer.DeserializeFromStream<TraktSyncResponse>(response);
}