2014-06-29 20:04:50 -07:00
|
|
|
|
using MediaBrowser.Common.Configuration;
|
|
|
|
|
using MediaBrowser.Controller.Entities.TV;
|
2013-06-09 09:47:28 -07:00
|
|
|
|
using MediaBrowser.Controller.Providers;
|
2013-02-21 13:26:35 -07:00
|
|
|
|
using MediaBrowser.Model.Logging;
|
2014-02-04 13:19:29 -07:00
|
|
|
|
using System;
|
2014-02-08 21:52:52 -07:00
|
|
|
|
using System.Collections.Generic;
|
2013-11-17 08:27:48 -07:00
|
|
|
|
using System.Globalization;
|
2013-08-12 12:18:31 -07:00
|
|
|
|
using System.Threading;
|
2013-02-20 18:33:05 -07:00
|
|
|
|
using System.Xml;
|
|
|
|
|
|
2014-06-29 20:04:50 -07:00
|
|
|
|
namespace MediaBrowser.XbmcMetadata.Parsers
|
2013-02-20 18:33:05 -07:00
|
|
|
|
{
|
2014-06-29 20:04:50 -07:00
|
|
|
|
public class EpisodeNfoParser : BaseNfoParser<Episode>
|
2013-02-20 18:33:05 -07:00
|
|
|
|
{
|
2014-06-29 20:04:50 -07:00
|
|
|
|
public EpisodeNfoParser(ILogger logger, IConfigurationManager config) : base(logger, config)
|
2013-02-21 13:26:35 -07:00
|
|
|
|
{
|
2013-08-12 12:18:31 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-08-02 10:31:08 -07:00
|
|
|
|
public void Fetch(MetadataResult<Episode> item,
|
2014-05-14 13:55:16 -07:00
|
|
|
|
List<LocalImageInfo> images,
|
|
|
|
|
string metadataFile,
|
|
|
|
|
CancellationToken cancellationToken)
|
2013-08-12 12:18:31 -07:00
|
|
|
|
{
|
2015-06-28 18:10:45 -07:00
|
|
|
|
Fetch(item, metadataFile, cancellationToken);
|
2013-02-21 13:26:35 -07:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-17 08:27:48 -07:00
|
|
|
|
private static readonly CultureInfo UsCulture = new CultureInfo("en-US");
|
2013-12-08 13:33:24 -07:00
|
|
|
|
|
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="itemResult">The item result.</param>
|
2015-08-02 10:31:08 -07:00
|
|
|
|
protected override void FetchDataFromXmlNode(XmlReader reader, MetadataResult<Episode> itemResult)
|
2013-02-20 18:33:05 -07:00
|
|
|
|
{
|
2015-06-28 18:10:45 -07:00
|
|
|
|
var item = itemResult.Item;
|
|
|
|
|
|
2013-02-20 18:33:05 -07:00
|
|
|
|
switch (reader.Name)
|
|
|
|
|
{
|
2014-06-29 20:04:50 -07:00
|
|
|
|
case "season":
|
2013-02-20 18:33:05 -07:00
|
|
|
|
{
|
|
|
|
|
var number = reader.ReadElementContentAsString();
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(number))
|
|
|
|
|
{
|
|
|
|
|
int num;
|
|
|
|
|
|
|
|
|
|
if (int.TryParse(number, out num))
|
|
|
|
|
{
|
|
|
|
|
item.ParentIndexNumber = num;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-29 20:04:50 -07:00
|
|
|
|
case "episode":
|
2013-02-20 18:33:05 -07:00
|
|
|
|
{
|
|
|
|
|
var number = reader.ReadElementContentAsString();
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(number))
|
|
|
|
|
{
|
|
|
|
|
int num;
|
|
|
|
|
|
|
|
|
|
if (int.TryParse(number, out num))
|
|
|
|
|
{
|
|
|
|
|
item.IndexNumber = num;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-29 20:04:50 -07:00
|
|
|
|
case "episodenumberend":
|
2013-10-25 07:26:22 -07:00
|
|
|
|
{
|
|
|
|
|
var number = reader.ReadElementContentAsString();
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(number))
|
|
|
|
|
{
|
|
|
|
|
int num;
|
|
|
|
|
|
|
|
|
|
if (int.TryParse(number, out num))
|
|
|
|
|
{
|
|
|
|
|
item.IndexNumberEnd = num;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-10 13:42:42 -07:00
|
|
|
|
case "absolute_number":
|
|
|
|
|
{
|
|
|
|
|
var val = reader.ReadElementContentAsString();
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(val))
|
|
|
|
|
{
|
|
|
|
|
int rval;
|
|
|
|
|
|
|
|
|
|
// int.TryParse is local aware, so it can be probamatic, force us culture
|
|
|
|
|
if (int.TryParse(val, NumberStyles.Integer, UsCulture, out rval))
|
|
|
|
|
{
|
|
|
|
|
item.AbsoluteEpisodeNumber = rval;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
2013-12-08 11:07:45 -07:00
|
|
|
|
case "DVD_episodenumber":
|
|
|
|
|
{
|
|
|
|
|
var number = reader.ReadElementContentAsString();
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(number))
|
|
|
|
|
{
|
2013-12-08 13:33:24 -07:00
|
|
|
|
float num;
|
2013-12-08 11:07:45 -07:00
|
|
|
|
|
2013-12-08 13:33:24 -07:00
|
|
|
|
if (float.TryParse(number, NumberStyles.Any, UsCulture, out num))
|
2013-12-08 11:07:45 -07:00
|
|
|
|
{
|
2013-12-08 15:16:59 -07:00
|
|
|
|
item.DvdEpisodeNumber = num;
|
2013-12-08 11:07:45 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case "DVD_season":
|
|
|
|
|
{
|
|
|
|
|
var number = reader.ReadElementContentAsString();
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(number))
|
|
|
|
|
{
|
2013-12-08 13:33:24 -07:00
|
|
|
|
float num;
|
2013-12-08 11:07:45 -07:00
|
|
|
|
|
2013-12-08 13:33:24 -07:00
|
|
|
|
if (float.TryParse(number, NumberStyles.Any, UsCulture, out num))
|
2013-12-08 11:07:45 -07:00
|
|
|
|
{
|
2013-12-08 13:33:24 -07:00
|
|
|
|
item.DvdSeasonNumber = Convert.ToInt32(num);
|
2013-12-08 11:07:45 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-17 08:27:48 -07:00
|
|
|
|
case "airsbefore_episode":
|
2013-11-15 14:31:33 -07:00
|
|
|
|
{
|
2013-11-17 08:27:48 -07:00
|
|
|
|
var val = reader.ReadElementContentAsString();
|
2013-11-15 14:31:33 -07:00
|
|
|
|
|
2013-11-17 08:27:48 -07:00
|
|
|
|
if (!string.IsNullOrWhiteSpace(val))
|
2013-11-15 14:31:33 -07:00
|
|
|
|
{
|
2013-11-17 08:27:48 -07:00
|
|
|
|
int rval;
|
2013-11-15 14:31:33 -07:00
|
|
|
|
|
2013-11-17 08:27:48 -07:00
|
|
|
|
// int.TryParse is local aware, so it can be probamatic, force us culture
|
|
|
|
|
if (int.TryParse(val, NumberStyles.Integer, UsCulture, out rval))
|
2013-11-15 14:31:33 -07:00
|
|
|
|
{
|
2013-11-17 08:27:48 -07:00
|
|
|
|
item.AirsBeforeEpisodeNumber = rval;
|
2013-11-15 14:31:33 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
2013-11-17 08:27:48 -07:00
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case "airsafter_season":
|
|
|
|
|
{
|
|
|
|
|
var val = reader.ReadElementContentAsString();
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(val))
|
|
|
|
|
{
|
|
|
|
|
int rval;
|
|
|
|
|
|
|
|
|
|
// int.TryParse is local aware, so it can be probamatic, force us culture
|
|
|
|
|
if (int.TryParse(val, NumberStyles.Integer, UsCulture, out rval))
|
|
|
|
|
{
|
|
|
|
|
item.AirsAfterSeasonNumber = rval;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case "airsbefore_season":
|
|
|
|
|
{
|
|
|
|
|
var val = reader.ReadElementContentAsString();
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(val))
|
|
|
|
|
{
|
|
|
|
|
int rval;
|
|
|
|
|
|
|
|
|
|
// int.TryParse is local aware, so it can be probamatic, force us culture
|
|
|
|
|
if (int.TryParse(val, NumberStyles.Integer, UsCulture, out rval))
|
|
|
|
|
{
|
|
|
|
|
item.AirsBeforeSeasonNumber = rval;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-15 14:31:33 -07:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-24 13:07:35 -07:00
|
|
|
|
case "displayseason":
|
|
|
|
|
{
|
|
|
|
|
var val = reader.ReadElementContentAsString();
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(val))
|
|
|
|
|
{
|
|
|
|
|
int rval;
|
|
|
|
|
|
|
|
|
|
// int.TryParse is local aware, so it can be probamatic, force us culture
|
|
|
|
|
if (int.TryParse(val, NumberStyles.Integer, UsCulture, out rval))
|
|
|
|
|
{
|
2016-08-01 11:16:07 -07:00
|
|
|
|
item.AirsBeforeSeasonNumber = rval;
|
2016-06-24 13:07:35 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case "displayepisode":
|
|
|
|
|
{
|
|
|
|
|
var val = reader.ReadElementContentAsString();
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(val))
|
|
|
|
|
{
|
|
|
|
|
int rval;
|
|
|
|
|
|
|
|
|
|
// int.TryParse is local aware, so it can be probamatic, force us culture
|
|
|
|
|
if (int.TryParse(val, NumberStyles.Integer, UsCulture, out rval))
|
|
|
|
|
{
|
2016-08-01 11:16:07 -07:00
|
|
|
|
item.AirsBeforeEpisodeNumber = rval;
|
2016-06-24 13:07:35 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
|
|
|
|
default:
|
2015-06-28 18:10:45 -07:00
|
|
|
|
base.FetchDataFromXmlNode(reader, itemResult);
|
2013-02-20 18:33:05 -07:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|