jellyfin/MediaBrowser.TV/Metadata/EpisodeXmlParser.cs

68 lines
2.3 KiB
C#
Raw Normal View History

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>
{
protected override void FetchDataFromXmlNode(XmlReader reader, Episode item)
2012-07-11 23:55:27 -07:00
{
switch (reader.Name)
2012-07-11 23:55:27 -07:00
{
case "filename":
{
string filename = reader.ReadElementContentAsString();
2012-07-11 23:55:27 -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":
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":
item.SeasonNumber = reader.ReadElementContentAsString() ?? string.Empty;
2012-07-11 23:55:27 -07:00
break;
case "EpisodeName":
item.Name = reader.ReadElementContentAsString() ?? string.Empty;
2012-07-11 23:55:27 -07:00
break;
case "FirstAired":
{
string firstAired = reader.ReadElementContentAsString() ?? string.Empty;
2012-07-11 23:55:27 -07:00
if (!string.IsNullOrWhiteSpace(firstAired))
2012-07-11 23:55:27 -07:00
{
DateTime airDate;
if (DateTime.TryParse(firstAired, out airDate) && airDate.Year > 1850)
2012-07-11 23:55:27 -07:00
{
item.PremiereDate = airDate;
item.ProductionYear = airDate.Year;
2012-07-11 23:55:27 -07:00
}
}
break;
}
default:
base.FetchDataFromXmlNode(reader, item);
2012-07-11 23:55:27 -07:00
break;
}
}
}
}