update xml parsing

pull/702/head
Luke Pulverenti 8 years ago
parent 7cf0f79f85
commit 8f64a5555b

@ -1329,11 +1329,13 @@ namespace MediaBrowser.LocalMetadata.Parsers
protected Share GetShare(XmlReader reader)
{
reader.MoveToContent();
var item = new Share();
while (reader.Read())
reader.MoveToContent();
reader.Read();
// Loop through each element
while (!reader.EOF)
{
if (reader.NodeType == XmlNodeType.Element)
{
@ -1350,12 +1352,17 @@ namespace MediaBrowser.LocalMetadata.Parsers
item.CanEdit = string.Equals(reader.ReadElementContentAsString(), "true", StringComparison.OrdinalIgnoreCase);
break;
}
default:
reader.Skip();
break;
{
reader.Skip();
break;
}
}
}
else
{
reader.Read();
}
}
// This is valid

@ -31,11 +31,13 @@ namespace MediaBrowser.LocalMetadata.Parsers
private void FetchFromCollectionItemsNode(XmlReader reader, MetadataResult<BoxSet> item)
{
reader.MoveToContent();
var list = new List<LinkedChild>();
while (reader.Read())
reader.MoveToContent();
reader.Read();
// Loop through each element
while (!reader.EOF)
{
if (reader.NodeType == XmlNodeType.Element)
{
@ -55,12 +57,17 @@ namespace MediaBrowser.LocalMetadata.Parsers
break;
}
default:
reader.Skip();
break;
{
reader.Skip();
break;
}
}
}
else
{
reader.Read();
}
}
item.Item.LinkedChildren = list;

@ -65,11 +65,13 @@ namespace MediaBrowser.LocalMetadata.Parsers
private void FetchFromCollectionItemsNode(XmlReader reader, Playlist item)
{
reader.MoveToContent();
var list = new List<LinkedChild>();
while (reader.Read())
reader.MoveToContent();
reader.Read();
// Loop through each element
while (!reader.EOF)
{
if (reader.NodeType == XmlNodeType.Element)
{
@ -89,12 +91,17 @@ namespace MediaBrowser.LocalMetadata.Parsers
break;
}
default:
reader.Skip();
break;
{
reader.Skip();
break;
}
}
}
else
{
reader.Read();
}
}
item.LinkedChildren = list;
@ -102,11 +109,13 @@ namespace MediaBrowser.LocalMetadata.Parsers
private void FetchFromSharesNode(XmlReader reader, Playlist item)
{
reader.MoveToContent();
var list = new List<Share>();
while (reader.Read())
reader.MoveToContent();
reader.Read();
// Loop through each element
while (!reader.EOF)
{
if (reader.NodeType == XmlNodeType.Element)
{
@ -126,12 +135,17 @@ namespace MediaBrowser.LocalMetadata.Parsers
break;
}
default:
reader.Skip();
break;
{
reader.Skip();
break;
}
}
}
else
{
reader.Read();
}
}
item.Shares = list;

@ -513,9 +513,10 @@ namespace MediaBrowser.Providers.TV
using (var reader = XmlReader.Create(streamReader, settings))
{
reader.MoveToContent();
reader.Read();
// Loop through each element
while (reader.Read())
while (!reader.EOF)
{
if (reader.NodeType == XmlNodeType.Element)
{
@ -546,12 +547,17 @@ namespace MediaBrowser.Providers.TV
break;
}
default:
reader.Skip();
break;
{
reader.Skip();
break;
}
}
}
else
{
reader.Read();
}
}
}
}

@ -82,67 +82,73 @@ namespace MediaBrowser.Providers.TV
// Use XmlReader for best performance
using (reader)
{
reader.MoveToContent();
// Loop through each element
while (reader.Read())
{
cancellationToken.ThrowIfCancellationRequested();
if (reader.NodeType == XmlNodeType.Element)
{
switch (reader.Name)
{
case "thumb_width":
{
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))
{
width = rval;
}
}
break;
}
case "thumb_height":
{
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))
{
height = rval;
}
}
break;
}
case "filename":
{
var val = reader.ReadElementContentAsString();
if (!string.IsNullOrWhiteSpace(val))
{
url = TVUtils.BannerUrl + val;
}
break;
}
default:
reader.Skip();
break;
}
}
}
reader.MoveToContent();
reader.Read();
// Loop through each element
while (!reader.EOF)
{
if (reader.NodeType == XmlNodeType.Element)
{
cancellationToken.ThrowIfCancellationRequested();
switch (reader.Name)
{
case "thumb_width":
{
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))
{
width = rval;
}
}
break;
}
case "thumb_height":
{
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))
{
height = rval;
}
}
break;
}
case "filename":
{
var val = reader.ReadElementContentAsString();
if (!string.IsNullOrWhiteSpace(val))
{
url = TVUtils.BannerUrl + val;
}
break;
}
default:
{
reader.Skip();
break;
}
}
}
else
{
reader.Read();
}
}
}
if (string.IsNullOrEmpty(url))

Loading…
Cancel
Save