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.Providers/TV/SeriesXmlParser.cs

119 lines
3.8 KiB

using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Logging;
using System;
using System.Xml;
namespace MediaBrowser.Providers.TV
{
/// <summary>
/// Class SeriesXmlParser
/// </summary>
public class SeriesXmlParser : BaseItemXmlParser<Series>
{
/// <summary>
/// Initializes a new instance of the <see cref="BaseItemXmlParser{T}" /> class.
/// </summary>
/// <param name="logger">The logger.</param>
public SeriesXmlParser(ILogger logger)
: base(logger)
{
}
/// <summary>
/// Fetches the data from XML node.
/// </summary>
/// <param name="reader">The reader.</param>
/// <param name="item">The item.</param>
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":
{
var val = reader.ReadElementContentAsString();
if (!string.IsNullOrWhiteSpace(val))
{
item.AirTime = val;
}
break;
}
case "AnimeSeriesIndex":
{
var number = reader.ReadElementContentAsString();
if (!string.IsNullOrWhiteSpace(number))
{
int num;
if (int.TryParse(number, out num))
{
item.AnimeSeriesIndex = num;
}
}
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;
}
}
}
}