2012-07-12 08:55:27 +02:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
2012-08-19 22:38:31 +02:00
|
|
|
|
using System.Threading.Tasks;
|
2012-07-12 08:55:27 +02:00
|
|
|
|
using System.Xml;
|
|
|
|
|
using MediaBrowser.Model.Entities;
|
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Controller.Xml
|
|
|
|
|
{
|
2012-07-20 04:22:44 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Provides a base class for parsing metadata xml
|
|
|
|
|
/// </summary>
|
2012-08-15 15:20:29 +02:00
|
|
|
|
public class BaseItemXmlParser<T>
|
2012-07-12 08:55:27 +02:00
|
|
|
|
where T : BaseItem, new()
|
|
|
|
|
{
|
2012-07-20 04:22:44 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Fetches metadata for an item from one xml file
|
|
|
|
|
/// </summary>
|
2012-08-20 02:15:03 +02:00
|
|
|
|
public async Task Fetch(T item, string metadataFile)
|
2012-07-12 08:55:27 +02:00
|
|
|
|
{
|
2012-08-20 02:15:03 +02:00
|
|
|
|
// Use XmlReader for best performance
|
|
|
|
|
using (XmlReader reader = XmlReader.Create(metadataFile, new XmlReaderSettings() { Async = true }))
|
2012-07-12 08:55:27 +02:00
|
|
|
|
{
|
2012-08-20 02:15:03 +02:00
|
|
|
|
await reader.MoveToContentAsync();
|
2012-08-19 18:54:41 +02:00
|
|
|
|
|
2012-08-20 02:15:03 +02:00
|
|
|
|
// Loop through each element
|
|
|
|
|
while (await reader.ReadAsync())
|
|
|
|
|
{
|
|
|
|
|
if (reader.NodeType == XmlNodeType.Element)
|
2012-07-14 22:45:11 +02:00
|
|
|
|
{
|
2012-08-20 17:55:05 +02:00
|
|
|
|
await FetchDataFromXmlNode(reader, item);
|
2012-07-14 22:45:11 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2012-08-20 02:15:03 +02:00
|
|
|
|
}
|
2012-07-12 08:55:27 +02:00
|
|
|
|
|
2012-08-20 02:15:03 +02:00
|
|
|
|
// If dates weren't supplied in metadata, use values from the xml file
|
|
|
|
|
if (item.DateCreated == DateTime.MinValue)
|
|
|
|
|
{
|
|
|
|
|
item.DateCreated = File.GetCreationTime(metadataFile);
|
|
|
|
|
}
|
2012-07-12 08:55:27 +02:00
|
|
|
|
|
2012-08-20 02:15:03 +02:00
|
|
|
|
if (item.DateModified == DateTime.MinValue)
|
|
|
|
|
{
|
|
|
|
|
item.DateModified = File.GetLastWriteTime(metadataFile);
|
|
|
|
|
}
|
2012-07-12 08:55:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
2012-07-20 04:22:44 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Fetches metadata from one Xml Element
|
|
|
|
|
/// </summary>
|
2012-08-20 17:55:05 +02:00
|
|
|
|
protected async virtual Task FetchDataFromXmlNode(XmlReader reader, T item)
|
2012-07-12 08:55:27 +02:00
|
|
|
|
{
|
2012-07-14 22:45:11 +02:00
|
|
|
|
switch (reader.Name)
|
2012-07-12 08:55:27 +02:00
|
|
|
|
{
|
2012-07-20 04:22:44 +02:00
|
|
|
|
// DateCreated
|
2012-07-12 08:55:27 +02:00
|
|
|
|
case "Added":
|
|
|
|
|
DateTime added;
|
2012-08-20 17:55:05 +02:00
|
|
|
|
if (DateTime.TryParse(await reader.ReadElementContentAsStringAsync() ?? string.Empty, out added))
|
2012-07-12 08:55:27 +02:00
|
|
|
|
{
|
|
|
|
|
item.DateCreated = added;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
2012-07-20 04:22:44 +02:00
|
|
|
|
// DisplayMediaType
|
2012-07-12 08:55:27 +02:00
|
|
|
|
case "Type":
|
|
|
|
|
{
|
2012-08-20 17:55:05 +02:00
|
|
|
|
item.DisplayMediaType = await reader.ReadElementContentAsStringAsync();
|
2012-07-12 08:55:27 +02:00
|
|
|
|
|
|
|
|
|
switch (item.DisplayMediaType.ToLower())
|
|
|
|
|
{
|
|
|
|
|
case "blu-ray":
|
|
|
|
|
item.DisplayMediaType = VideoType.BluRay.ToString();
|
|
|
|
|
break;
|
|
|
|
|
case "dvd":
|
|
|
|
|
item.DisplayMediaType = VideoType.DVD.ToString();
|
|
|
|
|
break;
|
|
|
|
|
case "":
|
|
|
|
|
item.DisplayMediaType = null;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2012-07-20 04:22:44 +02:00
|
|
|
|
// TODO: Do we still need this?
|
2012-07-12 08:55:27 +02:00
|
|
|
|
case "banner":
|
2012-08-20 17:55:05 +02:00
|
|
|
|
item.BannerImagePath = await reader.ReadElementContentAsStringAsync();
|
2012-07-12 08:55:27 +02:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "LocalTitle":
|
2012-08-20 17:55:05 +02:00
|
|
|
|
item.Name = await reader.ReadElementContentAsStringAsync();
|
2012-07-12 08:55:27 +02:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "SortTitle":
|
2012-08-20 17:55:05 +02:00
|
|
|
|
item.SortName = await reader.ReadElementContentAsStringAsync();
|
2012-07-12 08:55:27 +02:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "Overview":
|
|
|
|
|
case "Description":
|
2012-08-20 17:55:05 +02:00
|
|
|
|
item.Overview = await reader.ReadElementContentAsStringAsync();
|
2012-07-12 08:55:27 +02:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "TagLine":
|
2012-08-18 10:22:54 +02:00
|
|
|
|
{
|
|
|
|
|
var list = (item.Taglines ?? new string[] { }).ToList();
|
2012-08-20 17:55:05 +02:00
|
|
|
|
var tagline = await reader.ReadElementContentAsStringAsync();
|
2012-08-18 10:22:54 +02:00
|
|
|
|
|
|
|
|
|
if (!list.Contains(tagline))
|
|
|
|
|
{
|
|
|
|
|
list.Add(tagline);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
item.Taglines = list;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case "TagLines":
|
|
|
|
|
{
|
2012-08-20 17:55:05 +02:00
|
|
|
|
await FetchFromTaglinesNode(reader.ReadSubtree(), item);
|
2012-08-18 10:22:54 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
2012-07-12 08:55:27 +02:00
|
|
|
|
|
|
|
|
|
case "ContentRating":
|
|
|
|
|
case "MPAARating":
|
2012-08-20 17:55:05 +02:00
|
|
|
|
item.OfficialRating = await reader.ReadElementContentAsStringAsync();
|
2012-07-12 08:55:27 +02:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "CustomRating":
|
2012-08-20 17:55:05 +02:00
|
|
|
|
item.CustomRating = await reader.ReadElementContentAsStringAsync();
|
2012-07-12 08:55:27 +02:00
|
|
|
|
break;
|
|
|
|
|
|
2012-08-18 16:31:48 +02:00
|
|
|
|
case "Runtime":
|
|
|
|
|
case "RunningTime":
|
|
|
|
|
{
|
2012-08-20 17:55:05 +02:00
|
|
|
|
string text = await reader.ReadElementContentAsStringAsync();
|
2012-08-18 16:31:48 +02:00
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(text))
|
|
|
|
|
{
|
|
|
|
|
int runtime;
|
|
|
|
|
if (int.TryParse(text.Split(' ')[0], out runtime))
|
|
|
|
|
{
|
|
|
|
|
item.RunTimeTicks = TimeSpan.FromMinutes(runtime).Ticks;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2012-07-12 08:55:27 +02:00
|
|
|
|
case "Genre":
|
|
|
|
|
{
|
|
|
|
|
var genres = (item.Genres ?? new string[] { }).ToList();
|
2012-08-20 17:55:05 +02:00
|
|
|
|
genres.AddRange(GetSplitValues(await reader.ReadElementContentAsStringAsync(), '|'));
|
2012-07-12 08:55:27 +02:00
|
|
|
|
|
|
|
|
|
item.Genres = genres;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case "AspectRatio":
|
2012-08-20 17:55:05 +02:00
|
|
|
|
item.AspectRatio = await reader.ReadElementContentAsStringAsync();
|
2012-07-12 08:55:27 +02:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "Network":
|
|
|
|
|
{
|
|
|
|
|
var studios = (item.Studios ?? new string[] { }).ToList();
|
2012-08-20 17:55:05 +02:00
|
|
|
|
studios.AddRange(GetSplitValues(await reader.ReadElementContentAsStringAsync(), '|'));
|
2012-07-12 08:55:27 +02:00
|
|
|
|
|
|
|
|
|
item.Studios = studios;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case "Director":
|
|
|
|
|
{
|
2012-07-14 22:45:11 +02:00
|
|
|
|
var list = (item.People ?? new PersonInfo[] { }).ToList();
|
2012-08-20 17:55:05 +02:00
|
|
|
|
list.AddRange(GetSplitValues(await reader.ReadElementContentAsStringAsync(), '|').Select(v => new PersonInfo() { Name = v, Type = "Director" }));
|
2012-07-12 08:55:27 +02:00
|
|
|
|
|
|
|
|
|
item.People = list;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case "Writer":
|
|
|
|
|
{
|
2012-07-12 19:09:35 +02:00
|
|
|
|
var list = (item.People ?? new PersonInfo[] { }).ToList();
|
2012-08-20 17:55:05 +02:00
|
|
|
|
list.AddRange(GetSplitValues(await reader.ReadElementContentAsStringAsync(), '|').Select(v => new PersonInfo() { Name = v, Type = "Writer" }));
|
2012-07-12 08:55:27 +02:00
|
|
|
|
|
|
|
|
|
item.People = list;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case "Actors":
|
|
|
|
|
case "GuestStars":
|
|
|
|
|
{
|
2012-07-12 19:09:35 +02:00
|
|
|
|
var list = (item.People ?? new PersonInfo[] { }).ToList();
|
2012-08-20 17:55:05 +02:00
|
|
|
|
list.AddRange(GetSplitValues(await reader.ReadElementContentAsStringAsync(), '|').Select(v => new PersonInfo() { Name = v, Type = "Actor" }));
|
2012-07-12 08:55:27 +02:00
|
|
|
|
|
|
|
|
|
item.People = list;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case "Trailer":
|
2012-08-20 17:55:05 +02:00
|
|
|
|
item.TrailerUrl = await reader.ReadElementContentAsStringAsync();
|
2012-07-12 08:55:27 +02:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "ProductionYear":
|
|
|
|
|
{
|
2012-08-20 17:55:05 +02:00
|
|
|
|
string val = await reader.ReadElementContentAsStringAsync();
|
2012-08-18 16:31:48 +02:00
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(val))
|
2012-07-12 08:55:27 +02:00
|
|
|
|
{
|
2012-08-18 16:31:48 +02:00
|
|
|
|
int ProductionYear;
|
|
|
|
|
if (int.TryParse(val, out ProductionYear) && ProductionYear > 1850)
|
|
|
|
|
{
|
|
|
|
|
item.ProductionYear = ProductionYear;
|
|
|
|
|
}
|
2012-07-12 08:55:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2012-07-14 22:45:11 +02:00
|
|
|
|
case "Rating":
|
|
|
|
|
case "IMDBrating":
|
|
|
|
|
|
2012-08-20 17:55:05 +02:00
|
|
|
|
string rating = await reader.ReadElementContentAsStringAsync();
|
2012-07-14 22:45:11 +02:00
|
|
|
|
|
2012-07-20 04:22:44 +02:00
|
|
|
|
if (!string.IsNullOrWhiteSpace(rating))
|
2012-07-14 22:45:11 +02:00
|
|
|
|
{
|
|
|
|
|
float val;
|
|
|
|
|
|
|
|
|
|
if (float.TryParse(rating, out val))
|
|
|
|
|
{
|
|
|
|
|
item.UserRating = val;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
2012-08-04 15:33:23 +02:00
|
|
|
|
case "FirstAired":
|
|
|
|
|
{
|
2012-08-20 17:55:05 +02:00
|
|
|
|
string firstAired = await reader.ReadElementContentAsStringAsync();
|
2012-08-04 15:33:23 +02:00
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(firstAired))
|
|
|
|
|
{
|
|
|
|
|
DateTime airDate;
|
|
|
|
|
|
|
|
|
|
if (DateTime.TryParse(firstAired, out airDate) && airDate.Year > 1850)
|
|
|
|
|
{
|
|
|
|
|
item.PremiereDate = airDate;
|
|
|
|
|
item.ProductionYear = airDate.Year;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-15 15:20:29 +02:00
|
|
|
|
case "TMDbId":
|
2012-08-20 17:55:05 +02:00
|
|
|
|
string tmdb = await reader.ReadElementContentAsStringAsync();
|
2012-08-15 15:20:29 +02:00
|
|
|
|
if (!string.IsNullOrWhiteSpace(tmdb))
|
|
|
|
|
{
|
|
|
|
|
item.SetProviderId(MetadataProviders.Tmdb, tmdb);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "TVcomId":
|
2012-08-20 17:55:05 +02:00
|
|
|
|
string TVcomId = await reader.ReadElementContentAsStringAsync();
|
2012-08-15 15:20:29 +02:00
|
|
|
|
if (!string.IsNullOrWhiteSpace(TVcomId))
|
|
|
|
|
{
|
|
|
|
|
item.SetProviderId(MetadataProviders.Tvcom, TVcomId);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "IMDB_ID":
|
|
|
|
|
case "IMDB":
|
|
|
|
|
case "IMDbId":
|
2012-08-20 17:55:05 +02:00
|
|
|
|
string IMDbId = await reader.ReadElementContentAsStringAsync();
|
2012-08-15 15:20:29 +02:00
|
|
|
|
if (!string.IsNullOrWhiteSpace(IMDbId))
|
|
|
|
|
{
|
|
|
|
|
item.SetProviderId(MetadataProviders.Imdb, IMDbId);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
2012-07-14 22:45:11 +02:00
|
|
|
|
case "Genres":
|
2012-08-20 17:55:05 +02:00
|
|
|
|
await FetchFromGenresNode(reader.ReadSubtree(), item);
|
2012-07-14 22:45:11 +02:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "Persons":
|
2012-08-20 17:55:05 +02:00
|
|
|
|
await FetchDataFromPersonsNode(reader.ReadSubtree(), item);
|
2012-07-14 22:45:11 +02:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "ParentalRating":
|
2012-08-20 17:55:05 +02:00
|
|
|
|
await FetchFromParentalRatingNode(reader.ReadSubtree(), item);
|
2012-07-14 22:45:11 +02:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "Studios":
|
2012-08-20 17:55:05 +02:00
|
|
|
|
await FetchFromStudiosNode(reader.ReadSubtree(), item);
|
2012-07-14 22:45:11 +02:00
|
|
|
|
break;
|
|
|
|
|
|
2012-07-12 08:55:27 +02:00
|
|
|
|
case "MediaInfo":
|
2012-08-20 17:55:05 +02:00
|
|
|
|
{
|
|
|
|
|
var video = item as Video;
|
|
|
|
|
|
|
|
|
|
if (video != null)
|
|
|
|
|
{
|
|
|
|
|
await FetchMediaInfo(reader.ReadSubtree(), video);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
2012-07-12 08:55:27 +02:00
|
|
|
|
|
|
|
|
|
default:
|
2012-08-20 17:55:05 +02:00
|
|
|
|
await reader.SkipAsync();
|
2012-07-12 08:55:27 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-20 17:55:05 +02:00
|
|
|
|
private async Task FetchMediaInfo(XmlReader reader, Video item)
|
2012-07-12 08:55:27 +02:00
|
|
|
|
{
|
2012-08-20 17:55:05 +02:00
|
|
|
|
await reader.MoveToContentAsync();
|
2012-07-12 08:55:27 +02:00
|
|
|
|
|
2012-08-20 17:55:05 +02:00
|
|
|
|
while (await reader.ReadAsync())
|
2012-07-12 08:55:27 +02:00
|
|
|
|
{
|
2012-07-14 22:45:11 +02:00
|
|
|
|
if (reader.NodeType == XmlNodeType.Element)
|
2012-07-12 08:55:27 +02:00
|
|
|
|
{
|
2012-07-14 22:45:11 +02:00
|
|
|
|
switch (reader.Name)
|
|
|
|
|
{
|
|
|
|
|
case "Audio":
|
|
|
|
|
{
|
2012-08-20 17:55:05 +02:00
|
|
|
|
AudioStream stream = await FetchMediaInfoAudio(reader.ReadSubtree());
|
2012-07-12 08:55:27 +02:00
|
|
|
|
|
2012-08-18 10:22:54 +02:00
|
|
|
|
List<AudioStream> streams = (item.AudioStreams ?? new AudioStream[] { }).ToList();
|
2012-07-14 22:45:11 +02:00
|
|
|
|
streams.Add(stream);
|
|
|
|
|
item.AudioStreams = streams;
|
2012-07-12 08:55:27 +02:00
|
|
|
|
|
2012-07-14 22:45:11 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
2012-07-12 08:55:27 +02:00
|
|
|
|
|
2012-07-14 22:45:11 +02:00
|
|
|
|
case "Video":
|
2012-08-20 17:55:05 +02:00
|
|
|
|
await FetchMediaInfoVideo(reader.ReadSubtree(), item);
|
2012-07-14 22:45:11 +02:00
|
|
|
|
break;
|
2012-07-12 08:55:27 +02:00
|
|
|
|
|
2012-07-14 22:45:11 +02:00
|
|
|
|
case "Subtitle":
|
2012-08-20 17:55:05 +02:00
|
|
|
|
await FetchMediaInfoSubtitles(reader.ReadSubtree(), item);
|
2012-07-14 22:45:11 +02:00
|
|
|
|
break;
|
2012-07-12 08:55:27 +02:00
|
|
|
|
|
2012-07-14 22:45:11 +02:00
|
|
|
|
default:
|
2012-08-20 17:55:05 +02:00
|
|
|
|
await reader.SkipAsync();
|
2012-07-14 22:45:11 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
2012-07-12 08:55:27 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-20 17:55:05 +02:00
|
|
|
|
private async Task<AudioStream> FetchMediaInfoAudio(XmlReader reader)
|
2012-07-12 08:55:27 +02:00
|
|
|
|
{
|
|
|
|
|
AudioStream stream = new AudioStream();
|
|
|
|
|
|
2012-08-20 17:55:05 +02:00
|
|
|
|
await reader.MoveToContentAsync();
|
2012-07-14 22:45:11 +02:00
|
|
|
|
|
2012-08-20 17:55:05 +02:00
|
|
|
|
while (await reader.ReadAsync())
|
2012-07-12 08:55:27 +02:00
|
|
|
|
{
|
2012-07-14 22:45:11 +02:00
|
|
|
|
if (reader.NodeType == XmlNodeType.Element)
|
2012-07-12 08:55:27 +02:00
|
|
|
|
{
|
2012-07-14 22:45:11 +02:00
|
|
|
|
switch (reader.Name)
|
|
|
|
|
{
|
2012-08-18 10:22:54 +02:00
|
|
|
|
case "Default":
|
2012-08-20 17:55:05 +02:00
|
|
|
|
stream.IsDefault = await reader.ReadElementContentAsStringAsync() == "True";
|
2012-08-18 10:22:54 +02:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "Forced":
|
2012-08-20 17:55:05 +02:00
|
|
|
|
stream.IsForced = await reader.ReadElementContentAsStringAsync() == "True";
|
2012-08-18 10:22:54 +02:00
|
|
|
|
break;
|
|
|
|
|
|
2012-07-14 22:45:11 +02:00
|
|
|
|
case "BitRate":
|
2012-08-20 17:55:05 +02:00
|
|
|
|
stream.BitRate = await reader.ReadIntSafe();
|
2012-07-14 22:45:11 +02:00
|
|
|
|
break;
|
2012-07-12 08:55:27 +02:00
|
|
|
|
|
2012-07-14 22:45:11 +02:00
|
|
|
|
case "Channels":
|
2012-08-20 17:55:05 +02:00
|
|
|
|
stream.Channels = await reader.ReadIntSafe();
|
2012-07-14 22:45:11 +02:00
|
|
|
|
break;
|
2012-07-12 08:55:27 +02:00
|
|
|
|
|
2012-07-14 22:45:11 +02:00
|
|
|
|
case "Language":
|
2012-08-20 17:55:05 +02:00
|
|
|
|
stream.Language = await reader.ReadElementContentAsStringAsync();
|
2012-07-14 22:45:11 +02:00
|
|
|
|
break;
|
2012-07-12 08:55:27 +02:00
|
|
|
|
|
2012-07-14 22:45:11 +02:00
|
|
|
|
case "Codec":
|
2012-07-12 08:55:27 +02:00
|
|
|
|
{
|
2012-08-20 17:55:05 +02:00
|
|
|
|
string codec = await reader.ReadElementContentAsStringAsync();
|
2012-07-14 22:45:11 +02:00
|
|
|
|
|
|
|
|
|
switch (codec.ToLower())
|
|
|
|
|
{
|
|
|
|
|
case "dts-es":
|
|
|
|
|
case "dts-es matrix":
|
|
|
|
|
case "dts-es discrete":
|
2012-08-18 10:22:54 +02:00
|
|
|
|
stream.Format = "DTS";
|
|
|
|
|
stream.Profile = "ES";
|
2012-07-14 22:45:11 +02:00
|
|
|
|
break;
|
|
|
|
|
case "dts-hd hra":
|
|
|
|
|
case "dts-hd high resolution":
|
2012-08-18 10:22:54 +02:00
|
|
|
|
stream.Format = "DTS";
|
|
|
|
|
stream.Profile = "HRA";
|
2012-07-14 22:45:11 +02:00
|
|
|
|
break;
|
|
|
|
|
case "dts ma":
|
|
|
|
|
case "dts-hd ma":
|
|
|
|
|
case "dts-hd master":
|
2012-08-18 10:22:54 +02:00
|
|
|
|
stream.Format = "DTS";
|
|
|
|
|
stream.Profile = "MA";
|
2012-07-14 22:45:11 +02:00
|
|
|
|
break;
|
|
|
|
|
case "dolby digital":
|
|
|
|
|
case "dolby digital surround ex":
|
|
|
|
|
case "dolby surround":
|
2012-08-18 10:22:54 +02:00
|
|
|
|
stream.Format = "AC-3";
|
2012-07-14 22:45:11 +02:00
|
|
|
|
break;
|
|
|
|
|
case "dolby digital plus":
|
2012-08-18 10:22:54 +02:00
|
|
|
|
stream.Format = "E-AC-3";
|
2012-07-14 22:45:11 +02:00
|
|
|
|
break;
|
|
|
|
|
case "dolby truehd":
|
2012-08-18 10:22:54 +02:00
|
|
|
|
stream.Format = "AC-3";
|
|
|
|
|
stream.Profile = "TrueHD";
|
2012-07-14 22:45:11 +02:00
|
|
|
|
break;
|
|
|
|
|
case "mp2":
|
2012-08-18 10:22:54 +02:00
|
|
|
|
stream.Format = "MPEG Audio";
|
|
|
|
|
stream.Profile = "Layer 2";
|
2012-07-14 22:45:11 +02:00
|
|
|
|
break;
|
|
|
|
|
case "other":
|
|
|
|
|
break;
|
|
|
|
|
default:
|
2012-08-18 10:22:54 +02:00
|
|
|
|
stream.Format = codec;
|
2012-07-14 22:45:11 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
2012-07-12 08:55:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
2012-07-14 22:45:11 +02:00
|
|
|
|
default:
|
2012-08-20 17:55:05 +02:00
|
|
|
|
await reader.SkipAsync();
|
2012-07-12 08:55:27 +02:00
|
|
|
|
break;
|
2012-07-14 22:45:11 +02:00
|
|
|
|
}
|
2012-07-12 08:55:27 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return stream;
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-20 17:55:05 +02:00
|
|
|
|
private async Task FetchMediaInfoVideo(XmlReader reader, Video item)
|
2012-07-12 08:55:27 +02:00
|
|
|
|
{
|
2012-08-20 17:55:05 +02:00
|
|
|
|
await reader.MoveToContentAsync();
|
2012-07-14 22:45:11 +02:00
|
|
|
|
|
2012-08-20 17:55:05 +02:00
|
|
|
|
while (await reader.ReadAsync())
|
2012-07-12 08:55:27 +02:00
|
|
|
|
{
|
2012-07-14 22:45:11 +02:00
|
|
|
|
if (reader.NodeType == XmlNodeType.Element)
|
2012-07-12 08:55:27 +02:00
|
|
|
|
{
|
2012-07-14 22:45:11 +02:00
|
|
|
|
switch (reader.Name)
|
|
|
|
|
{
|
|
|
|
|
case "Width":
|
2012-08-20 17:55:05 +02:00
|
|
|
|
item.Width = await reader.ReadIntSafe();
|
2012-07-14 22:45:11 +02:00
|
|
|
|
break;
|
2012-07-12 08:55:27 +02:00
|
|
|
|
|
2012-07-14 22:45:11 +02:00
|
|
|
|
case "Height":
|
2012-08-20 17:55:05 +02:00
|
|
|
|
item.Height = await reader.ReadIntSafe();
|
2012-07-14 22:45:11 +02:00
|
|
|
|
break;
|
2012-07-12 08:55:27 +02:00
|
|
|
|
|
2012-07-14 22:45:11 +02:00
|
|
|
|
case "BitRate":
|
2012-08-20 17:55:05 +02:00
|
|
|
|
item.BitRate = await reader.ReadIntSafe();
|
2012-07-14 22:45:11 +02:00
|
|
|
|
break;
|
2012-07-12 08:55:27 +02:00
|
|
|
|
|
2012-07-14 22:45:11 +02:00
|
|
|
|
case "FrameRate":
|
2012-08-20 17:55:05 +02:00
|
|
|
|
item.FrameRate = await reader.ReadElementContentAsStringAsync();
|
2012-07-14 22:45:11 +02:00
|
|
|
|
break;
|
2012-07-12 08:55:27 +02:00
|
|
|
|
|
2012-07-14 22:45:11 +02:00
|
|
|
|
case "ScanType":
|
2012-08-20 17:55:05 +02:00
|
|
|
|
item.ScanType = await reader.ReadElementContentAsStringAsync();
|
2012-07-14 22:45:11 +02:00
|
|
|
|
break;
|
2012-07-12 08:55:27 +02:00
|
|
|
|
|
2012-07-14 22:45:11 +02:00
|
|
|
|
case "Duration":
|
2012-08-20 17:55:05 +02:00
|
|
|
|
item.RunTimeTicks = TimeSpan.FromMinutes(await reader.ReadIntSafe()).Ticks;
|
2012-07-14 22:45:11 +02:00
|
|
|
|
break;
|
2012-07-12 08:55:27 +02:00
|
|
|
|
|
2012-07-14 22:45:11 +02:00
|
|
|
|
case "DurationSeconds":
|
2012-08-20 17:55:05 +02:00
|
|
|
|
int seconds = await reader.ReadIntSafe();
|
2012-07-14 22:45:11 +02:00
|
|
|
|
if (seconds > 0)
|
|
|
|
|
{
|
2012-08-18 10:22:54 +02:00
|
|
|
|
item.RunTimeTicks = TimeSpan.FromSeconds(seconds).Ticks;
|
2012-07-14 22:45:11 +02:00
|
|
|
|
}
|
|
|
|
|
break;
|
2012-07-12 08:55:27 +02:00
|
|
|
|
|
2012-07-14 22:45:11 +02:00
|
|
|
|
case "Codec":
|
2012-07-12 08:55:27 +02:00
|
|
|
|
{
|
2012-08-20 17:55:05 +02:00
|
|
|
|
string videoCodec = await reader.ReadElementContentAsStringAsync();
|
2012-07-14 22:45:11 +02:00
|
|
|
|
|
|
|
|
|
switch (videoCodec.ToLower())
|
|
|
|
|
{
|
|
|
|
|
case "sorenson h.263":
|
2012-08-18 10:22:54 +02:00
|
|
|
|
item.Codec = "Sorenson H263";
|
2012-07-14 22:45:11 +02:00
|
|
|
|
break;
|
|
|
|
|
case "h.262":
|
2012-08-18 10:22:54 +02:00
|
|
|
|
item.Codec = "MPEG-2 Video";
|
2012-07-14 22:45:11 +02:00
|
|
|
|
break;
|
|
|
|
|
case "h.264":
|
2012-08-18 10:22:54 +02:00
|
|
|
|
item.Codec = "AVC";
|
2012-07-14 22:45:11 +02:00
|
|
|
|
break;
|
|
|
|
|
default:
|
2012-08-18 10:22:54 +02:00
|
|
|
|
item.Codec = videoCodec;
|
2012-07-14 22:45:11 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
2012-07-12 08:55:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
2012-07-14 22:45:11 +02:00
|
|
|
|
default:
|
2012-08-20 17:55:05 +02:00
|
|
|
|
await reader.SkipAsync();
|
2012-07-12 08:55:27 +02:00
|
|
|
|
break;
|
2012-07-14 22:45:11 +02:00
|
|
|
|
}
|
2012-07-12 08:55:27 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-20 17:55:05 +02:00
|
|
|
|
private async Task FetchMediaInfoSubtitles(XmlReader reader, Video item)
|
2012-07-12 08:55:27 +02:00
|
|
|
|
{
|
2012-07-14 22:45:11 +02:00
|
|
|
|
List<string> list = (item.Subtitles ?? new string[] { }).ToList();
|
|
|
|
|
|
2012-08-20 17:55:05 +02:00
|
|
|
|
await reader.MoveToContentAsync();
|
2012-07-12 08:55:27 +02:00
|
|
|
|
|
2012-08-20 17:55:05 +02:00
|
|
|
|
while (await reader.ReadAsync())
|
2012-07-12 08:55:27 +02:00
|
|
|
|
{
|
2012-07-14 22:45:11 +02:00
|
|
|
|
if (reader.NodeType == XmlNodeType.Element)
|
2012-07-12 08:55:27 +02:00
|
|
|
|
{
|
2012-07-14 22:45:11 +02:00
|
|
|
|
switch (reader.Name)
|
|
|
|
|
{
|
|
|
|
|
case "Language":
|
|
|
|
|
{
|
2012-08-20 17:55:05 +02:00
|
|
|
|
string genre = await reader.ReadElementContentAsStringAsync();
|
2012-07-12 08:55:27 +02:00
|
|
|
|
|
2012-07-20 04:22:44 +02:00
|
|
|
|
if (!string.IsNullOrWhiteSpace(genre))
|
2012-07-14 22:45:11 +02:00
|
|
|
|
{
|
|
|
|
|
list.Add(genre);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
2012-07-12 08:55:27 +02:00
|
|
|
|
|
2012-07-14 22:45:11 +02:00
|
|
|
|
default:
|
2012-08-20 17:55:05 +02:00
|
|
|
|
await reader.SkipAsync();
|
2012-07-14 22:45:11 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
2012-07-12 08:55:27 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-07-14 22:45:11 +02:00
|
|
|
|
item.Subtitles = list;
|
2012-07-12 08:55:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
2012-08-20 17:55:05 +02:00
|
|
|
|
private async Task FetchFromTaglinesNode(XmlReader reader, T item)
|
2012-08-18 10:22:54 +02:00
|
|
|
|
{
|
|
|
|
|
List<string> list = (item.Taglines ?? new string[] { }).ToList();
|
|
|
|
|
|
2012-08-20 17:55:05 +02:00
|
|
|
|
await reader.MoveToContentAsync();
|
2012-08-18 10:22:54 +02:00
|
|
|
|
|
2012-08-20 17:55:05 +02:00
|
|
|
|
while (await reader.ReadAsync())
|
2012-08-18 10:22:54 +02:00
|
|
|
|
{
|
|
|
|
|
if (reader.NodeType == XmlNodeType.Element)
|
|
|
|
|
{
|
|
|
|
|
switch (reader.Name)
|
|
|
|
|
{
|
|
|
|
|
case "Tagline":
|
|
|
|
|
{
|
2012-08-20 17:55:05 +02:00
|
|
|
|
string val = await reader.ReadElementContentAsStringAsync();
|
2012-08-18 10:22:54 +02:00
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(val))
|
|
|
|
|
{
|
|
|
|
|
list.Add(val);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
default:
|
2012-08-20 17:55:05 +02:00
|
|
|
|
await reader.SkipAsync();
|
2012-08-18 10:22:54 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
item.Taglines = list;
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-20 17:55:05 +02:00
|
|
|
|
private async Task FetchFromGenresNode(XmlReader reader, T item)
|
2012-07-12 08:55:27 +02:00
|
|
|
|
{
|
|
|
|
|
List<string> list = (item.Genres ?? new string[] { }).ToList();
|
|
|
|
|
|
2012-08-20 17:55:05 +02:00
|
|
|
|
await reader.MoveToContentAsync();
|
2012-07-14 22:45:11 +02:00
|
|
|
|
|
2012-08-20 17:55:05 +02:00
|
|
|
|
while (await reader.ReadAsync())
|
2012-07-12 08:55:27 +02:00
|
|
|
|
{
|
2012-07-14 22:45:11 +02:00
|
|
|
|
if (reader.NodeType == XmlNodeType.Element)
|
2012-07-12 08:55:27 +02:00
|
|
|
|
{
|
2012-07-14 22:45:11 +02:00
|
|
|
|
switch (reader.Name)
|
|
|
|
|
{
|
|
|
|
|
case "Genre":
|
|
|
|
|
{
|
2012-08-20 17:55:05 +02:00
|
|
|
|
string genre = await reader.ReadElementContentAsStringAsync();
|
2012-07-12 08:55:27 +02:00
|
|
|
|
|
2012-07-20 04:22:44 +02:00
|
|
|
|
if (!string.IsNullOrWhiteSpace(genre))
|
2012-07-14 22:45:11 +02:00
|
|
|
|
{
|
|
|
|
|
list.Add(genre);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
2012-07-12 08:55:27 +02:00
|
|
|
|
|
2012-07-14 22:45:11 +02:00
|
|
|
|
default:
|
2012-08-20 17:55:05 +02:00
|
|
|
|
await reader.SkipAsync();
|
2012-07-14 22:45:11 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
2012-07-12 08:55:27 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2012-07-14 22:45:11 +02:00
|
|
|
|
|
2012-07-12 08:55:27 +02:00
|
|
|
|
item.Genres = list;
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-20 17:55:05 +02:00
|
|
|
|
private async Task FetchDataFromPersonsNode(XmlReader reader, T item)
|
2012-07-12 08:55:27 +02:00
|
|
|
|
{
|
2012-07-12 19:09:35 +02:00
|
|
|
|
List<PersonInfo> list = (item.People ?? new PersonInfo[] { }).ToList();
|
2012-07-12 08:55:27 +02:00
|
|
|
|
|
2012-08-20 17:55:05 +02:00
|
|
|
|
await reader.MoveToContentAsync();
|
2012-07-14 22:45:11 +02:00
|
|
|
|
|
2012-08-20 17:55:05 +02:00
|
|
|
|
while (await reader.ReadAsync())
|
2012-07-12 08:55:27 +02:00
|
|
|
|
{
|
2012-07-14 22:45:11 +02:00
|
|
|
|
if (reader.NodeType == XmlNodeType.Element)
|
2012-07-12 08:55:27 +02:00
|
|
|
|
{
|
2012-07-14 22:45:11 +02:00
|
|
|
|
switch (reader.Name)
|
|
|
|
|
{
|
|
|
|
|
case "Person":
|
|
|
|
|
{
|
2012-08-20 17:55:05 +02:00
|
|
|
|
list.Add(await GetPersonFromXmlNode(reader.ReadSubtree()));
|
2012-07-14 22:45:11 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
2012-07-12 08:55:27 +02:00
|
|
|
|
|
2012-07-14 22:45:11 +02:00
|
|
|
|
default:
|
2012-08-20 17:55:05 +02:00
|
|
|
|
await reader.SkipAsync();
|
2012-07-12 08:55:27 +02:00
|
|
|
|
break;
|
2012-07-14 22:45:11 +02:00
|
|
|
|
}
|
2012-07-12 08:55:27 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
item.People = list;
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-20 17:55:05 +02:00
|
|
|
|
private async Task FetchFromStudiosNode(XmlReader reader, T item)
|
2012-07-12 08:55:27 +02:00
|
|
|
|
{
|
|
|
|
|
List<string> list = (item.Studios ?? new string[] { }).ToList();
|
|
|
|
|
|
2012-08-20 17:55:05 +02:00
|
|
|
|
await reader.MoveToContentAsync();
|
2012-07-14 22:45:11 +02:00
|
|
|
|
|
2012-08-20 17:55:05 +02:00
|
|
|
|
while (await reader.ReadAsync())
|
2012-07-12 08:55:27 +02:00
|
|
|
|
{
|
2012-07-14 22:45:11 +02:00
|
|
|
|
if (reader.NodeType == XmlNodeType.Element)
|
2012-07-12 08:55:27 +02:00
|
|
|
|
{
|
2012-07-14 22:45:11 +02:00
|
|
|
|
switch (reader.Name)
|
|
|
|
|
{
|
|
|
|
|
case "Studio":
|
|
|
|
|
{
|
2012-08-20 17:55:05 +02:00
|
|
|
|
string studio = await reader.ReadElementContentAsStringAsync();
|
2012-07-12 08:55:27 +02:00
|
|
|
|
|
2012-07-20 04:22:44 +02:00
|
|
|
|
if (!string.IsNullOrWhiteSpace(studio))
|
2012-07-14 22:45:11 +02:00
|
|
|
|
{
|
|
|
|
|
list.Add(studio);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
2012-07-12 08:55:27 +02:00
|
|
|
|
|
2012-07-14 22:45:11 +02:00
|
|
|
|
default:
|
2012-08-20 17:55:05 +02:00
|
|
|
|
await reader.SkipAsync();
|
2012-07-14 22:45:11 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
2012-07-12 08:55:27 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
item.Studios = list;
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-20 17:55:05 +02:00
|
|
|
|
private async Task FetchFromParentalRatingNode(XmlReader reader, T item)
|
2012-07-12 08:55:27 +02:00
|
|
|
|
{
|
2012-08-20 17:55:05 +02:00
|
|
|
|
await reader.MoveToContentAsync();
|
2012-07-14 22:45:11 +02:00
|
|
|
|
|
2012-08-20 17:55:05 +02:00
|
|
|
|
while (await reader.ReadAsync())
|
2012-07-12 08:55:27 +02:00
|
|
|
|
{
|
2012-07-14 22:45:11 +02:00
|
|
|
|
if (reader.NodeType == XmlNodeType.Element)
|
2012-07-12 08:55:27 +02:00
|
|
|
|
{
|
2012-07-14 22:45:11 +02:00
|
|
|
|
switch (reader.Name)
|
|
|
|
|
{
|
|
|
|
|
case "Value":
|
2012-07-12 08:55:27 +02:00
|
|
|
|
{
|
2012-08-20 17:55:05 +02:00
|
|
|
|
string ratingString = await reader.ReadElementContentAsStringAsync();
|
2012-07-14 22:45:11 +02:00
|
|
|
|
|
|
|
|
|
int rating = 7;
|
|
|
|
|
|
2012-07-20 04:22:44 +02:00
|
|
|
|
if (!string.IsNullOrWhiteSpace(ratingString))
|
2012-07-14 22:45:11 +02:00
|
|
|
|
{
|
|
|
|
|
int.TryParse(ratingString, out rating);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (rating)
|
|
|
|
|
{
|
|
|
|
|
case -1:
|
|
|
|
|
item.OfficialRating = "NR";
|
|
|
|
|
break;
|
|
|
|
|
case 0:
|
|
|
|
|
item.OfficialRating = "UR";
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
item.OfficialRating = "G";
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
item.OfficialRating = "PG";
|
|
|
|
|
break;
|
|
|
|
|
case 4:
|
|
|
|
|
item.OfficialRating = "PG-13";
|
|
|
|
|
break;
|
|
|
|
|
case 5:
|
|
|
|
|
item.OfficialRating = "NC-17";
|
|
|
|
|
break;
|
|
|
|
|
case 6:
|
|
|
|
|
item.OfficialRating = "R";
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
2012-07-12 08:55:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
2012-07-14 22:45:11 +02:00
|
|
|
|
default:
|
2012-08-20 17:55:05 +02:00
|
|
|
|
await reader.SkipAsync();
|
2012-07-14 22:45:11 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
2012-07-12 08:55:27 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-20 17:55:05 +02:00
|
|
|
|
private async Task<PersonInfo> GetPersonFromXmlNode(XmlReader reader)
|
2012-07-12 08:55:27 +02:00
|
|
|
|
{
|
2012-07-12 19:09:35 +02:00
|
|
|
|
PersonInfo person = new PersonInfo();
|
2012-07-12 08:55:27 +02:00
|
|
|
|
|
2012-08-20 17:55:05 +02:00
|
|
|
|
await reader.MoveToContentAsync();
|
2012-07-14 22:45:11 +02:00
|
|
|
|
|
2012-08-20 17:55:05 +02:00
|
|
|
|
while (await reader.ReadAsync())
|
2012-07-12 08:55:27 +02:00
|
|
|
|
{
|
2012-07-14 22:45:11 +02:00
|
|
|
|
if (reader.NodeType == XmlNodeType.Element)
|
2012-07-12 08:55:27 +02:00
|
|
|
|
{
|
2012-07-14 22:45:11 +02:00
|
|
|
|
switch (reader.Name)
|
|
|
|
|
{
|
|
|
|
|
case "Name":
|
2012-08-20 17:55:05 +02:00
|
|
|
|
person.Name = await reader.ReadElementContentAsStringAsync();
|
2012-07-14 22:45:11 +02:00
|
|
|
|
break;
|
2012-07-12 08:55:27 +02:00
|
|
|
|
|
2012-07-14 22:45:11 +02:00
|
|
|
|
case "Type":
|
2012-08-20 17:55:05 +02:00
|
|
|
|
person.Type = await reader.ReadElementContentAsStringAsync();
|
2012-08-18 10:22:54 +02:00
|
|
|
|
break;
|
2012-07-12 08:55:27 +02:00
|
|
|
|
|
2012-07-14 22:45:11 +02:00
|
|
|
|
case "Role":
|
2012-08-20 17:55:05 +02:00
|
|
|
|
person.Overview = await reader.ReadElementContentAsStringAsync();
|
2012-07-14 22:45:11 +02:00
|
|
|
|
break;
|
2012-07-12 08:55:27 +02:00
|
|
|
|
|
2012-07-14 22:45:11 +02:00
|
|
|
|
default:
|
2012-08-20 17:55:05 +02:00
|
|
|
|
await reader.SkipAsync();
|
2012-07-14 22:45:11 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
2012-07-12 08:55:27 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2012-07-14 22:45:11 +02:00
|
|
|
|
|
2012-07-12 08:55:27 +02:00
|
|
|
|
return person;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected IEnumerable<string> GetSplitValues(string value, char deliminator)
|
|
|
|
|
{
|
|
|
|
|
value = (value ?? string.Empty).Trim(deliminator);
|
|
|
|
|
|
2012-07-20 04:22:44 +02:00
|
|
|
|
return string.IsNullOrWhiteSpace(value) ? new string[] { } : value.Split(deliminator);
|
2012-07-12 08:55:27 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|