update xml parsing

pull/702/head
Luke Pulverenti 8 years ago
parent 83ad945015
commit 7ed6c67db0

@ -16,7 +16,7 @@ namespace Emby.Dlna.Service
public abstract class BaseControlHandler
{
private const string NS_SOAPENV = "http://schemas.xmlsoap.org/soap/envelope/";
protected readonly IServerConfigurationManager Config;
protected readonly ILogger Logger;
protected readonly IXmlReaderSettingsFactory XmlReaderSettingsFactory;
@ -109,7 +109,7 @@ namespace Emby.Dlna.Service
}
var xml = builder.ToString().Replace("xmlns:m=", "xmlns:u=");
var controlResponse = new ControlResponse
{
Xml = xml,
@ -136,12 +136,20 @@ namespace Emby.Dlna.Service
switch (reader.LocalName)
{
case "Body":
{
using (var subReader = reader.ReadSubtree())
{
return ParseBodyTag(subReader);
if (!reader.IsEmptyElement)
{
using (var subReader = reader.ReadSubtree())
{
return ParseBodyTag(subReader);
}
}
else
{
reader.Read();
}
break;
}
}
default:
{
reader.Skip();
@ -173,11 +181,18 @@ namespace Emby.Dlna.Service
result.LocalName = reader.LocalName;
result.NamespaceURI = reader.NamespaceURI;
using (var subReader = reader.ReadSubtree())
if (!reader.IsEmptyElement)
{
result.Headers = ParseFirstBodyChild(subReader);
using (var subReader = reader.ReadSubtree())
{
result.Headers = ParseFirstBodyChild(subReader);
return result;
return result;
}
}
else
{
reader.Read();
}
}
else

@ -134,10 +134,18 @@ namespace Emby.Server.Implementations.News
{
case "channel":
{
using (var subReader = reader.ReadSubtree())
if (!reader.IsEmptyElement)
{
return ParseFromChannelNode(subReader);
using (var subReader = reader.ReadSubtree())
{
return ParseFromChannelNode(subReader);
}
}
else
{
reader.Read();
}
break;
}
default:
{
@ -170,9 +178,16 @@ namespace Emby.Server.Implementations.News
{
case "item":
{
using (var subReader = reader.ReadSubtree())
if (!reader.IsEmptyElement)
{
using (var subReader = reader.ReadSubtree())
{
list.Add(ParseItem(subReader));
}
}
else
{
list.Add(ParseItem(subReader));
reader.Read();
}
break;
}

@ -395,18 +395,32 @@ namespace MediaBrowser.LocalMetadata.Parsers
case "TagLines":
{
using (var subtree = reader.ReadSubtree())
if (!reader.IsEmptyElement)
{
FetchFromTaglinesNode(subtree, item);
using (var subtree = reader.ReadSubtree())
{
FetchFromTaglinesNode(subtree, item);
}
}
else
{
reader.Read();
}
break;
}
case "Countries":
{
using (var subtree = reader.ReadSubtree())
if (!reader.IsEmptyElement)
{
FetchFromCountriesNode(subtree, item);
using (var subtree = reader.ReadSubtree())
{
FetchFromCountriesNode(subtree, item);
}
}
else
{
reader.Read();
}
break;
}
@ -592,14 +606,21 @@ namespace MediaBrowser.LocalMetadata.Parsers
case "Trailers":
{
using (var subtree = reader.ReadSubtree())
if (!reader.IsEmptyElement)
{
var hasTrailers = item as IHasTrailers;
if (hasTrailers != null)
using (var subtree = reader.ReadSubtree())
{
FetchDataFromTrailersNode(subtree, hasTrailers);
var hasTrailers = item as IHasTrailers;
if (hasTrailers != null)
{
FetchDataFromTrailersNode(subtree, hasTrailers);
}
}
}
else
{
reader.Read();
}
break;
}
@ -699,59 +720,101 @@ namespace MediaBrowser.LocalMetadata.Parsers
case "Genres":
{
using (var subtree = reader.ReadSubtree())
if (!reader.IsEmptyElement)
{
using (var subtree = reader.ReadSubtree())
{
FetchFromGenresNode(subtree, item);
}
}
else
{
FetchFromGenresNode(subtree, item);
reader.Read();
}
break;
}
case "Tags":
{
using (var subtree = reader.ReadSubtree())
if (!reader.IsEmptyElement)
{
FetchFromTagsNode(subtree, item);
using (var subtree = reader.ReadSubtree())
{
FetchFromTagsNode(subtree, item);
}
}
else
{
reader.Read();
}
break;
}
case "PlotKeywords":
{
using (var subtree = reader.ReadSubtree())
if (!reader.IsEmptyElement)
{
FetchFromKeywordsNode(subtree, item);
using (var subtree = reader.ReadSubtree())
{
FetchFromKeywordsNode(subtree, item);
}
}
else
{
reader.Read();
}
break;
}
case "Persons":
{
using (var subtree = reader.ReadSubtree())
if (!reader.IsEmptyElement)
{
FetchDataFromPersonsNode(subtree, itemResult);
using (var subtree = reader.ReadSubtree())
{
FetchDataFromPersonsNode(subtree, itemResult);
}
}
else
{
reader.Read();
}
break;
}
case "Studios":
{
using (var subtree = reader.ReadSubtree())
if (!reader.IsEmptyElement)
{
FetchFromStudiosNode(subtree, item);
using (var subtree = reader.ReadSubtree())
{
FetchFromStudiosNode(subtree, item);
}
}
else
{
reader.Read();
}
break;
}
case "Shares":
{
using (var subtree = reader.ReadSubtree())
if (!reader.IsEmptyElement)
{
var hasShares = item as IHasShares;
if (hasShares != null)
using (var subtree = reader.ReadSubtree())
{
FetchFromSharesNode(subtree, hasShares);
var hasShares = item as IHasShares;
if (hasShares != null)
{
FetchFromSharesNode(subtree, hasShares);
}
}
}
else
{
reader.Read();
}
break;
}
@ -824,6 +887,11 @@ namespace MediaBrowser.LocalMetadata.Parsers
{
case "Share":
{
if (reader.IsEmptyElement)
{
reader.Read();
continue;
}
using (var subtree = reader.ReadSubtree())
{
var share = GetShareFromNode(subtree);
@ -1090,6 +1158,11 @@ namespace MediaBrowser.LocalMetadata.Parsers
case "Person":
case "Actor":
{
if (reader.IsEmptyElement)
{
reader.Read();
continue;
}
using (var subtree = reader.ReadSubtree())
{
foreach (var person in GetPersonsFromXmlNode(subtree))

@ -43,17 +43,31 @@ namespace MediaBrowser.LocalMetadata.Parsers
case "PlaylistItems":
using (var subReader = reader.ReadSubtree())
if (!reader.IsEmptyElement)
{
FetchFromCollectionItemsNode(subReader, item);
using (var subReader = reader.ReadSubtree())
{
FetchFromCollectionItemsNode(subReader, item);
}
}
else
{
reader.Read();
}
break;
case "Shares":
using (var subReader = reader.ReadSubtree())
if (!reader.IsEmptyElement)
{
using (var subReader = reader.ReadSubtree())
{
FetchFromSharesNode(subReader, item);
}
}
else
{
FetchFromSharesNode(subReader, item);
reader.Read();
}
break;
@ -79,6 +93,12 @@ namespace MediaBrowser.LocalMetadata.Parsers
{
case "PlaylistItem":
{
if (reader.IsEmptyElement)
{
reader.Read();
continue;
}
using (var subReader = reader.ReadSubtree())
{
var child = GetLinkedChild(subReader);
@ -123,6 +143,12 @@ namespace MediaBrowser.LocalMetadata.Parsers
{
case "Share":
{
if (reader.IsEmptyElement)
{
reader.Read();
continue;
}
using (var subReader = reader.ReadSubtree())
{
var child = GetShare(subReader);

@ -218,6 +218,11 @@ namespace MediaBrowser.MediaEncoding.Probing
switch (reader.Name)
{
case "dict":
if (reader.IsEmptyElement)
{
reader.Read();
continue;
}
using (var subtree = reader.ReadSubtree())
{
ReadFromDictNode(subtree, info);
@ -279,9 +284,14 @@ namespace MediaBrowser.MediaEncoding.Probing
}
break;
case "array":
if (!string.IsNullOrWhiteSpace(currentKey))
if (reader.IsEmptyElement)
{
using (var subtree = reader.ReadSubtree())
reader.Read();
continue;
}
using (var subtree = reader.ReadSubtree())
{
if (!string.IsNullOrWhiteSpace(currentKey))
{
pairs.AddRange(ReadValueArray(subtree));
}
@ -315,6 +325,12 @@ namespace MediaBrowser.MediaEncoding.Probing
switch (reader.Name)
{
case "dict":
if (reader.IsEmptyElement)
{
reader.Read();
continue;
}
using (var subtree = reader.ReadSubtree())
{
var dict = GetNameValuePair(subtree);

@ -274,6 +274,11 @@ namespace MediaBrowser.Providers.Music
{
case "release-list":
{
if (reader.IsEmptyElement)
{
reader.Read();
continue;
}
using (var subReader = reader.ReadSubtree())
{
return ParseReleaseList(subReader);
@ -311,6 +316,11 @@ namespace MediaBrowser.Providers.Music
{
case "release":
{
if (reader.IsEmptyElement)
{
reader.Read();
continue;
}
var releaseId = reader.GetAttribute("id");
using (var subReader = reader.ReadSubtree())
@ -435,6 +445,11 @@ namespace MediaBrowser.Providers.Music
{
case "release-group-list":
{
if (reader.IsEmptyElement)
{
reader.Read();
continue;
}
using (var subReader = reader.ReadSubtree())
{
return GetFirstReleaseGroupId(subReader);

@ -97,6 +97,11 @@ namespace MediaBrowser.Providers.Music
{
case "artist-list":
{
if (reader.IsEmptyElement)
{
reader.Read();
continue;
}
using (var subReader = reader.ReadSubtree())
{
return ParseArtistList(subReader);
@ -136,6 +141,11 @@ namespace MediaBrowser.Providers.Music
{
case "artist":
{
if (reader.IsEmptyElement)
{
reader.Read();
continue;
}
var mbzId = reader.GetAttribute("id");
using (var subReader = reader.ReadSubtree())

@ -127,6 +127,11 @@ namespace MediaBrowser.Providers.People
{
case "Actor":
{
if (reader.IsEmptyElement)
{
reader.Read();
continue;
}
using (var subtree = reader.ReadSubtree())
{
var info = FetchImageInfoFromActorNode(personName, subtree);

@ -139,6 +139,11 @@ namespace MediaBrowser.Providers.TV
{
case "Banner":
{
if (reader.IsEmptyElement)
{
reader.Read();
continue;
}
using (var subtree = reader.ReadSubtree())
{
AddImage(subtree, list, seasonNumber);

@ -126,6 +126,11 @@ namespace MediaBrowser.Providers.TV
{
case "Banner":
{
if (reader.IsEmptyElement)
{
reader.Read();
continue;
}
using (var subtree = reader.ReadSubtree())
{
AddImage(subtree, list);

@ -314,6 +314,11 @@ namespace MediaBrowser.Providers.TV
{
case "Series":
{
if (reader.IsEmptyElement)
{
reader.Read();
continue;
}
using (var subtree = reader.ReadSubtree())
{
return FindSeriesId(subtree);
@ -559,6 +564,11 @@ namespace MediaBrowser.Providers.TV
{
case "Series":
{
if (reader.IsEmptyElement)
{
reader.Read();
continue;
}
using (var subtree = reader.ReadSubtree())
{
var searchResult = GetSeriesSearchResultFromSubTree(subtree, comparableName);
@ -799,6 +809,11 @@ namespace MediaBrowser.Providers.TV
{
case "Series":
{
if (reader.IsEmptyElement)
{
reader.Read();
continue;
}
using (var subtree = reader.ReadSubtree())
{
FetchDataFromSeriesNode(result, subtree, cancellationToken);
@ -808,6 +823,11 @@ namespace MediaBrowser.Providers.TV
case "Episode":
{
if (reader.IsEmptyElement)
{
reader.Read();
continue;
}
using (var subtree = reader.ReadSubtree())
{
var date = GetFirstAiredDateFromEpisodeNode(subtree, cancellationToken);
@ -942,6 +962,11 @@ namespace MediaBrowser.Providers.TV
{
case "Actor":
{
if (reader.IsEmptyElement)
{
reader.Read();
continue;
}
using (var subtree = reader.ReadSubtree())
{
FetchDataFromActorNode(result, subtree);

@ -655,15 +655,22 @@ namespace MediaBrowser.XbmcMetadata.Parsers
case "actor":
{
using (var subtree = reader.ReadSubtree())
if (!reader.IsEmptyElement)
{
var person = GetPersonFromXmlNode(subtree);
if (!string.IsNullOrWhiteSpace(person.Name))
using (var subtree = reader.ReadSubtree())
{
itemResult.AddPerson(person);
var person = GetPersonFromXmlNode(subtree);
if (!string.IsNullOrWhiteSpace(person.Name))
{
itemResult.AddPerson(person);
}
}
}
else
{
reader.Read();
}
break;
}
@ -831,9 +838,16 @@ namespace MediaBrowser.XbmcMetadata.Parsers
case "fileinfo":
{
using (var subtree = reader.ReadSubtree())
if (!reader.IsEmptyElement)
{
FetchFromFileInfoNode(subtree, item);
using (var subtree = reader.ReadSubtree())
{
FetchFromFileInfoNode(subtree, item);
}
}
else
{
reader.Read();
}
break;
}
@ -896,15 +910,22 @@ namespace MediaBrowser.XbmcMetadata.Parsers
case "resume":
{
using (var subtree = reader.ReadSubtree())
if (!reader.IsEmptyElement)
{
if (!string.IsNullOrWhiteSpace(userDataUserId))
using (var subtree = reader.ReadSubtree())
{
var userData = GetOrAdd(itemResult, userDataUserId);
if (!string.IsNullOrWhiteSpace(userDataUserId))
{
var userData = GetOrAdd(itemResult, userDataUserId);
FetchFromResumeNode(subtree, item, userData);
FetchFromResumeNode(subtree, item, userData);
}
}
}
else
{
reader.Read();
}
break;
}
@ -1006,6 +1027,11 @@ namespace MediaBrowser.XbmcMetadata.Parsers
{
case "streamdetails":
{
if (reader.IsEmptyElement)
{
reader.Read();
continue;
}
using (var subtree = reader.ReadSubtree())
{
FetchFromStreamDetailsNode(subtree, item);
@ -1039,6 +1065,11 @@ namespace MediaBrowser.XbmcMetadata.Parsers
{
case "video":
{
if (reader.IsEmptyElement)
{
reader.Read();
continue;
}
using (var subtree = reader.ReadSubtree())
{
FetchFromVideoNode(subtree, item);

Loading…
Cancel
Save