Merge pull request #2327 from MediaBrowser/dev

Dev
This commit is contained in:
Luke 2016-12-03 19:18:51 -05:00 committed by GitHub
commit 9f76369150
21 changed files with 461 additions and 220 deletions

View File

@ -129,19 +129,27 @@ namespace Emby.Dlna.Service
reader.Read(); reader.Read();
// Loop through each element // Loop through each element
while (!reader.EOF) while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
if (reader.NodeType == XmlNodeType.Element) if (reader.NodeType == XmlNodeType.Element)
{ {
switch (reader.LocalName) switch (reader.LocalName)
{ {
case "Body": case "Body":
{
if (!reader.IsEmptyElement)
{ {
using (var subReader = reader.ReadSubtree()) using (var subReader = reader.ReadSubtree())
{ {
return ParseBodyTag(subReader); return ParseBodyTag(subReader);
} }
} }
else
{
reader.Read();
}
break;
}
default: default:
{ {
reader.Skip(); reader.Skip();
@ -166,13 +174,15 @@ namespace Emby.Dlna.Service
reader.Read(); reader.Read();
// Loop through each element // Loop through each element
while (!reader.EOF) while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
if (reader.NodeType == XmlNodeType.Element) if (reader.NodeType == XmlNodeType.Element)
{ {
result.LocalName = reader.LocalName; result.LocalName = reader.LocalName;
result.NamespaceURI = reader.NamespaceURI; result.NamespaceURI = reader.NamespaceURI;
if (!reader.IsEmptyElement)
{
using (var subReader = reader.ReadSubtree()) using (var subReader = reader.ReadSubtree())
{ {
result.Headers = ParseFirstBodyChild(subReader); result.Headers = ParseFirstBodyChild(subReader);
@ -185,6 +195,11 @@ namespace Emby.Dlna.Service
reader.Read(); reader.Read();
} }
} }
else
{
reader.Read();
}
}
return result; return result;
} }
@ -197,7 +212,7 @@ namespace Emby.Dlna.Service
reader.Read(); reader.Read();
// Loop through each element // Loop through each element
while (!reader.EOF) while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
if (reader.NodeType == XmlNodeType.Element) if (reader.NodeType == XmlNodeType.Element)
{ {

View File

@ -4,6 +4,8 @@ using MediaBrowser.Model.Entities;
using MediaBrowser.Naming.Video; using MediaBrowser.Naming.Video;
using System; using System;
using System.IO; using System.IO;
using System.Linq;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Logging; using MediaBrowser.Model.Logging;
namespace Emby.Server.Implementations.Library.Resolvers namespace Emby.Server.Implementations.Library.Resolvers
@ -59,7 +61,7 @@ namespace Emby.Server.Implementations.Library.Resolvers
if (child.IsDirectory) if (child.IsDirectory)
{ {
if (IsDvdDirectory(filename)) if (IsDvdDirectory(child.FullName, filename, args.DirectoryService))
{ {
videoInfo = parser.ResolveDirectory(args.Path); videoInfo = parser.ResolveDirectory(args.Path);
@ -76,7 +78,7 @@ namespace Emby.Server.Implementations.Library.Resolvers
}; };
break; break;
} }
if (IsBluRayDirectory(filename)) if (IsBluRayDirectory(child.FullName, filename, args.DirectoryService))
{ {
videoInfo = parser.ResolveDirectory(args.Path); videoInfo = parser.ResolveDirectory(args.Path);
@ -267,11 +269,14 @@ namespace Emby.Server.Implementations.Library.Resolvers
/// <summary> /// <summary>
/// Determines whether [is DVD directory] [the specified directory name]. /// Determines whether [is DVD directory] [the specified directory name].
/// </summary> /// </summary>
/// <param name="directoryName">Name of the directory.</param> protected bool IsDvdDirectory(string fullPath, string directoryName, IDirectoryService directoryService)
/// <returns><c>true</c> if [is DVD directory] [the specified directory name]; otherwise, <c>false</c>.</returns>
protected bool IsDvdDirectory(string directoryName)
{ {
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));
} }
/// <summary> /// <summary>
@ -287,11 +292,14 @@ namespace Emby.Server.Implementations.Library.Resolvers
/// <summary> /// <summary>
/// Determines whether [is blu ray directory] [the specified directory name]. /// Determines whether [is blu ray directory] [the specified directory name].
/// </summary> /// </summary>
/// <param name="directoryName">Name of the directory.</param> protected bool IsBluRayDirectory(string fullPath, string directoryName, IDirectoryService directoryService)
/// <returns><c>true</c> if [is blu ray directory] [the specified directory name]; otherwise, <c>false</c>.</returns>
protected bool IsBluRayDirectory(string directoryName)
{ {
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));
} }
} }
} }

View File

