2012-07-11 23:55:27 -07:00
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Xml;
|
|
|
|
|
using MediaBrowser.Controller.Xml;
|
|
|
|
|
using MediaBrowser.TV.Entities;
|
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.TV.Metadata
|
|
|
|
|
{
|
|
|
|
|
public class EpisodeXmlParser : BaseItemXmlParser<Episode>
|
|
|
|
|
{
|
2012-07-14 13:45:11 -07:00
|
|
|
|
protected override void FetchDataFromXmlNode(XmlReader reader, Episode item)
|
2012-07-11 23:55:27 -07:00
|
|
|
|
{
|
2012-07-14 13:45:11 -07:00
|
|
|
|
switch (reader.Name)
|
2012-07-11 23:55:27 -07:00
|
|
|
|
{
|
|
|
|
|
case "filename":
|
|
|
|
|
{
|
2012-07-14 13:45:11 -07:00
|
|
|
|
string filename = reader.ReadElementContentAsString();
|
2012-07-11 23:55:27 -07:00
|
|
|
|
|
2012-07-19 19:22:44 -07:00
|
|
|
|
if (!string.IsNullOrWhiteSpace(filename))
|
2012-07-11 23:55:27 -07:00
|
|
|
|
{
|
|
|
|
|
string metadataFolder = Path.GetDirectoryName(item.Path);
|
|
|
|
|
item.PrimaryImagePath = Path.Combine(metadataFolder, filename);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case "EpisodeNumber":
|
2012-07-19 19:22:44 -07:00
|
|
|
|
string number = reader.ReadElementContentAsString() ?? string.Empty;
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(number))
|
|
|
|
|
{
|
|
|
|
|
item.IndexNumber = int.Parse(number);
|
|
|
|
|
}
|
2012-07-11 23:55:27 -07:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "SeasonNumber":
|
2012-07-14 13:45:11 -07:00
|
|
|
|
item.SeasonNumber = reader.ReadElementContentAsString() ?? string.Empty;
|
2012-07-11 23:55:27 -07:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "EpisodeName":
|
2012-07-14 13:45:11 -07:00
|
|
|
|
item.Name = reader.ReadElementContentAsString() ?? string.Empty;
|
2012-07-11 23:55:27 -07:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "FirstAired":
|
|
|
|
|
{
|
2012-07-15 13:27:07 -07:00
|
|
|
|
string firstAired = reader.ReadElementContentAsString() ?? string.Empty;
|
2012-07-11 23:55:27 -07:00
|
|
|
|
|
2012-07-19 19:22:44 -07:00
|
|
|
|
if (!string.IsNullOrWhiteSpace(firstAired))
|
2012-07-11 23:55:27 -07:00
|
|
|
|
{
|
|
|
|
|
DateTime airDate;
|
2012-07-15 13:27:07 -07:00
|
|
|
|
|
|
|
|
|
if (DateTime.TryParse(firstAired, out airDate) && airDate.Year > 1850)
|
2012-07-11 23:55:27 -07:00
|
|
|
|
{
|
2012-07-19 19:22:44 -07:00
|
|
|
|
item.PremiereDate = airDate;
|
2012-07-15 13:27:07 -07:00
|
|
|
|
item.ProductionYear = airDate.Year;
|
2012-07-11 23:55:27 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
default:
|
2012-07-14 13:45:11 -07:00
|
|
|
|
base.FetchDataFromXmlNode(reader, item);
|
2012-07-11 23:55:27 -07:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|