jellyfin/MediaBrowser.TV/Metadata/EpisodeXmlParser.cs

62 lines
2.1 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.IsNullOrEmpty(filename))
{
string metadataFolder = Path.GetDirectoryName(item.Path);
item.PrimaryImagePath = Path.Combine(metadataFolder, filename);
}
break;
}
case "EpisodeNumber":
item.EpisodeNumber = reader.ReadElementContentAsString() ?? string.Empty;
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":
{
item.FirstAired = reader.ReadElementContentAsString() ?? string.Empty;
2012-07-11 23:55:27 -07:00
if (!string.IsNullOrEmpty(item.FirstAired))
{
DateTime airDate;
int y = DateTime.TryParse(item.FirstAired, out airDate) ? airDate.Year : -1;
if (y > 1850)
{
item.ProductionYear = y;
}
}
break;
}
default:
base.FetchDataFromXmlNode(reader, item);
2012-07-11 23:55:27 -07:00
break;
}
}
}
}