diff --git a/Emby.Dlna/Service/BaseControlHandler.cs b/Emby.Dlna/Service/BaseControlHandler.cs
index 35203edae..4ce047172 100644
--- a/Emby.Dlna/Service/BaseControlHandler.cs
+++ b/Emby.Dlna/Service/BaseControlHandler.cs
@@ -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,
@@ -129,19 +129,27 @@ namespace Emby.Dlna.Service
reader.Read();
// Loop through each element
- while (!reader.EOF)
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
if (reader.NodeType == XmlNodeType.Element)
{
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();
@@ -166,18 +174,25 @@ namespace Emby.Dlna.Service
reader.Read();
// Loop through each element
- while (!reader.EOF)
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
if (reader.NodeType == XmlNodeType.Element)
{
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
@@ -197,7 +212,7 @@ namespace Emby.Dlna.Service
reader.Read();
// Loop through each element
- while (!reader.EOF)
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
if (reader.NodeType == XmlNodeType.Element)
{
diff --git a/Emby.Server.Implementations/Library/Resolvers/BaseVideoResolver.cs b/Emby.Server.Implementations/Library/Resolvers/BaseVideoResolver.cs
index d9c3ac5ab..b337e1b9e 100644
--- a/Emby.Server.Implementations/Library/Resolvers/BaseVideoResolver.cs
+++ b/Emby.Server.Implementations/Library/Resolvers/BaseVideoResolver.cs
@@ -4,6 +4,8 @@ using MediaBrowser.Model.Entities;
using MediaBrowser.Naming.Video;
using System;
using System.IO;
+using System.Linq;
+using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Logging;
namespace Emby.Server.Implementations.Library.Resolvers
@@ -59,7 +61,7 @@ namespace Emby.Server.Implementations.Library.Resolvers
if (child.IsDirectory)
{
- if (IsDvdDirectory(filename))
+ if (IsDvdDirectory(child.FullName, filename, args.DirectoryService))
{
videoInfo = parser.ResolveDirectory(args.Path);
@@ -76,7 +78,7 @@ namespace Emby.Server.Implementations.Library.Resolvers
};
break;
}
- if (IsBluRayDirectory(filename))
+ if (IsBluRayDirectory(child.FullName, filename, args.DirectoryService))
{
videoInfo = parser.ResolveDirectory(args.Path);
@@ -267,11 +269,14 @@ namespace Emby.Server.Implementations.Library.Resolvers
///
/// Determines whether [is DVD directory] [the specified directory name].
///
- /// Name of the directory.
- /// true if [is DVD directory] [the specified directory name]; otherwise, false.
- protected bool IsDvdDirectory(string directoryName)
+ protected bool IsDvdDirectory(string fullPath, string directoryName, IDirectoryService directoryService)
{
- return string.Equals(directoryName, "video_ts", StringComparison.OrdinalIgnoreCase);
+ if (!string.Equals(directoryName, "video_ts", StringComparison.OrdinalIgnoreCase))
+ {
+ return false;
+ }
+
+ return directoryService.GetFiles(fullPath).Any(i => string.Equals(i.Extension, ".vob", StringComparison.OrdinalIgnoreCase));
}
///
@@ -287,11 +292,14 @@ namespace Emby.Server.Implementations.Library.Resolvers
///
/// Determines whether [is blu ray directory] [the specified directory name].
///
- /// Name of the directory.
- /// true if [is blu ray directory] [the specified directory name]; otherwise, false.
- protected bool IsBluRayDirectory(string directoryName)
+ protected bool IsBluRayDirectory(string fullPath, string directoryName, IDirectoryService directoryService)
{
- return string.Equals(directoryName, "bdmv", StringComparison.OrdinalIgnoreCase);
+ if (!string.Equals(directoryName, "bdmv", StringComparison.OrdinalIgnoreCase))
+ {
+ return false;
+ }
+
+ return directoryService.GetFiles(fullPath).Any(i => string.Equals(i.Extension, ".m2ts", StringComparison.OrdinalIgnoreCase));
}
}
}
diff --git a/Emby.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs b/Emby.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs
index 002505b56..55a63b4e5 100644
--- a/Emby.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs
+++ b/Emby.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs
@@ -366,7 +366,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
if (child.IsDirectory)
{
- if (IsDvdDirectory(filename))
+ if (IsDvdDirectory(child.FullName, filename, directoryService))
{
var movie = new T
{
@@ -376,7 +376,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
Set3DFormat(movie);
return movie;
}
- if (IsBluRayDirectory(filename))
+ if (IsBluRayDirectory(child.FullName, filename, directoryService))
{
var movie = new T
{
@@ -446,15 +446,14 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
var subfolders = subFileEntries
.Where(e => e.IsDirectory)
- .Select(d => d.Name)
.ToList();
- if (subfolders.Any(IsDvdDirectory))
+ if (subfolders.Any(s => IsDvdDirectory(s.FullName, s.Name, directoryService)))
{
videoTypes.Add(VideoType.Dvd);
return true;
}
- if (subfolders.Any(IsBluRayDirectory))
+ if (subfolders.Any(s => IsBluRayDirectory(s.FullName, s.Name, directoryService)))
{
videoTypes.Add(VideoType.BluRay);
return true;
diff --git a/Emby.Server.Implementations/News/NewsEntryPoint.cs b/Emby.Server.Implementations/News/NewsEntryPoint.cs
index 1497d066f..53c862d47 100644
--- a/Emby.Server.Implementations/News/NewsEntryPoint.cs
+++ b/Emby.Server.Implementations/News/NewsEntryPoint.cs
@@ -126,7 +126,7 @@ namespace Emby.Server.Implementations.News
reader.MoveToContent();
reader.Read();
- while (!reader.EOF)
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
if (reader.NodeType == XmlNodeType.Element)
{
@@ -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:
{
@@ -162,7 +170,7 @@ namespace Emby.Server.Implementations.News
reader.MoveToContent();
reader.Read();
- while (!reader.EOF)
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
if (reader.NodeType == XmlNodeType.Element)
{
@@ -170,9 +178,16 @@ namespace Emby.Server.Implementations.News
{
case "item":
{
- using (var subReader = reader.ReadSubtree())
+ if (!reader.IsEmptyElement)
{
- list.Add(ParseItem(subReader));
+ using (var subReader = reader.ReadSubtree())
+ {
+ list.Add(ParseItem(subReader));
+ }
+ }
+ else
+ {
+ reader.Read();
}
break;
}
@@ -199,7 +214,7 @@ namespace Emby.Server.Implementations.News
reader.MoveToContent();
reader.Read();
- while (!reader.EOF)
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
if (reader.NodeType == XmlNodeType.Element)
{
diff --git a/MediaBrowser.LocalMetadata/Parsers/BaseItemXmlParser.cs b/MediaBrowser.LocalMetadata/Parsers/BaseItemXmlParser.cs
index 31b13056c..d66cdf801 100644
--- a/MediaBrowser.LocalMetadata/Parsers/BaseItemXmlParser.cs
+++ b/MediaBrowser.LocalMetadata/Parsers/BaseItemXmlParser.cs
@@ -110,9 +110,10 @@ namespace MediaBrowser.LocalMetadata.Parsers
using (var reader = XmlReader.Create(streamReader, settings))
{
reader.MoveToContent();
+ reader.Read();
// Loop through each element
- while (reader.Read())
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
cancellationToken.ThrowIfCancellationRequested();
@@ -120,6 +121,10 @@ namespace MediaBrowser.LocalMetadata.Parsers
{
FetchDataFromXmlNode(reader, item);
}
+ else
+ {
+ reader.Read();
+ }
}
}
}
@@ -390,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;
}
@@ -587,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;
}
@@ -694,70 +720,112 @@ namespace MediaBrowser.LocalMetadata.Parsers
case "Genres":
{
- using (var subtree = reader.ReadSubtree())
+ if (!reader.IsEmptyElement)
{
- FetchFromGenresNode(subtree, item);
+ using (var subtree = reader.ReadSubtree())
+ {
+ FetchFromGenresNode(subtree, item);
+ }
+ }
+ else
+ {
+ 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;
}
case "Format3D":
{
+ var val = reader.ReadElementContentAsString();
+
var video = item as Video;
if (video != null)
{
- var val = reader.ReadElementContentAsString();
-
if (string.Equals("HSBS", val, StringComparison.OrdinalIgnoreCase))
{
video.Video3DFormat = Video3DFormat.HalfSideBySide;
@@ -808,8 +876,10 @@ namespace MediaBrowser.LocalMetadata.Parsers
private void FetchFromSharesNode(XmlReader reader, IHasShares item)
{
reader.MoveToContent();
+ reader.Read();
- while (reader.Read())
+ // Loop through each element
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
if (reader.NodeType == XmlNodeType.Element)
{
@@ -817,6 +887,11 @@ namespace MediaBrowser.LocalMetadata.Parsers
{
case "Share":
{
+ if (reader.IsEmptyElement)
+ {
+ reader.Read();
+ continue;
+ }
using (var subtree = reader.ReadSubtree())
{
var share = GetShareFromNode(subtree);
@@ -833,6 +908,10 @@ namespace MediaBrowser.LocalMetadata.Parsers
break;
}
}
+ else
+ {
+ reader.Read();
+ }
}
}
@@ -841,8 +920,10 @@ namespace MediaBrowser.LocalMetadata.Parsers
var share = new Share();
reader.MoveToContent();
+ reader.Read();
- while (reader.Read())
+ // Loop through each element
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
if (reader.NodeType == XmlNodeType.Element)
{
@@ -865,6 +946,10 @@ namespace MediaBrowser.LocalMetadata.Parsers
break;
}
}
+ else
+ {
+ reader.Read();
+ }
}
return share;
@@ -873,8 +958,10 @@ namespace MediaBrowser.LocalMetadata.Parsers
private void FetchFromCountriesNode(XmlReader reader, T item)
{
reader.MoveToContent();
+ reader.Read();
- while (reader.Read())
+ // Loop through each element
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
if (reader.NodeType == XmlNodeType.Element)
{
@@ -895,6 +982,10 @@ namespace MediaBrowser.LocalMetadata.Parsers
break;
}
}
+ else
+ {
+ reader.Read();
+ }
}
}
@@ -909,7 +1000,7 @@ namespace MediaBrowser.LocalMetadata.Parsers
reader.Read();
// Loop through each element
- while (!reader.EOF)
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
if (reader.NodeType == XmlNodeType.Element)
{
@@ -945,8 +1036,10 @@ namespace MediaBrowser.LocalMetadata.Parsers
private void FetchFromGenresNode(XmlReader reader, T item)
{
reader.MoveToContent();
+ reader.Read();
- while (reader.Read())
+ // Loop through each element
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
if (reader.NodeType == XmlNodeType.Element)
{
@@ -968,14 +1061,20 @@ namespace MediaBrowser.LocalMetadata.Parsers
break;
}
}
+ else
+ {
+ reader.Read();
+ }
}
}
private void FetchFromTagsNode(XmlReader reader, BaseItem item)
{
reader.MoveToContent();
+ reader.Read();
- while (reader.Read())
+ // Loop through each element
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
if (reader.NodeType == XmlNodeType.Element)
{
@@ -997,14 +1096,20 @@ namespace MediaBrowser.LocalMetadata.Parsers
break;
}
}
+ else
+ {
+ reader.Read();
+ }
}
}
private void FetchFromKeywordsNode(XmlReader reader, BaseItem item)
{
reader.MoveToContent();
+ reader.Read();
- while (reader.Read())
+ // Loop through each element
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
if (reader.NodeType == XmlNodeType.Element)
{
@@ -1026,6 +1131,10 @@ namespace MediaBrowser.LocalMetadata.Parsers
break;
}
}
+ else
+ {
+ reader.Read();
+ }
}
}
@@ -1037,8 +1146,10 @@ namespace MediaBrowser.LocalMetadata.Parsers
private void FetchDataFromPersonsNode(XmlReader reader, MetadataResult item)
{
reader.MoveToContent();
+ reader.Read();
- while (reader.Read())
+ // Loop through each element
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
if (reader.NodeType == XmlNodeType.Element)
{
@@ -1047,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))
@@ -1066,14 +1182,20 @@ namespace MediaBrowser.LocalMetadata.Parsers
break;
}
}
+ else
+ {
+ reader.Read();
+ }
}
}
private void FetchDataFromTrailersNode(XmlReader reader, IHasTrailers item)
{
reader.MoveToContent();
+ reader.Read();
- while (reader.Read())
+ // Loop through each element
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
if (reader.NodeType == XmlNodeType.Element)
{
@@ -1095,87 +1217,11 @@ namespace MediaBrowser.LocalMetadata.Parsers
break;
}
}
- }
- }
-
- protected List FetchChaptersFromXmlNode(BaseItem item, XmlReader reader)
- {
- using (reader)
- {
- return GetChaptersFromXmlNode(reader)
- .Where(i => i.StartPositionTicks >= 0)
- .ToList();
- }
- }
-
- private IEnumerable GetChaptersFromXmlNode(XmlReader reader)
- {
- var chapters = new List();
-
- reader.MoveToContent();
-
- while (reader.Read())
- {
- if (reader.NodeType == XmlNodeType.Element)
+ else
{
- switch (reader.Name)
- {
- case "Chapter":
- {
- using (var subtree = reader.ReadSubtree())
- {
- chapters.Add(GetChapterInfoFromXmlNode(subtree));
- }
- break;
- }
-
- default:
- reader.Skip();
- break;
- }
+ reader.Read();
}
}
-
- return chapters;
- }
-
- private ChapterInfo GetChapterInfoFromXmlNode(XmlReader reader)
- {
- var chapter = new ChapterInfo();
-
- reader.MoveToContent();
-
- while (reader.Read())
- {
- if (reader.NodeType == XmlNodeType.Element)
- {
- switch (reader.Name)
- {
- case "StartPositionMs":
- {
- var val = reader.ReadElementContentAsString();
-
- var ms = long.Parse(val, _usCulture);
-
- chapter.StartPositionTicks = TimeSpan.FromMilliseconds(ms).Ticks;
-
- break;
- }
-
- case "Name":
- {
- chapter.Name = reader.ReadElementContentAsString();
- break;
- }
-
- default:
- reader.Skip();
- break;
- }
- }
- }
-
- return chapter;
}
///
@@ -1186,8 +1232,10 @@ namespace MediaBrowser.LocalMetadata.Parsers
private void FetchFromStudiosNode(XmlReader reader, T item)
{
reader.MoveToContent();
+ reader.Read();
- while (reader.Read())
+ // Loop through each element
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
if (reader.NodeType == XmlNodeType.Element)
{
@@ -1209,6 +1257,10 @@ namespace MediaBrowser.LocalMetadata.Parsers
break;
}
}
+ else
+ {
+ reader.Read();
+ }
}
}
@@ -1225,8 +1277,10 @@ namespace MediaBrowser.LocalMetadata.Parsers
int? sortOrder = null;
reader.MoveToContent();
+ reader.Read();
- while (reader.Read())
+ // Loop through each element
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
if (reader.NodeType == XmlNodeType.Element)
{
@@ -1277,6 +1331,10 @@ namespace MediaBrowser.LocalMetadata.Parsers
break;
}
}
+ else
+ {
+ reader.Read();
+ }
}
var personInfo = new PersonInfo
@@ -1292,14 +1350,16 @@ namespace MediaBrowser.LocalMetadata.Parsers
protected LinkedChild GetLinkedChild(XmlReader reader)
{
- reader.MoveToContent();
-
var linkedItem = new LinkedChild
{
Type = LinkedChildType.Manual
};
- while (reader.Read())
+ reader.MoveToContent();
+ reader.Read();
+
+ // Loop through each element
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
if (reader.NodeType == XmlNodeType.Element)
{
@@ -1316,6 +1376,10 @@ namespace MediaBrowser.LocalMetadata.Parsers
break;
}
}
+ else
+ {
+ reader.Read();
+ }
}
// This is valid
@@ -1335,7 +1399,7 @@ namespace MediaBrowser.LocalMetadata.Parsers
reader.Read();
// Loop through each element
- while (!reader.EOF)
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
if (reader.NodeType == XmlNodeType.Element)
{
diff --git a/MediaBrowser.LocalMetadata/Parsers/BoxSetXmlParser.cs b/MediaBrowser.LocalMetadata/Parsers/BoxSetXmlParser.cs
index c42b44f9e..9dcfa2f76 100644
--- a/MediaBrowser.LocalMetadata/Parsers/BoxSetXmlParser.cs
+++ b/MediaBrowser.LocalMetadata/Parsers/BoxSetXmlParser.cs
@@ -37,7 +37,7 @@ namespace MediaBrowser.LocalMetadata.Parsers
reader.Read();
// Loop through each element
- while (!reader.EOF)
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
if (reader.NodeType == XmlNodeType.Element)
{
diff --git a/MediaBrowser.LocalMetadata/Parsers/PlaylistXmlParser.cs b/MediaBrowser.LocalMetadata/Parsers/PlaylistXmlParser.cs
index ee986ae2d..695fe2b12 100644
--- a/MediaBrowser.LocalMetadata/Parsers/PlaylistXmlParser.cs
+++ b/MediaBrowser.LocalMetadata/Parsers/PlaylistXmlParser.cs
@@ -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)
{
- FetchFromSharesNode(subReader, item);
+ using (var subReader = reader.ReadSubtree())
+ {
+ FetchFromSharesNode(subReader, item);
+ }
+ }
+ else
+ {
+ reader.Read();
}
break;
@@ -71,7 +85,7 @@ namespace MediaBrowser.LocalMetadata.Parsers
reader.Read();
// Loop through each element
- while (!reader.EOF)
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
if (reader.NodeType == XmlNodeType.Element)
{
@@ -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);
@@ -115,7 +135,7 @@ namespace MediaBrowser.LocalMetadata.Parsers
reader.Read();
// Loop through each element
- while (!reader.EOF)
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
if (reader.NodeType == XmlNodeType.Element)
{
@@ -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);
diff --git a/MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs b/MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs
index 02c34320b..b52bae2ce 100644
--- a/MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs
+++ b/MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs
@@ -724,7 +724,7 @@ namespace MediaBrowser.LocalMetadata.Savers
reader.Read();
// Loop through each element
- while (!reader.EOF)
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
if (reader.NodeType == XmlNodeType.Element)
{
diff --git a/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs b/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs
index 9804bc1db..de055146a 100644
--- a/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs
+++ b/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs
@@ -211,13 +211,18 @@ namespace MediaBrowser.MediaEncoding.Probing
reader.Read();
// Loop through each element
- while (!reader.EOF)
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
if (reader.NodeType == XmlNodeType.Element)
{
switch (reader.Name)
{
case "dict":
+ if (reader.IsEmptyElement)
+ {
+ reader.Read();
+ continue;
+ }
using (var subtree = reader.ReadSubtree())
{
ReadFromDictNode(subtree, info);
@@ -253,7 +258,7 @@ namespace MediaBrowser.MediaEncoding.Probing
reader.Read();
// Loop through each element
- while (!reader.EOF)
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
if (reader.NodeType == XmlNodeType.Element)
{
@@ -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));
}
@@ -308,13 +318,19 @@ namespace MediaBrowser.MediaEncoding.Probing
reader.Read();
// Loop through each element
- while (!reader.EOF)
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
if (reader.NodeType == XmlNodeType.Element)
{
switch (reader.Name)
{
case "dict":
+
+ if (reader.IsEmptyElement)
+ {
+ reader.Read();
+ continue;
+ }
using (var subtree = reader.ReadSubtree())
{
var dict = GetNameValuePair(subtree);
@@ -397,7 +413,7 @@ namespace MediaBrowser.MediaEncoding.Probing
reader.Read();
// Loop through each element
- while (!reader.EOF)
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
if (reader.NodeType == XmlNodeType.Element)
{
diff --git a/MediaBrowser.Providers/Music/MusicBrainzAlbumProvider.cs b/MediaBrowser.Providers/Music/MusicBrainzAlbumProvider.cs
index db5a1b18c..ec31824db 100644
--- a/MediaBrowser.Providers/Music/MusicBrainzAlbumProvider.cs
+++ b/MediaBrowser.Providers/Music/MusicBrainzAlbumProvider.cs
@@ -266,7 +266,7 @@ namespace MediaBrowser.Providers.Music
reader.Read();
// Loop through each element
- while (!reader.EOF)
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
if (reader.NodeType == XmlNodeType.Element)
{
@@ -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);
@@ -303,7 +308,7 @@ namespace MediaBrowser.Providers.Music
reader.Read();
// Loop through each element
- while (!reader.EOF)
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
if (reader.NodeType == XmlNodeType.Element)
{
@@ -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())
@@ -352,7 +362,7 @@ namespace MediaBrowser.Providers.Music
// http://stackoverflow.com/questions/2299632/why-does-xmlreader-skip-every-other-element-if-there-is-no-whitespace-separator
// Loop through each element
- while (!reader.EOF)
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
if (reader.NodeType == XmlNodeType.Element)
{
@@ -427,7 +437,7 @@ namespace MediaBrowser.Providers.Music
reader.Read();
// Loop through each element
- while (!reader.EOF)
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
if (reader.NodeType == XmlNodeType.Element)
{
@@ -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);
@@ -464,7 +479,7 @@ namespace MediaBrowser.Providers.Music
reader.Read();
// Loop through each element
- while (!reader.EOF)
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
if (reader.NodeType == XmlNodeType.Element)
{
diff --git a/MediaBrowser.Providers/Music/MusicBrainzArtistProvider.cs b/MediaBrowser.Providers/Music/MusicBrainzArtistProvider.cs
index 031207c33..1a2b13e94 100644
--- a/MediaBrowser.Providers/Music/MusicBrainzArtistProvider.cs
+++ b/MediaBrowser.Providers/Music/MusicBrainzArtistProvider.cs
@@ -89,7 +89,7 @@ namespace MediaBrowser.Providers.Music
reader.Read();
// Loop through each element
- while (!reader.EOF)
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
if (reader.NodeType == XmlNodeType.Element)
{
@@ -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);
@@ -128,7 +133,7 @@ namespace MediaBrowser.Providers.Music
reader.Read();
// Loop through each element
- while (!reader.EOF)
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
if (reader.NodeType == XmlNodeType.Element)
{
@@ -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())
@@ -174,7 +184,7 @@ namespace MediaBrowser.Providers.Music
// http://stackoverflow.com/questions/2299632/why-does-xmlreader-skip-every-other-element-if-there-is-no-whitespace-separator
// Loop through each element
- while (!reader.EOF)
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
if (reader.NodeType == XmlNodeType.Element)
{
diff --git a/MediaBrowser.Providers/People/TvdbPersonImageProvider.cs b/MediaBrowser.Providers/People/TvdbPersonImageProvider.cs
index 9335fca9f..dd3bfb4f8 100644
--- a/MediaBrowser.Providers/People/TvdbPersonImageProvider.cs
+++ b/MediaBrowser.Providers/People/TvdbPersonImageProvider.cs
@@ -117,7 +117,7 @@ namespace MediaBrowser.Providers.People
reader.Read();
// Loop through each element
- while (!reader.EOF)
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
cancellationToken.ThrowIfCancellationRequested();
@@ -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);
@@ -170,7 +175,7 @@ namespace MediaBrowser.Providers.People
reader.Read();
// Loop through each element
- while (!reader.EOF)
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
if (reader.NodeType == XmlNodeType.Element)
{
diff --git a/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs b/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs
index 873834bf6..05ca7c7d9 100644
--- a/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs
+++ b/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs
@@ -524,7 +524,7 @@ namespace MediaBrowser.Providers.TV
reader.Read();
// Loop through each element
- while (!reader.EOF)
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
if (reader.NodeType == XmlNodeType.Element)
{
diff --git a/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeImageProvider.cs b/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeImageProvider.cs
index 5bbcc9d15..791f56beb 100644
--- a/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeImageProvider.cs
+++ b/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeImageProvider.cs
@@ -86,7 +86,7 @@ namespace MediaBrowser.Providers.TV
reader.Read();
// Loop through each element
- while (!reader.EOF)
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
if (reader.NodeType == XmlNodeType.Element)
{
diff --git a/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeProvider.cs b/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeProvider.cs
index ecc0f6cee..99136cd85 100644
--- a/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeProvider.cs
+++ b/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeProvider.cs
@@ -343,7 +343,7 @@ namespace MediaBrowser.Providers.TV
reader.Read();
// Loop through each element
- while (!reader.EOF)
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
if (reader.NodeType == XmlNodeType.Element)
{
@@ -398,7 +398,7 @@ namespace MediaBrowser.Providers.TV
reader.Read();
// Loop through each element
- while (!reader.EOF)
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
if (reader.NodeType == XmlNodeType.Element)
{
@@ -452,7 +452,7 @@ namespace MediaBrowser.Providers.TV
reader.Read();
// Loop through each element
- while (!reader.EOF)
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
cancellationToken.ThrowIfCancellationRequested();
@@ -825,7 +825,7 @@ namespace MediaBrowser.Providers.TV
reader.Read();
// Loop through each element
- while (!reader.EOF)
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
cancellationToken.ThrowIfCancellationRequested();
diff --git a/MediaBrowser.Providers/TV/TheTVDB/TvdbPrescanTask.cs b/MediaBrowser.Providers/TV/TheTVDB/TvdbPrescanTask.cs
index ab40cdff5..8488c5669 100644
--- a/MediaBrowser.Providers/TV/TheTVDB/TvdbPrescanTask.cs
+++ b/MediaBrowser.Providers/TV/TheTVDB/TvdbPrescanTask.cs
@@ -198,7 +198,7 @@ namespace MediaBrowser.Providers.TV
reader.Read();
// Loop through each element
- while (!reader.EOF)
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
if (reader.NodeType == XmlNodeType.Element)
{
@@ -274,7 +274,7 @@ namespace MediaBrowser.Providers.TV
reader.Read();
// Loop through each element
- while (!reader.EOF)
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
if (reader.NodeType == XmlNodeType.Element)
{
diff --git a/MediaBrowser.Providers/TV/TheTVDB/TvdbSeasonImageProvider.cs b/MediaBrowser.Providers/TV/TheTVDB/TvdbSeasonImageProvider.cs
index 9454277df..e189c292c 100644
--- a/MediaBrowser.Providers/TV/TheTVDB/TvdbSeasonImageProvider.cs
+++ b/MediaBrowser.Providers/TV/TheTVDB/TvdbSeasonImageProvider.cs
@@ -129,7 +129,7 @@ namespace MediaBrowser.Providers.TV
reader.Read();
// Loop through each element
- while (!reader.EOF)
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
cancellationToken.ThrowIfCancellationRequested();
@@ -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);
@@ -204,7 +209,7 @@ namespace MediaBrowser.Providers.TV
reader.Read();
// Loop through each element
- while (!reader.EOF)
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
if (reader.NodeType == XmlNodeType.Element)
{
diff --git a/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesImageProvider.cs b/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesImageProvider.cs
index 5ad96300d..2595ad585 100644
--- a/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesImageProvider.cs
+++ b/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesImageProvider.cs
@@ -116,7 +116,7 @@ namespace MediaBrowser.Providers.TV
reader.Read();
// Loop through each element
- while (!reader.EOF)
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
cancellationToken.ThrowIfCancellationRequested();
@@ -126,6 +126,11 @@ namespace MediaBrowser.Providers.TV
{
case "Banner":
{
+ if (reader.IsEmptyElement)
+ {
+ reader.Read();
+ continue;
+ }
using (var subtree = reader.ReadSubtree())
{
AddImage(subtree, list);
@@ -190,7 +195,7 @@ namespace MediaBrowser.Providers.TV
reader.Read();
// Loop through each element
- while (!reader.EOF)
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
if (reader.NodeType == XmlNodeType.Element)
{
diff --git a/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesProvider.cs b/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesProvider.cs
index 41f19a5b5..cc8a90fe3 100644
--- a/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesProvider.cs
+++ b/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesProvider.cs
@@ -306,7 +306,7 @@ namespace MediaBrowser.Providers.TV
reader.Read();
// Loop through each element
- while (!reader.EOF)
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
if (reader.NodeType == XmlNodeType.Element)
{
@@ -314,6 +314,11 @@ namespace MediaBrowser.Providers.TV
{
case "Series":
{
+ if (reader.IsEmptyElement)
+ {
+ reader.Read();
+ continue;
+ }
using (var subtree = reader.ReadSubtree())
{
return FindSeriesId(subtree);
@@ -342,7 +347,7 @@ namespace MediaBrowser.Providers.TV
reader.Read();
// Loop through each element
- while (!reader.EOF)
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
if (reader.NodeType == XmlNodeType.Element)
{
@@ -549,7 +554,7 @@ namespace MediaBrowser.Providers.TV
reader.Read();
// Loop through each element
- while (!reader.EOF)
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
cancellationToken.ThrowIfCancellationRequested();
@@ -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);
@@ -607,7 +617,7 @@ namespace MediaBrowser.Providers.TV
reader.Read();
// Loop through each element
- while (!reader.EOF)
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
if (reader.NodeType == XmlNodeType.Element)
{
@@ -789,7 +799,7 @@ namespace MediaBrowser.Providers.TV
reader.Read();
// Loop through each element
- while (!reader.EOF)
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
cancellationToken.ThrowIfCancellationRequested();
@@ -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);
@@ -849,7 +869,7 @@ namespace MediaBrowser.Providers.TV
reader.Read();
// Loop through each element
- while (!reader.EOF)
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
cancellationToken.ThrowIfCancellationRequested();
@@ -934,7 +954,7 @@ namespace MediaBrowser.Providers.TV
reader.Read();
// Loop through each element
- while (!reader.EOF)
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
if (reader.NodeType == XmlNodeType.Element)
{
@@ -942,6 +962,11 @@ namespace MediaBrowser.Providers.TV
{
case "Actor":
{
+ if (reader.IsEmptyElement)
+ {
+ reader.Read();
+ continue;
+ }
using (var subtree = reader.ReadSubtree())
{
FetchDataFromActorNode(result, subtree);
@@ -978,7 +1003,7 @@ namespace MediaBrowser.Providers.TV
reader.Read();
// Loop through each element
- while (!reader.EOF)
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
if (reader.NodeType == XmlNodeType.Element)
{
@@ -1056,7 +1081,7 @@ namespace MediaBrowser.Providers.TV
reader.Read();
// Loop through each element
- while (!reader.EOF)
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
cancellationToken.ThrowIfCancellationRequested();
@@ -1315,7 +1340,7 @@ namespace MediaBrowser.Providers.TV
reader.Read();
// Loop through each element
- while (!reader.EOF)
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
if (reader.NodeType == XmlNodeType.Element)
{
@@ -1366,7 +1391,7 @@ namespace MediaBrowser.Providers.TV
reader.Read();
// Loop through each element
- while (!reader.EOF)
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
if (reader.NodeType == XmlNodeType.Element)
{
diff --git a/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs b/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs
index 548403347..dba6d96ac 100644
--- a/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs
+++ b/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs
@@ -123,7 +123,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers
reader.Read();
// Loop through each element
- while (!reader.EOF)
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
cancellationToken.ThrowIfCancellationRequested();
@@ -203,7 +203,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers
reader.Read();
// Loop through each element
- while (!reader.EOF)
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
cancellationToken.ThrowIfCancellationRequested();
@@ -607,7 +607,8 @@ namespace MediaBrowser.XbmcMetadata.Parsers
case "director":
{
- foreach (var p in SplitNames(reader.ReadElementContentAsString()).Select(v => new PersonInfo { Name = v.Trim(), Type = PersonType.Director }))
+ var val = reader.ReadElementContentAsString();
+ foreach (var p in SplitNames(val).Select(v => new PersonInfo { Name = v.Trim(), Type = PersonType.Director }))
{
if (string.IsNullOrWhiteSpace(p.Name))
{
@@ -640,7 +641,8 @@ namespace MediaBrowser.XbmcMetadata.Parsers
case "writer":
{
- foreach (var p in SplitNames(reader.ReadElementContentAsString()).Select(v => new PersonInfo { Name = v.Trim(), Type = PersonType.Writer }))
+ var val = reader.ReadElementContentAsString();
+ foreach (var p in SplitNames(val).Select(v => new PersonInfo { Name = v.Trim(), Type = PersonType.Writer }))
{
if (string.IsNullOrWhiteSpace(p.Name))
{
@@ -653,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;
}
@@ -829,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;
}
@@ -894,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;
}
@@ -957,7 +980,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers
reader.Read();
// Loop through each element
- while (!reader.EOF)
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
if (reader.NodeType == XmlNodeType.Element)
{
@@ -996,7 +1019,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers
reader.Read();
// Loop through each element
- while (!reader.EOF)
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
if (reader.NodeType == XmlNodeType.Element)
{
@@ -1004,6 +1027,11 @@ namespace MediaBrowser.XbmcMetadata.Parsers
{
case "streamdetails":
{
+ if (reader.IsEmptyElement)
+ {
+ reader.Read();
+ continue;
+ }
using (var subtree = reader.ReadSubtree())
{
FetchFromStreamDetailsNode(subtree, item);
@@ -1029,7 +1057,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers
reader.Read();
// Loop through each element
- while (!reader.EOF)
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
if (reader.NodeType == XmlNodeType.Element)
{
@@ -1037,6 +1065,11 @@ namespace MediaBrowser.XbmcMetadata.Parsers
{
case "video":
{
+ if (reader.IsEmptyElement)
+ {
+ reader.Read();
+ continue;
+ }
using (var subtree = reader.ReadSubtree())
{
FetchFromVideoNode(subtree, item);
@@ -1062,7 +1095,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers
reader.Read();
// Loop through each element
- while (!reader.EOF)
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
if (reader.NodeType == XmlNodeType.Element)
{
@@ -1128,7 +1161,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers
reader.Read();
// Loop through each element
- while (!reader.EOF)
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
if (reader.NodeType == XmlNodeType.Element)
{
diff --git a/MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs b/MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs
index 125ac5291..18936df01 100644
--- a/MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs
+++ b/MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs
@@ -1066,7 +1066,7 @@ namespace MediaBrowser.XbmcMetadata.Savers
reader.Read();
// Loop through each element
- while (!reader.EOF)
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
if (reader.NodeType == XmlNodeType.Element)
{