本文整理汇总了C#中MediaBrowser.Controller.Entities.TV.Series.AddGenre方法的典型用法代码示例。如果您正苦于以下问题:C# Series.AddGenre方法的具体用法?C# Series.AddGenre怎么用?C# Series.AddGenre使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MediaBrowser.Controller.Entities.TV.Series
的用法示例。
在下文中一共展示了Series.AddGenre方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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();
}
示例2: FetchDataFromSeriesNode
//.........这里部分代码省略.........
if (!string.IsNullOrWhiteSpace(val))
{
DateTime date;
if (DateTime.TryParse(val, out date))
{
date = date.ToUniversalTime();
item.PremiereDate = date;
item.ProductionYear = date.Year;
}
}
break;
}
case "Runtime":
{
var val = reader.ReadElementContentAsString();
if (!string.IsNullOrWhiteSpace(val) && !item.LockedFields.Contains(MetadataFields.Runtime))
{
int rval;
// int.TryParse is local aware, so it can be probamatic, force us culture
if (int.TryParse(val, NumberStyles.Integer, UsCulture, out rval))
{
item.RunTimeTicks = TimeSpan.FromMinutes(rval).Ticks;
}
}
break;
}
case "Genre":
{
var val = reader.ReadElementContentAsString();
if (!string.IsNullOrWhiteSpace(val))
{
// Only fill this in if there's no existing genres, because Imdb data from Omdb is preferred
if (!item.LockedFields.Contains(MetadataFields.Genres) && (item.Genres.Count == 0 || !string.Equals(item.GetPreferredMetadataLanguage(), "en", StringComparison.OrdinalIgnoreCase)))
{
var vals = val
.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries)
.Select(i => i.Trim())
.Where(i => !string.IsNullOrWhiteSpace(i))
.ToList();
if (vals.Count > 0)
{
item.Genres.Clear();
foreach (var genre in vals)
{
item.AddGenre(genre);
}
}
}
}
break;
}
case "Network":
{
var val = reader.ReadElementContentAsString();
if (!string.IsNullOrWhiteSpace(val))
{
if (!item.LockedFields.Contains(MetadataFields.Studios))
{
var vals = val
.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries)
.Select(i => i.Trim())
.Where(i => !string.IsNullOrWhiteSpace(i))
.ToList();
if (vals.Count > 0)
{
item.Studios.Clear();
foreach (var genre in vals)
{
item.AddStudio(genre);
}
}
}
}
break;
}
default:
reader.Skip();
break;
}
}
}
}
示例3: FetchMainInfo
/// <summary>
/// Fetches the main info.
/// </summary>
/// <param name="series">The series.</param>
/// <param name="doc">The doc.</param>
private void FetchMainInfo(Series series, XmlDocument doc)
{
if (!series.LockedFields.Contains(MetadataFields.Name))
{
series.Name = doc.SafeGetString("//SeriesName");
}
if (!series.LockedFields.Contains(MetadataFields.Overview))
{
series.Overview = doc.SafeGetString("//Overview");
}
series.CommunityRating = doc.SafeGetSingle("//Rating", 0, 10);
series.AirDays = TVUtils.GetAirDays(doc.SafeGetString("//Airs_DayOfWeek"));
series.AirTime = doc.SafeGetString("//Airs_Time");
SeriesStatus seriesStatus;
if(Enum.TryParse(doc.SafeGetString("//Status"), true, out seriesStatus))
series.Status = seriesStatus;
series.PremiereDate = doc.SafeGetDateTime("//FirstAired");
if (series.PremiereDate.HasValue)
series.ProductionYear = series.PremiereDate.Value.Year;
series.RunTimeTicks = TimeSpan.FromMinutes(doc.SafeGetInt32("//Runtime")).Ticks;
if (!series.LockedFields.Contains(MetadataFields.Studios))
{
string s = doc.SafeGetString("//Network");
if (!string.IsNullOrWhiteSpace(s))
{
series.Studios.Clear();
foreach (var studio in s.Trim().Split('|'))
{
series.AddStudio(studio);
}
}
}
series.OfficialRating = doc.SafeGetString("//ContentRating");
if (!series.LockedFields.Contains(MetadataFields.Genres))
{
string g = doc.SafeGetString("//Genre");
if (g != null)
{
string[] genres = g.Trim('|').Split('|');
if (g.Length > 0)
{
series.Genres.Clear();
foreach (var genre in genres)
{
series.AddGenre(genre);
}
}
}
}
if (series.Status == SeriesStatus.Ended) {
var document = XDocument.Load(new XmlNodeReader(doc));
var dates = document.Descendants("Episode").Where(x => {
var seasonNumber = x.Element("SeasonNumber");
var firstAired = x.Element("FirstAired");
return firstAired != null && seasonNumber != null && (!string.IsNullOrEmpty(seasonNumber.Value) && seasonNumber.Value != "0") && !string.IsNullOrEmpty(firstAired.Value);
}).Select(x => {
DateTime? date = null;
DateTime tempDate;
var firstAired = x.Element("FirstAired");
if (firstAired != null && DateTime.TryParse(firstAired.Value, out tempDate))
{
date = tempDate;
}
return date;
}).ToList();
if(dates.Any(x=>x.HasValue))
series.EndDate = dates.Where(x => x.HasValue).Max();
}
}