aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.MediaEncoding
diff options
context:
space:
mode:
authorLuke <luke.pulverenti@gmail.com>2016-12-03 15:01:21 -0500
committerGitHub <noreply@github.com>2016-12-03 15:01:21 -0500
commite455af7c5c96cdd9c6676f822292ea9ad8612450 (patch)
tree748195b2640352f661df7db6d77a9c0b6796890d /MediaBrowser.MediaEncoding
parent035f385d6c5d0844b714bad7ce01ed09745b98a0 (diff)
parentf5467021b0e8a86bf17d13404e8a6cff1d87d587 (diff)
Merge pull request #2325 from MediaBrowser/dev
Dev
Diffstat (limited to 'MediaBrowser.MediaEncoding')
-rw-r--r--MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs60
1 files changed, 37 insertions, 23 deletions
diff --git a/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs b/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs
index 09996e1d3..9804bc1db 100644
--- a/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs
+++ b/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs
@@ -188,7 +188,13 @@ namespace MediaBrowser.MediaEncoding.Probing
private void FetchFromItunesInfo(string xml, MediaInfo info)
{
// Make things simpler and strip out the dtd
- xml = xml.Substring(xml.IndexOf("<plist", StringComparison.OrdinalIgnoreCase));
+ var plistIndex = xml.IndexOf("<plist", StringComparison.OrdinalIgnoreCase);
+
+ if (plistIndex != -1)
+ {
+ xml = xml.Substring(plistIndex);
+ }
+
xml = "<?xml version=\"1.0\"?>" + xml;
// <?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>cast</key>\n\t<array>\n\t\t<dict>\n\t\t\t<key>name</key>\n\t\t\t<string>Blender Foundation</string>\n\t\t</dict>\n\t\t<dict>\n\t\t\t<key>name</key>\n\t\t\t<string>Janus Bager Kristensen</string>\n\t\t</dict>\n\t</array>\n\t<key>directors</key>\n\t<array>\n\t\t<dict>\n\t\t\t<key>name</key>\n\t\t\t<string>Sacha Goedegebure</string>\n\t\t</dict>\n\t</array>\n\t<key>studio</key>\n\t<string>Blender Foundation</string>\n</dict>\n</plist>\n
@@ -196,36 +202,44 @@ namespace MediaBrowser.MediaEncoding.Probing
{
using (var streamReader = new StreamReader(stream))
{
- // Use XmlReader for best performance
- using (var reader = XmlReader.Create(streamReader))
+ try
{
- reader.MoveToContent();
- reader.Read();
-
- // Loop through each element
- while (!reader.EOF)
+ // Use XmlReader for best performance
+ using (var reader = XmlReader.Create(streamReader))
{
- if (reader.NodeType == XmlNodeType.Element)
+ reader.MoveToContent();
+ reader.Read();
+
+ // Loop through each element
+ while (!reader.EOF)
{
- switch (reader.Name)
+ if (reader.NodeType == XmlNodeType.Element)
{
- case "dict":
- using (var subtree = reader.ReadSubtree())
- {
- ReadFromDictNode(subtree, info);
- }
- break;
- default:
- reader.Skip();
- break;
+ switch (reader.Name)
+ {
+ case "dict":
+ using (var subtree = reader.ReadSubtree())
+ {
+ ReadFromDictNode(subtree, info);
+ }
+ break;
+ default:
+ reader.Skip();
+ break;
+ }
+ }
+ else
+ {
+ reader.Read();
}
- }
- else
- {
- reader.Read();
}
}
}
+ catch (XmlException)
+ {
+ // I've seen probe examples where the iTunMOVI value is just "<"
+ // So we should not allow this to fail the entire probing operation
+ }
}
}
}