using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Resolvers.TV;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Logging;
using System;
using System.Xml;
namespace MediaBrowser.Controller.Providers.TV
{
///
/// Class SeriesXmlParser
///
public class SeriesXmlParser : BaseItemXmlParser
{
///
/// Initializes a new instance of the class.
///
/// The logger.
public SeriesXmlParser(ILogger logger)
: base(logger)
{
}
///
/// Fetches the data from XML node.
///
/// The reader.
/// The item.
protected override void FetchDataFromXmlNode(XmlReader reader, Series item)
{
switch (reader.Name)
{
case "Series":
//MB generated metadata is within a "Series" node
using (var subTree = reader.ReadSubtree())
{
subTree.MoveToContent();
// Loop through each element
while (subTree.Read())
{
if (subTree.NodeType == XmlNodeType.Element)
{
FetchDataFromXmlNode(subTree, item);
}
}
}
break;
case "id":
string id = reader.ReadElementContentAsString();
if (!string.IsNullOrWhiteSpace(id))
{
item.SetProviderId(MetadataProviders.Tvdb, id);
}
break;
case "Airs_DayOfWeek":
{
item.AirDays = TVUtils.GetAirDays(reader.ReadElementContentAsString());
break;
}
case "Airs_Time":
item.AirTime = reader.ReadElementContentAsString();
break;
case "SeriesName":
item.Name = reader.ReadElementContentAsString();
break;
case "Status":
{
var status = reader.ReadElementContentAsString();
if (!string.IsNullOrWhiteSpace(status))
{
SeriesStatus seriesStatus;
if (Enum.TryParse(status, true, out seriesStatus))
{
item.Status = seriesStatus;
}
else
{
Logger.Info("Unrecognized series status: " + status);
}
}
break;
}
default:
base.FetchDataFromXmlNode(reader, item);
break;
}
}
}
}