jellyfin-server/MediaBrowser.TV/Metadata/EpisodeXmlParser.cs

63 lines
2.1 KiB
C#
Raw Normal View History

2012-07-12 06:55:27 +00: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-12 06:55:27 +00:00
{
switch (reader.Name)
2012-07-12 06:55:27 +00:00
{
case "filename":
{
string filename = reader.ReadElementContentAsString();
2012-07-12 06:55:27 +00: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-12 06:55:27 +00:00
break;
case "SeasonNumber":
item.SeasonNumber = reader.ReadElementContentAsString() ?? string.Empty;
2012-07-12 06:55:27 +00:00
break;
case "EpisodeName":
item.Name = reader.ReadElementContentAsString() ?? string.Empty;
2012-07-12 06:55:27 +00:00
break;
case "FirstAired":
{
string firstAired = reader.ReadElementContentAsString() ?? string.Empty;
2012-07-12 06:55:27 +00:00
if (!string.IsNullOrEmpty(firstAired))
2012-07-12 06:55:27 +00:00
{
DateTime airDate;
if (DateTime.TryParse(firstAired, out airDate) && airDate.Year > 1850)
2012-07-12 06:55:27 +00:00
{
item.FirstAired = airDate;
item.ProductionYear = airDate.Year;
2012-07-12 06:55:27 +00:00
}
}
break;
}
default:
base.FetchDataFromXmlNode(reader, item);
2012-07-12 06:55:27 +00:00
break;
}
}
}
}