You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
jellyfin/MediaBrowser.TV/Metadata/EpisodeXmlParser.cs

63 lines
2.1 KiB

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