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

59 lines
2.0 KiB
C#
Raw Normal View History

using System.IO;
using System.Threading.Tasks;
2012-07-12 06:55:27 +00:00
using System.Xml;
using MediaBrowser.Controller.Xml;
using MediaBrowser.TV.Entities;
namespace MediaBrowser.TV.Metadata
{
public class EpisodeXmlParser : BaseItemXmlParser<Episode>
{
protected override async Task 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 = await reader.ReadElementContentAsStringAsync();
2012-07-12 06:55:27 +00:00
if (!string.IsNullOrWhiteSpace(filename))
2012-07-12 06:55:27 +00:00
{
string seasonFolder = Path.GetDirectoryName(item.Path);
item.PrimaryImagePath = Path.Combine(seasonFolder, "metadata", filename);
2012-07-12 06:55:27 +00:00
}
break;
}
2012-08-20 02:05:55 +00:00
case "SeasonNumber":
{
string number = await reader.ReadElementContentAsStringAsync();
2012-08-20 02:05:55 +00:00
if (!string.IsNullOrWhiteSpace(number))
{
item.ParentIndexNumber = int.Parse(number);
}
break;
}
2012-08-20 02:05:55 +00:00
case "EpisodeNumber":
{
string number = await reader.ReadElementContentAsStringAsync();
2012-08-20 02:05:55 +00:00
if (!string.IsNullOrWhiteSpace(number))
{
item.IndexNumber = int.Parse(number);
}
break;
}
2012-07-12 06:55:27 +00:00
case "EpisodeName":
item.Name = await reader.ReadElementContentAsStringAsync();
2012-07-12 06:55:27 +00:00
break;
default:
await base.FetchDataFromXmlNode(reader, item);
2012-07-12 06:55:27 +00:00
break;
}
}
}
}