@ -366,7 +366,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
if (child.IsDirectory) if (child.IsDirectory)
{ {
if (IsDvdDirectory(filename)) if (IsDvdDirectory(child.FullName, filename, directoryService))
{ {
var movie = new T var movie = new T
{ {
@ -376,7 +376,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
Set3DFormat(movie); Set3DFormat(movie);
return movie; return movie;
} }
if (IsBluRayDirectory(filename)) if (IsBluRayDirectory(child.FullName, filename, directoryService))
{ {
var movie = new T var movie = new T
{ {
@ -446,15 +446,14 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
var subfolders = subFileEntries var subfolders = subFileEntries
.Where(e => e.IsDirectory) .Where(e => e.IsDirectory)
.Select(d => d.Name)
.ToList(); .ToList();
if (subfolders.Any(IsDvdDirectory)) if (subfolders.Any(s => IsDvdDirectory(s.FullName, s.Name, directoryService)))
{ {
videoTypes.Add(VideoType.Dvd); videoTypes.Add(VideoType.Dvd);
return true; return true;
} }
if (subfolders.Any(IsBluRayDirectory)) if (subfolders.Any(s => IsBluRayDirectory(s.FullName, s.Name, directoryService)))
{ {
videoTypes.Add(VideoType.BluRay); videoTypes.Add(VideoType.BluRay);
return true; return true;

View File

@ -126,19 +126,27 @@ namespace Emby.Server.Implementations.News
reader.MoveToContent(); reader.MoveToContent();
reader.Read(); reader.Read();
while (!reader.EOF) while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
if (reader.NodeType == XmlNodeType.Element) if (reader.NodeType == XmlNodeType.Element)
{ {
switch (reader.Name) switch (reader.Name)
{ {
case "channel": case "channel":
{
if (!reader.IsEmptyElement)
{ {
using (var subReader = reader.ReadSubtree()) using (var subReader = reader.ReadSubtree())
{ {
return ParseFromChannelNode(subReader); return ParseFromChannelNode(subReader);
} }
} }
else
{
reader.Read();
}
break;
}
default: default:
{ {
reader.Skip(); reader.Skip();
@ -162,18 +170,25 @@ namespace Emby.Server.Implementations.News
reader.MoveToContent(); reader.MoveToContent();
reader.Read(); reader.Read();
while (!reader.EOF) while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
if (reader.NodeType == XmlNodeType.Element) if (reader.NodeType == XmlNodeType.Element)
{ {
switch (reader.Name) switch (reader.Name)
{ {
case "item": case "item":
{
if (!reader.IsEmptyElement)
{ {
using (var subReader = reader.ReadSubtree()) using (var subReader = reader.ReadSubtree())
{ {
list.Add(ParseItem(subReader)); list.Add(ParseItem(subReader));
} }
}
else
{
reader.Read();
}
break; break;
} }
default: default:
@ -199,7 +214,7 @@ namespace Emby.Server.Implementations.News
reader.MoveToContent(); reader.MoveToContent();
reader.Read(); reader.Read();
while (!reader.EOF) while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
if (reader.NodeType == XmlNodeType.Element) if (reader.NodeType == XmlNodeType.Element)
{ {

View File

@ -110,9 +110,10 @@ namespace MediaBrowser.LocalMetadata.Parsers
using (var reader = XmlReader.Create(streamReader, settings)) using (var reader = XmlReader.Create(streamReader, settings))
{ {
reader.MoveToContent(); reader.MoveToContent();
reader.Read();
// Loop through each element // Loop through each element
while (reader.Read()) while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
@ -120,6 +121,10 @@ namespace MediaBrowser.LocalMetadata.Parsers
{ {
FetchDataFromXmlNode(reader, item); FetchDataFromXmlNode(reader, item);
} }
else
{
reader.Read();
}
} }
} }
} }
@ -389,20 +394,34 @@ namespace MediaBrowser.LocalMetadata.Parsers
} }
case "TagLines": case "TagLines":
{
if (!reader.IsEmptyElement)
{ {
using (var subtree = reader.ReadSubtree()) using (var subtree = reader.ReadSubtree())
{ {
FetchFromTaglinesNode(subtree, item); FetchFromTaglinesNode(subtree, item);
} }
}
else
{
reader.Read();
}
break; break;
} }
case "Countries": case "Countries":
{
if (!reader.IsEmptyElement)
{ {
using (var subtree = reader.ReadSubtree()) using (var subtree = reader.ReadSubtree())
{ {
FetchFromCountriesNode(subtree, item); FetchFromCountriesNode(subtree, item);
} }
}
else
{
reader.Read();
}
break; break;
} }
@ -586,6 +605,8 @@ namespace MediaBrowser.LocalMetadata.Parsers
} }
case "Trailers": case "Trailers":
{
if (!reader.IsEmptyElement)
{ {
using (var subtree = reader.ReadSubtree()) using (var subtree = reader.ReadSubtree())
{ {
@ -595,6 +616,11 @@ namespace MediaBrowser.LocalMetadata.Parsers
FetchDataFromTrailersNode(subtree, hasTrailers); FetchDataFromTrailersNode(subtree, hasTrailers);
} }
} }
}
else
{
reader.Read();
}
break; break;
} }
@ -693,51 +719,88 @@ namespace MediaBrowser.LocalMetadata.Parsers
break; break;
case "Genres": case "Genres":
{
if (!reader.IsEmptyElement)
{ {
using (var subtree = reader.ReadSubtree()) using (var subtree = reader.ReadSubtree())
{ {
FetchFromGenresNode(subtree, item); FetchFromGenresNode(subtree, item);
} }
}
else
{
reader.Read();
}
break; break;
} }
case "Tags": case "Tags":
{
if (!reader.IsEmptyElement)
{ {
using (var subtree = reader.ReadSubtree()) using (var subtree = reader.ReadSubtree())
{ {
FetchFromTagsNode(subtree, item); FetchFromTagsNode(subtree, item);
} }
}
else
{
reader.Read();
}
break; break;
} }
case "PlotKeywords": case "PlotKeywords":
{
if (!reader.IsEmptyElement)
{ {
using (var subtree = reader.ReadSubtree()) using (var subtree = reader.ReadSubtree())
{ {
FetchFromKeywordsNode(subtree, item); FetchFromKeywordsNode(subtree, item);
} }
}
else
{
reader.Read();
}
break; break;
} }
case "Persons": case "Persons":
{
if (!reader.IsEmptyElement)
{ {
using (var subtree = reader.ReadSubtree()) using (var subtree = reader.ReadSubtree())
{ {
FetchDataFromPersonsNode(subtree, itemResult); FetchDataFromPersonsNode(subtree, itemResult);
} }
}
else
{
reader.Read();
}
break; break;
} }
case "Studios": case "Studios":
{
if (!reader.IsEmptyElement)
{ {
using (var subtree = reader.ReadSubtree()) using (var subtree = reader.ReadSubtree())
{ {
FetchFromStudiosNode(subtree, item); FetchFromStudiosNode(subtree, item);
} }
}
else
{
reader.Read();
}
break; break;
} }
case "Shares": case "Shares":
{
if (!reader.IsEmptyElement)
{ {
using (var subtree = reader.ReadSubtree()) using (var subtree = reader.ReadSubtree())
{ {
@ -747,17 +810,22 @@ namespace MediaBrowser.LocalMetadata.Parsers
FetchFromSharesNode(subtree, hasShares); FetchFromSharesNode(subtree, hasShares);
} }
} }
}
else
{
reader.Read();
}
break; break;
} }
case "Format3D": case "Format3D":
{ {
var val = reader.ReadElementContentAsString();
var video = item as Video; var video = item as Video;
if (video != null) if (video != null)
{ {
var val = reader.ReadElementContentAsString();
if (string.Equals("HSBS", val, StringComparison.OrdinalIgnoreCase)) if (string.Equals("HSBS", val, StringComparison.OrdinalIgnoreCase))
{ {
video.Video3DFormat = Video3DFormat.HalfSideBySide; video.Video3DFormat = Video3DFormat.HalfSideBySide;
@ -808,8 +876,10 @@ namespace MediaBrowser.LocalMetadata.Parsers
private void FetchFromSharesNode(XmlReader reader, IHasShares item) private void FetchFromSharesNode(XmlReader reader, IHasShares item)
{ {
reader.MoveToContent(); reader.MoveToContent();
reader.Read();
while (reader.Read()) // Loop through each element
while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
if (reader.NodeType == XmlNodeType.Element) if (reader.NodeType == XmlNodeType.Element)
{ {
@ -817,6 +887,11 @@ namespace MediaBrowser.LocalMetadata.Parsers
{ {
case "Share": case "Share":
{ {
if (reader.IsEmptyElement)
{
reader.Read();
continue;
}
using (var subtree = reader.ReadSubtree()) using (var subtree = reader.ReadSubtree())
{ {
var share = GetShareFromNode(subtree); var share = GetShareFromNode(subtree);
@ -833,6 +908,10 @@ namespace MediaBrowser.LocalMetadata.Parsers
break; break;
} }
} }
else
{
reader.Read();
}
} }
} }
@ -841,8 +920,10 @@ namespace MediaBrowser.LocalMetadata.Parsers
var share = new Share(); var share = new Share();
reader.MoveToContent(); reader.MoveToContent();
reader.Read();
while (reader.Read()) // Loop through each element
while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
if (reader.NodeType == XmlNodeType.Element) if (reader.NodeType == XmlNodeType.Element)
{ {
@ -865,6 +946,10 @@ namespace MediaBrowser.LocalMetadata.Parsers
break; break;
} }
} }
else
{
reader.Read();
}
} }
return share; return share;
@ -873,8 +958,10 @@ namespace MediaBrowser.LocalMetadata.Parsers
private void FetchFromCountriesNode(XmlReader reader, T item) private void FetchFromCountriesNode(XmlReader reader, T item)
{ {
reader.MoveToContent(); reader.MoveToContent();
reader.Read();
while (reader.Read()) // Loop through each element
while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
if (reader.NodeType == XmlNodeType.Element) if (reader.NodeType == XmlNodeType.Element)
{ {
@ -895,6 +982,10 @@ namespace MediaBrowser.LocalMetadata.Parsers
break; break;
} }
} }
else
{
reader.Read();
}
} }
} }
@ -909,7 +1000,7 @@ namespace MediaBrowser.LocalMetadata.Parsers
reader.Read(); reader.Read();
// Loop through each element // Loop through each element
while (!reader.EOF) while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
if (reader.NodeType == XmlNodeType.Element) if (reader.NodeType == XmlNodeType.Element)
{ {
@ -945,8 +1036,10 @@ namespace MediaBrowser.LocalMetadata.Parsers
private void FetchFromGenresNode(XmlReader reader, T item) private void FetchFromGenresNode(XmlReader reader, T item)
{ {
reader.MoveToContent(); reader.MoveToContent();
reader.Read();
while (reader.Read()) // Loop through each element
while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
if (reader.NodeType == XmlNodeType.Element) if (reader.NodeType == XmlNodeType.Element)
{ {
@ -968,14 +1061,20 @@ namespace MediaBrowser.LocalMetadata.Parsers
break; break;
} }
} }
else
{
reader.Read();
}
} }
} }
private void FetchFromTagsNode(XmlReader reader, BaseItem item) private void FetchFromTagsNode(XmlReader reader, BaseItem item)
{ {
reader.MoveToContent(); reader.MoveToContent();
reader.Read();
while (reader.Read()) // Loop through each element
while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
if (reader.NodeType == XmlNodeType.Element) if (reader.NodeType == XmlNodeType.Element)
{ {
@ -997,14 +1096,20 @@ namespace MediaBrowser.LocalMetadata.Parsers
break; break;
} }
} }
else
{
reader.Read();
}
} }
} }
private void FetchFromKeywordsNode(XmlReader reader, BaseItem item) private void FetchFromKeywordsNode(XmlReader reader, BaseItem item)
{ {
reader.MoveToContent(); reader.MoveToContent();
reader.Read();
while (reader.Read()) // Loop through each element
while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
if (reader.NodeType == XmlNodeType.Element) if (reader.NodeType == XmlNodeType.Element)
{ {
@ -1026,6 +1131,10 @@ namespace MediaBrowser.LocalMetadata.Parsers
break; break;
} }
} }
else
{
reader.Read();
}
} }
} }
@ -1037,8 +1146,10 @@ namespace MediaBrowser.LocalMetadata.Parsers
private void FetchDataFromPersonsNode(XmlReader reader, MetadataResult<T> item) private void FetchDataFromPersonsNode(XmlReader reader, MetadataResult<T> item)
{ {
reader.MoveToContent(); reader.MoveToContent();
reader.Read();
while (reader.Read()) // Loop through each element
while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
if (reader.NodeType == XmlNodeType.Element) if (reader.NodeType == XmlNodeType.Element)
{ {
@ -1047,6 +1158,11 @@ namespace MediaBrowser.LocalMetadata.Parsers
case "Person": case "Person":
case "Actor": case "Actor":
{ {
if (reader.IsEmptyElement)
{
reader.Read();
continue;
}
using (var subtree = reader.ReadSubtree()) using (var subtree = reader.ReadSubtree())
{ {
foreach (var person in GetPersonsFromXmlNode(subtree)) foreach (var person in GetPersonsFromXmlNode(subtree))
@ -1066,14 +1182,20 @@ namespace MediaBrowser.LocalMetadata.Parsers
break; break;
} }
} }
else
{
reader.Read();
}
} }
} }
private void FetchDataFromTrailersNode(XmlReader reader, IHasTrailers item) private void FetchDataFromTrailersNode(XmlReader reader, IHasTrailers item)
{ {
reader.MoveToContent(); reader.MoveToContent();
reader.Read();
while (reader.Read()) // Loop through each element
while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
if (reader.NodeType == XmlNodeType.Element) if (reader.NodeType == XmlNodeType.Element)
{ {
@ -1095,87 +1217,11 @@ namespace MediaBrowser.LocalMetadata.Parsers
break; break;
} }
} }
} else
}
protected List<ChapterInfo> FetchChaptersFromXmlNode(BaseItem item, XmlReader reader)
{ {
using (reader) reader.Read();
{
return GetChaptersFromXmlNode(reader)
.Where(i => i.StartPositionTicks >= 0)
.ToList();
} }
} }
private IEnumerable<ChapterInfo> GetChaptersFromXmlNode(XmlReader reader)
{
var chapters = new List<ChapterInfo>();
reader.MoveToContent();
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element)
{
switch (reader.Name)
{
case "Chapter":
{
using (var subtree = reader.ReadSubtree())
{
chapters.Add(GetChapterInfoFromXmlNode(subtree));
}
break;
}
default:
reader.Skip();
break;
}
}
}
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;
} }
/// <summary> /// <summary>
@ -1186,8 +1232,10 @@ namespace MediaBrowser.LocalMetadata.Parsers
private void FetchFromStudiosNode(XmlReader reader, T item) private void FetchFromStudiosNode(XmlReader reader, T item)
{ {
reader.MoveToContent(); reader.MoveToContent();
reader.Read();
while (reader.Read()) // Loop through each element
while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
if (reader.NodeType == XmlNodeType.Element) if (reader.NodeType == XmlNodeType.Element)
{ {
@ -1209,6 +1257,10 @@ namespace MediaBrowser.LocalMetadata.Parsers
break; break;
} }
} }
else
{
reader.Read();
}
} }
} }
@ -1225,8 +1277,10 @@ namespace MediaBrowser.LocalMetadata.Parsers
int? sortOrder = null; int? sortOrder = null;
reader.MoveToContent(); reader.MoveToContent();
reader.Read();
while (reader.Read()) // Loop through each element
while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
if (reader.NodeType == XmlNodeType.Element) if (reader.NodeType == XmlNodeType.Element)
{ {
@ -1277,6 +1331,10 @@ namespace MediaBrowser.LocalMetadata.Parsers
break; break;
} }
} }
else
{
reader.Read();
}
} }
var personInfo = new PersonInfo var personInfo = new PersonInfo
@ -1292,14 +1350,16 @@ namespace MediaBrowser.LocalMetadata.Parsers
protected LinkedChild GetLinkedChild(XmlReader reader) protected LinkedChild GetLinkedChild(XmlReader reader)
{ {
reader.MoveToContent();
var linkedItem = new LinkedChild var linkedItem = new LinkedChild
{ {
Type = LinkedChildType.Manual 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) if (reader.NodeType == XmlNodeType.Element)
{ {
@ -1316,6 +1376,10 @@ namespace MediaBrowser.LocalMetadata.Parsers
break; break;
} }
} }
else
{
reader.Read();
}
} }
// This is valid // This is valid
@ -1335,7 +1399,7 @@ namespace MediaBrowser.LocalMetadata.Parsers
reader.Read(); reader.Read();
// Loop through each element // Loop through each element
while (!reader.EOF) while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
if (reader.NodeType == XmlNodeType.Element) if (reader.NodeType == XmlNodeType.Element)
{ {

View File

@ -37,7 +37,7 @@ namespace MediaBrowser.LocalMetadata.Parsers
reader.Read(); reader.Read();
// Loop through each element // Loop through each element
while (!reader.EOF) while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
if (reader.NodeType == XmlNodeType.Element) if (reader.NodeType == XmlNodeType.Element)
{ {

View File

@ -43,18 +43,32 @@ namespace MediaBrowser.LocalMetadata.Parsers
case "PlaylistItems": case "PlaylistItems":
if (!reader.IsEmptyElement)
{
using (var subReader = reader.ReadSubtree()) using (var subReader = reader.ReadSubtree())
{ {
FetchFromCollectionItemsNode(subReader, item); FetchFromCollectionItemsNode(subReader, item);
} }
}
else
{
reader.Read();
}
break; break;
case "Shares": case "Shares":
if (!reader.IsEmptyElement)
{
using (var subReader = reader.ReadSubtree()) using (var subReader = reader.ReadSubtree())
{ {
FetchFromSharesNode(subReader, item); FetchFromSharesNode(subReader, item);
} }
}
else
{
reader.Read();
}
break; break;
default: default:
@ -71,7 +85,7 @@ namespace MediaBrowser.LocalMetadata.Parsers
reader.Read(); reader.Read();
// Loop through each element // Loop through each element
while (!reader.EOF) while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
if (reader.NodeType == XmlNodeType.Element) if (reader.NodeType == XmlNodeType.Element)
{ {
@ -79,6 +93,12 @@ namespace MediaBrowser.LocalMetadata.Parsers
{ {
case "PlaylistItem": case "PlaylistItem":
{ {
if (reader.IsEmptyElement)
{
reader.Read();
continue;
}
using (var subReader = reader.ReadSubtree()) using (var subReader = reader.ReadSubtree())
{ {
var child = GetLinkedChild(subReader); var child = GetLinkedChild(subReader);
@ -115,7 +135,7 @@ namespace MediaBrowser.LocalMetadata.Parsers
reader.Read(); reader.Read();
// Loop through each element // Loop through each element
while (!reader.EOF) while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
if (reader.NodeType == XmlNodeType.Element) if (reader.NodeType == XmlNodeType.Element)
{ {
@ -123,6 +143,12 @@ namespace MediaBrowser.LocalMetadata.Parsers
{ {
case "Share": case "Share":
{ {
if (reader.IsEmptyElement)
{
reader.Read();
continue;
}
using (var subReader = reader.ReadSubtree()) using (var subReader = reader.ReadSubtree())
{ {
var child = GetShare(subReader); var child = GetShare(subReader);

View File

@ -724,7 +724,7 @@ namespace MediaBrowser.LocalMetadata.Savers
reader.Read(); reader.Read();
// Loop through each element // Loop through each element
while (!reader.EOF) while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
if (reader.NodeType == XmlNodeType.Element) if (reader.NodeType == XmlNodeType.Element)
{ {

View File

@ -211,13 +211,18 @@ namespace MediaBrowser.MediaEncoding.Probing
reader.Read(); reader.Read();
// Loop through each element // Loop through each element
while (!reader.EOF) while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
if (reader.NodeType == XmlNodeType.Element) if (reader.NodeType == XmlNodeType.Element)
{ {
switch (reader.Name) switch (reader.Name)
{ {
case "dict": case "dict":
if (reader.IsEmptyElement)
{
reader.Read();
continue;
}
using (var subtree = reader.ReadSubtree()) using (var subtree = reader.ReadSubtree())
{ {
ReadFromDictNode(subtree, info); ReadFromDictNode(subtree, info);
@ -253,7 +258,7 @@ namespace MediaBrowser.MediaEncoding.Probing
reader.Read(); reader.Read();
// Loop through each element // Loop through each element
while (!reader.EOF) while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
if (reader.NodeType == XmlNodeType.Element) if (reader.NodeType == XmlNodeType.Element)
{ {
@ -279,9 +284,14 @@ namespace MediaBrowser.MediaEncoding.Probing
} }
break; break;
case "array": case "array":
if (!string.IsNullOrWhiteSpace(currentKey)) if (reader.IsEmptyElement)
{ {
reader.Read();
continue;
}
using (var subtree = reader.ReadSubtree()) using (var subtree = reader.ReadSubtree())
{
if (!string.IsNullOrWhiteSpace(currentKey))
{ {
pairs.AddRange(ReadValueArray(subtree)); pairs.AddRange(ReadValueArray(subtree));
} }
@ -308,13 +318,19 @@ namespace MediaBrowser.MediaEncoding.Probing
reader.Read(); reader.Read();
// Loop through each element // Loop through each element
while (!reader.EOF) while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
if (reader.NodeType == XmlNodeType.Element) if (reader.NodeType == XmlNodeType.Element)
{ {
switch (reader.Name) switch (reader.Name)
{ {
case "dict": case "dict":
if (reader.IsEmptyElement)
{
reader.Read();
continue;
}
using (var subtree = reader.ReadSubtree()) using (var subtree = reader.ReadSubtree())
{ {
var dict = GetNameValuePair(subtree); var dict = GetNameValuePair(subtree);
@ -397,7 +413,7 @@ namespace MediaBrowser.MediaEncoding.Probing
reader.Read(); reader.Read();
// Loop through each element // Loop through each element
while (!reader.EOF) while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
if (reader.NodeType == XmlNodeType.Element) if (reader.NodeType == XmlNodeType.Element)
{ {

View File

@ -266,7 +266,7 @@ namespace MediaBrowser.Providers.Music
reader.Read(); reader.Read();
// Loop through each element // Loop through each element
while (!reader.EOF) while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
if (reader.NodeType == XmlNodeType.Element) if (reader.NodeType == XmlNodeType.Element)
{ {
@ -274,6 +274,11 @@ namespace MediaBrowser.Providers.Music
{ {
case "release-list": case "release-list":
{ {
if (reader.IsEmptyElement)
{
reader.Read();
continue;
}
using (var subReader = reader.ReadSubtree()) using (var subReader = reader.ReadSubtree())
{ {
return ParseReleaseList(subReader); return ParseReleaseList(subReader);
@ -303,7 +308,7 @@ namespace MediaBrowser.Providers.Music
reader.Read(); reader.Read();
// Loop through each element // Loop through each element
while (!reader.EOF) while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
if (reader.NodeType == XmlNodeType.Element) if (reader.NodeType == XmlNodeType.Element)
{ {
@ -311,6 +316,11 @@ namespace MediaBrowser.Providers.Music
{ {
case "release": case "release":
{ {
if (reader.IsEmptyElement)
{
reader.Read();
continue;
}
var releaseId = reader.GetAttribute("id"); var releaseId = reader.GetAttribute("id");
using (var subReader = reader.ReadSubtree()) 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 // http://stackoverflow.com/questions/2299632/why-does-xmlreader-skip-every-other-element-if-there-is-no-whitespace-separator
// Loop through each element // Loop through each element
while (!reader.EOF) while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
if (reader.NodeType == XmlNodeType.Element) if (reader.NodeType == XmlNodeType.Element)
{ {
@ -427,7 +437,7 @@ namespace MediaBrowser.Providers.Music
reader.Read(); reader.Read();
// Loop through each element // Loop through each element
while (!reader.EOF) while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
if (reader.NodeType == XmlNodeType.Element) if (reader.NodeType == XmlNodeType.Element)
{ {
@ -435,6 +445,11 @@ namespace MediaBrowser.Providers.Music
{ {
case "release-group-list": case "release-group-list":
{ {
if (reader.IsEmptyElement)
{
reader.Read();
continue;
}
using (var subReader = reader.ReadSubtree()) using (var subReader = reader.ReadSubtree())
{ {
return GetFirstReleaseGroupId(subReader); return GetFirstReleaseGroupId(subReader);
@ -464,7 +479,7 @@ namespace MediaBrowser.Providers.Music
reader.Read(); reader.Read();
// Loop through each element // Loop through each element
while (!reader.EOF) while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
if (reader.NodeType == XmlNodeType.Element) if (reader.NodeType == XmlNodeType.Element)
{ {

View File

@ -89,7 +89,7 @@ namespace MediaBrowser.Providers.Music
reader.Read(); reader.Read();
// Loop through each element // Loop through each element
while (!reader.EOF) while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
if (reader.NodeType == XmlNodeType.Element) if (reader.NodeType == XmlNodeType.Element)
{ {
@ -97,6 +97,11 @@ namespace MediaBrowser.Providers.Music
{ {
case "artist-list": case "artist-list":
{ {
if (reader.IsEmptyElement)
{
reader.Read();
continue;
}
using (var subReader = reader.ReadSubtree()) using (var subReader = reader.ReadSubtree())
{ {
return ParseArtistList(subReader); return ParseArtistList(subReader);
@ -128,7 +133,7 @@ namespace MediaBrowser.Providers.Music
reader.Read(); reader.Read();
// Loop through each element // Loop through each element
while (!reader.EOF) while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
if (reader.NodeType == XmlNodeType.Element) if (reader.NodeType == XmlNodeType.Element)
{ {
@ -136,6 +141,11 @@ namespace MediaBrowser.Providers.Music
{ {
case "artist": case "artist":
{ {
if (reader.IsEmptyElement)
{
reader.Read();
continue;
}
var mbzId = reader.GetAttribute("id"); var mbzId = reader.GetAttribute("id");
using (var subReader = reader.ReadSubtree()) 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 // http://stackoverflow.com/questions/2299632/why-does-xmlreader-skip-every-other-element-if-there-is-no-whitespace-separator
// Loop through each element // Loop through each element
while (!reader.EOF) while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
if (reader.NodeType == XmlNodeType.Element) if (reader.NodeType == XmlNodeType.Element)
{ {

View File

@ -117,7 +117,7 @@ namespace MediaBrowser.Providers.People
reader.Read(); reader.Read();
// Loop through each element // Loop through each element
while (!reader.EOF) while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
@ -127,6 +127,11 @@ namespace MediaBrowser.Providers.People
{ {
case "Actor": case "Actor":
{ {
if (reader.IsEmptyElement)
{
reader.Read();
continue;
}
using (var subtree = reader.ReadSubtree()) using (var subtree = reader.ReadSubtree())
{ {
var info = FetchImageInfoFromActorNode(personName, subtree); var info = FetchImageInfoFromActorNode(personName, subtree);
@ -170,7 +175,7 @@ namespace MediaBrowser.Providers.People
reader.Read(); reader.Read();
// Loop through each element // Loop through each element
while (!reader.EOF) while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
if (reader.NodeType == XmlNodeType.Element) if (reader.NodeType == XmlNodeType.Element)
{ {

View File

@ -524,7 +524,7 @@ namespace MediaBrowser.Providers.TV
reader.Read(); reader.Read();
// Loop through each element // Loop through each element
while (!reader.EOF) while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
if (reader.NodeType == XmlNodeType.Element) if (reader.NodeType == XmlNodeType.Element)
{ {

View File

@ -86,7 +86,7 @@ namespace MediaBrowser.Providers.TV
reader.Read(); reader.Read();
// Loop through each element // Loop through each element
while (!reader.EOF) while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
if (reader.NodeType == XmlNodeType.Element) if (reader.NodeType == XmlNodeType.Element)
{ {

View File

@ -343,7 +343,7 @@ namespace MediaBrowser.Providers.TV
reader.Read(); reader.Read();
// Loop through each element // Loop through each element
while (!reader.EOF) while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
if (reader.NodeType == XmlNodeType.Element) if (reader.NodeType == XmlNodeType.Element)
{ {
@ -398,7 +398,7 @@ namespace MediaBrowser.Providers.TV
reader.Read(); reader.Read();
// Loop through each element // Loop through each element
while (!reader.EOF) while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
if (reader.NodeType == XmlNodeType.Element) if (reader.NodeType == XmlNodeType.Element)
{ {
@ -452,7 +452,7 @@ namespace MediaBrowser.Providers.TV
reader.Read(); reader.Read();
// Loop through each element // Loop through each element
while (!reader.EOF) while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
@ -825,7 +825,7 @@ namespace MediaBrowser.Providers.TV
reader.Read(); reader.Read();
// Loop through each element // Loop through each element
while (!reader.EOF) while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();

View File

@ -198,7 +198,7 @@ namespace MediaBrowser.Providers.TV
reader.Read(); reader.Read();
// Loop through each element // Loop through each element
while (!reader.EOF) while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
if (reader.NodeType == XmlNodeType.Element) if (reader.NodeType == XmlNodeType.Element)
{ {
@ -274,7 +274,7 @@ namespace MediaBrowser.Providers.TV
reader.Read(); reader.Read();
// Loop through each element // Loop through each element
while (!reader.EOF) while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
if (reader.NodeType == XmlNodeType.Element) if (reader.NodeType == XmlNodeType.Element)
{ {

View File

@ -129,7 +129,7 @@ namespace MediaBrowser.Providers.TV
reader.Read(); reader.Read();
// Loop through each element // Loop through each element
while (!reader.EOF) while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
@ -139,6 +139,11 @@ namespace MediaBrowser.Providers.TV
{ {
case "Banner": case "Banner":
{ {
if (reader.IsEmptyElement)
{
reader.Read();
continue;
}
using (var subtree = reader.ReadSubtree()) using (var subtree = reader.ReadSubtree())
{ {
AddImage(subtree, list, seasonNumber); AddImage(subtree, list, seasonNumber);
@ -204,7 +209,7 @@ namespace MediaBrowser.Providers.TV
reader.Read(); reader.Read();
// Loop through each element // Loop through each element
while (!reader.EOF) while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
if (reader.NodeType == XmlNodeType.Element) if (reader.NodeType == XmlNodeType.Element)
{ {

View File

@ -116,7 +116,7 @@ namespace MediaBrowser.Providers.TV
reader.Read(); reader.Read();
// Loop through each element // Loop through each element
while (!reader.EOF) while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
@ -126,6 +126,11 @@ namespace MediaBrowser.Providers.TV
{ {
case "Banner": case "Banner":
{ {
if (reader.IsEmptyElement)
{
reader.Read();
continue;
}
using (var subtree = reader.ReadSubtree()) using (var subtree = reader.ReadSubtree())
{ {
AddImage(subtree, list); AddImage(subtree, list);
@ -190,7 +195,7 @@ namespace MediaBrowser.Providers.TV
reader.Read(); reader.Read();
// Loop through each element // Loop through each element
while (!reader.EOF) while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
if (reader.NodeType == XmlNodeType.Element) if (reader.NodeType == XmlNodeType.Element)
{ {

View File

@ -306,7 +306,7 @@ namespace MediaBrowser.Providers.TV
reader.Read(); reader.Read();
// Loop through each element // Loop through each element
while (!reader.EOF) while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
if (reader.NodeType == XmlNodeType.Element) if (reader.NodeType == XmlNodeType.Element)
{ {
@ -314,6 +314,11 @@ namespace MediaBrowser.Providers.TV
{ {
case "Series": case "Series":
{ {
if (reader.IsEmptyElement)
{
reader.Read();
continue;
}
using (var subtree = reader.ReadSubtree()) using (var subtree = reader.ReadSubtree())
{ {
return FindSeriesId(subtree); return FindSeriesId(subtree);
@ -342,7 +347,7 @@ namespace MediaBrowser.Providers.TV
reader.Read(); reader.Read();
// Loop through each element // Loop through each element
while (!reader.EOF) while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
if (reader.NodeType == XmlNodeType.Element) if (reader.NodeType == XmlNodeType.Element)
{ {
@ -549,7 +554,7 @@ namespace MediaBrowser.Providers.TV
reader.Read(); reader.Read();
// Loop through each element // Loop through each element
while (!reader.EOF) while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
@ -559,6 +564,11 @@ namespace MediaBrowser.Providers.TV
{ {
case "Series": case "Series":
{ {
if (reader.IsEmptyElement)
{
reader.Read();
continue;
}
using (var subtree = reader.ReadSubtree()) using (var subtree = reader.ReadSubtree())
{ {
var searchResult = GetSeriesSearchResultFromSubTree(subtree, comparableName); var searchResult = GetSeriesSearchResultFromSubTree(subtree, comparableName);
@ -607,7 +617,7 @@ namespace MediaBrowser.Providers.TV
reader.Read(); reader.Read();
// Loop through each element // Loop through each element
while (!reader.EOF) while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
if (reader.NodeType == XmlNodeType.Element) if (reader.NodeType == XmlNodeType.Element)
{ {
@ -789,7 +799,7 @@ namespace MediaBrowser.Providers.TV
reader.Read(); reader.Read();
// Loop through each element // Loop through each element
while (!reader.EOF) while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
@ -799,6 +809,11 @@ namespace MediaBrowser.Providers.TV
{ {
case "Series": case "Series":
{ {
if (reader.IsEmptyElement)
{
reader.Read();
continue;
}
using (var subtree = reader.ReadSubtree()) using (var subtree = reader.ReadSubtree())
{ {
FetchDataFromSeriesNode(result, subtree, cancellationToken); FetchDataFromSeriesNode(result, subtree, cancellationToken);
@ -808,6 +823,11 @@ namespace MediaBrowser.Providers.TV
case "Episode": case "Episode":
{ {
if (reader.IsEmptyElement)
{
reader.Read();
continue;
}
using (var subtree = reader.ReadSubtree()) using (var subtree = reader.ReadSubtree())
{ {
var date = GetFirstAiredDateFromEpisodeNode(subtree, cancellationToken); var date = GetFirstAiredDateFromEpisodeNode(subtree, cancellationToken);
@ -849,7 +869,7 @@ namespace MediaBrowser.Providers.TV
reader.Read(); reader.Read();
// Loop through each element // Loop through each element
while (!reader.EOF) while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
@ -934,7 +954,7 @@ namespace MediaBrowser.Providers.TV
reader.Read(); reader.Read();
// Loop through each element // Loop through each element
while (!reader.EOF) while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
if (reader.NodeType == XmlNodeType.Element) if (reader.NodeType == XmlNodeType.Element)
{ {
@ -942,6 +962,11 @@ namespace MediaBrowser.Providers.TV
{ {
case "Actor": case "Actor":
{ {
if (reader.IsEmptyElement)
{
reader.Read();
continue;
}
using (var subtree = reader.ReadSubtree()) using (var subtree = reader.ReadSubtree())
{ {
FetchDataFromActorNode(result, subtree); FetchDataFromActorNode(result, subtree);
@ -978,7 +1003,7 @@ namespace MediaBrowser.Providers.TV
reader.Read(); reader.Read();
// Loop through each element // Loop through each element
while (!reader.EOF) while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
if (reader.NodeType == XmlNodeType.Element) if (reader.NodeType == XmlNodeType.Element)
{ {
@ -1056,7 +1081,7 @@ namespace MediaBrowser.Providers.TV
reader.Read(); reader.Read();
// Loop through each element // Loop through each element
while (!reader.EOF) while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
@ -1315,7 +1340,7 @@ namespace MediaBrowser.Providers.TV
reader.Read(); reader.Read();
// Loop through each element // Loop through each element
while (!reader.EOF) while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
if (reader.NodeType == XmlNodeType.Element) if (reader.NodeType == XmlNodeType.Element)
{ {
@ -1366,7 +1391,7 @@ namespace MediaBrowser.Providers.TV
reader.Read(); reader.Read();
// Loop through each element // Loop through each element
while (!reader.EOF) while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
if (reader.NodeType == XmlNodeType.Element) if (reader.NodeType == XmlNodeType.Element)
{ {

View File

@ -123,7 +123,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers
reader.Read(); reader.Read();
// Loop through each element // Loop through each element
while (!reader.EOF) while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
@ -203,7 +203,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers
reader.Read(); reader.Read();
// Loop through each element // Loop through each element
while (!reader.EOF) while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
@ -607,7 +607,8 @@ namespace MediaBrowser.XbmcMetadata.Parsers
case "director": 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)) if (string.IsNullOrWhiteSpace(p.Name))
{ {
@ -640,7 +641,8 @@ namespace MediaBrowser.XbmcMetadata.Parsers
case "writer": 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)) if (string.IsNullOrWhiteSpace(p.Name))
{ {
@ -652,6 +654,8 @@ namespace MediaBrowser.XbmcMetadata.Parsers
} }
case "actor": case "actor":
{
if (!reader.IsEmptyElement)
{ {
using (var subtree = reader.ReadSubtree()) using (var subtree = reader.ReadSubtree())
{ {
@ -662,6 +666,11 @@ namespace MediaBrowser.XbmcMetadata.Parsers
itemResult.AddPerson(person); itemResult.AddPerson(person);
} }
} }
}
else
{
reader.Read();
}
break; break;
} }
@ -828,11 +837,18 @@ namespace MediaBrowser.XbmcMetadata.Parsers
} }
case "fileinfo": case "fileinfo":
{
if (!reader.IsEmptyElement)
{ {
using (var subtree = reader.ReadSubtree()) using (var subtree = reader.ReadSubtree())
{ {
FetchFromFileInfoNode(subtree, item); FetchFromFileInfoNode(subtree, item);
} }
}
else
{
reader.Read();
}
break; break;
} }
@ -893,6 +909,8 @@ namespace MediaBrowser.XbmcMetadata.Parsers
} }
case "resume": case "resume":
{
if (!reader.IsEmptyElement)
{ {
using (var subtree = reader.ReadSubtree()) using (var subtree = reader.ReadSubtree())
{ {
@ -903,6 +921,11 @@ namespace MediaBrowser.XbmcMetadata.Parsers
FetchFromResumeNode(subtree, item, userData); FetchFromResumeNode(subtree, item, userData);
} }
} }
}
else
{
reader.Read();
}
break; break;
} }
@ -957,7 +980,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers
reader.Read(); reader.Read();
// Loop through each element // Loop through each element
while (!reader.EOF) while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
if (reader.NodeType == XmlNodeType.Element) if (reader.NodeType == XmlNodeType.Element)
{ {
@ -996,7 +1019,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers
reader.Read(); reader.Read();
// Loop through each element // Loop through each element
while (!reader.EOF) while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
if (reader.NodeType == XmlNodeType.Element) if (reader.NodeType == XmlNodeType.Element)
{ {
@ -1004,6 +1027,11 @@ namespace MediaBrowser.XbmcMetadata.Parsers
{ {
case "streamdetails": case "streamdetails":
{ {
if (reader.IsEmptyElement)
{
reader.Read();
continue;
}
using (var subtree = reader.ReadSubtree()) using (var subtree = reader.ReadSubtree())
{ {
FetchFromStreamDetailsNode(subtree, item); FetchFromStreamDetailsNode(subtree, item);
@ -1029,7 +1057,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers
reader.Read(); reader.Read();
// Loop through each element // Loop through each element
while (!reader.EOF) while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
if (reader.NodeType == XmlNodeType.Element) if (reader.NodeType == XmlNodeType.Element)
{ {
@ -1037,6 +1065,11 @@ namespace MediaBrowser.XbmcMetadata.Parsers
{ {
case "video": case "video":
{ {
if (reader.IsEmptyElement)
{
reader.Read();
continue;
}
using (var subtree = reader.ReadSubtree()) using (var subtree = reader.ReadSubtree())
{ {
FetchFromVideoNode(subtree, item); FetchFromVideoNode(subtree, item);
@ -1062,7 +1095,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers
reader.Read(); reader.Read();
// Loop through each element // Loop through each element
while (!reader.EOF) while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
if (reader.NodeType == XmlNodeType.Element) if (reader.NodeType == XmlNodeType.Element)
{ {
@ -1128,7 +1161,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers
reader.Read(); reader.Read();
// Loop through each element // Loop through each element
while (!reader.EOF) while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
if (reader.NodeType == XmlNodeType.Element) if (reader.NodeType == XmlNodeType.Element)
{ {

View File

@ -1066,7 +1066,7 @@ namespace MediaBrowser.XbmcMetadata.Savers
reader.Read(); reader.Read();
// Loop through each element // Loop through each element
while (!reader.EOF) while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{ {
if (reader.NodeType == XmlNodeType.Element) if (reader.NodeType == XmlNodeType.Element)
{ {