2014-06-29 20:04:50 -07:00
|
|
|
|
using System;
|
|
|
|
|
using System.Xml;
|
|
|
|
|
using MediaBrowser.Controller.Entities.TV;
|
2013-03-02 23:58:04 -07:00
|
|
|
|
using MediaBrowser.Controller.Library;
|
2013-06-09 09:47:28 -07:00
|
|
|
|
using MediaBrowser.Controller.Providers;
|
2013-02-20 18:33:05 -07:00
|
|
|
|
using MediaBrowser.Model.Entities;
|
2013-02-21 13:26:35 -07:00
|
|
|
|
using MediaBrowser.Model.Logging;
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2014-06-29 20:04:50 -07:00
|
|
|
|
namespace MediaBrowser.LocalMetadata.Parsers
|
2013-02-20 18:33:05 -07:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Class SeriesXmlParser
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class SeriesXmlParser : BaseItemXmlParser<Series>
|
|
|
|
|
{
|
2013-02-21 13:26:35 -07:00
|
|
|
|
/// <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)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-20 18:33:05 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Fetches the data from XML node.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="reader">The reader.</param>
|
2015-06-28 18:10:45 -07:00
|
|
|
|
/// <param name="result">The result.</param>
|
|
|
|
|
protected override void FetchDataFromXmlNode(XmlReader reader, MetadataResult<Series> result)
|
2013-02-20 18:33:05 -07:00
|
|
|
|
{
|
2015-06-28 18:10:45 -07:00
|
|
|
|
var item = result.Item;
|
|
|
|
|
|
2013-02-20 18:33:05 -07:00
|
|
|
|
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)
|
|
|
|
|
{
|
2015-06-28 18:10:45 -07:00
|
|
|
|
FetchDataFromXmlNode(subTree, result);
|
2013-02-20 18:33:05 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
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":
|
2013-05-17 11:05:49 -07:00
|
|
|
|
{
|
|
|
|
|
var val = reader.ReadElementContentAsString();
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(val))
|
|
|
|
|
{
|
|
|
|
|
item.AirTime = val;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2014-02-28 21:13:44 -07:00
|
|
|
|
case "AnimeSeriesIndex":
|
|
|
|
|
{
|
|
|
|
|
var number = reader.ReadElementContentAsString();
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(number))
|
|
|
|
|
{
|
|
|
|
|
int num;
|
|
|
|
|
|
|
|
|
|
if (int.TryParse(number, out num))
|
|
|
|
|
{
|
|
|
|
|
item.AnimeSeriesIndex = num;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
2013-02-20 18:33:05 -07:00
|
|
|
|
case "Status":
|
|
|
|
|
{
|
|
|
|
|
var status = reader.ReadElementContentAsString();
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(status))
|
|
|
|
|
{
|
|
|
|
|
SeriesStatus seriesStatus;
|
|
|
|
|
if (Enum.TryParse(status, true, out seriesStatus))
|
|
|
|
|
{
|
|
|
|
|
item.Status = seriesStatus;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2013-02-21 13:26:35 -07:00
|
|
|
|
Logger.Info("Unrecognized series status: " + status);
|
2013-02-20 18:33:05 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
default:
|
2015-06-28 18:10:45 -07:00
|
|
|
|
base.FetchDataFromXmlNode(reader, result);
|
2013-02-20 18:33:05 -07:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|