fixes #1255 - [BUG] NFO handler doesn't handle NFOs with multiple episode details
This commit is contained in:
parent
ceed0241fd
commit
099c422a85
|
@ -107,7 +107,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
|||
/// <param name="metadataFile">The metadata file.</param>
|
||||
/// <param name="settings">The settings.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
private void Fetch(MetadataResult<T> item, string metadataFile, XmlReaderSettings settings, CancellationToken cancellationToken)
|
||||
protected virtual void Fetch(MetadataResult<T> item, string metadataFile, XmlReaderSettings settings, CancellationToken cancellationToken)
|
||||
{
|
||||
if (!SupportsUrlAfterClosingXmlTag)
|
||||
{
|
||||
|
@ -233,7 +233,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
|||
get { return "themoviedb.org/movie/"; }
|
||||
}
|
||||
|
||||
private void ParseProviderLinks(T item, string xml)
|
||||
protected void ParseProviderLinks(T item, string xml)
|
||||
{
|
||||
//Look for a match for the Regex pattern "tt" followed by 7 digits
|
||||
Match m = Regex.Match(xml, @"tt([0-9]{7})", RegexOptions.IgnoreCase);
|
||||
|
|
|
@ -9,6 +9,8 @@ using System.Threading;
|
|||
using System.Xml;
|
||||
using MediaBrowser.Model.IO;
|
||||
using MediaBrowser.Model.Xml;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace MediaBrowser.XbmcMetadata.Parsers
|
||||
{
|
||||
|
@ -24,6 +26,65 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
|||
|
||||
private static readonly CultureInfo UsCulture = new CultureInfo("en-US");
|
||||
|
||||
protected override void Fetch(MetadataResult<Episode> item, string metadataFile, XmlReaderSettings settings, CancellationToken cancellationToken)
|
||||
{
|
||||
using (var fileStream = FileSystem.OpenRead(metadataFile))
|
||||
{
|
||||
using (var streamReader = new StreamReader(fileStream, Encoding.UTF8))
|
||||
{
|
||||
item.ResetPeople();
|
||||
|
||||
var xml = streamReader.ReadToEnd();
|
||||
|
||||
var srch = "</episodedetails>";
|
||||
var index = xml.IndexOf(srch, StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
if (index != -1)
|
||||
{
|
||||
xml = xml.Substring(0, index + srch.Length);
|
||||
}
|
||||
|
||||
using (var ms = new MemoryStream())
|
||||
{
|
||||
var bytes = Encoding.UTF8.GetBytes(xml);
|
||||
|
||||
ms.Write(bytes, 0, bytes.Length);
|
||||
ms.Position = 0;
|
||||
|
||||
// These are not going to be valid xml so no sense in causing the provider to fail and spamming the log with exceptions
|
||||
try
|
||||
{
|
||||
// Use XmlReader for best performance
|
||||
using (var reader = XmlReader.Create(ms, settings))
|
||||
{
|
||||
reader.MoveToContent();
|
||||
reader.Read();
|
||||
|
||||
// Loop through each element
|
||||
while (!reader.EOF && reader.ReadState == ReadState.Interactive)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
if (reader.NodeType == XmlNodeType.Element)
|
||||
{
|
||||
FetchDataFromXmlNode(reader, item);
|
||||
}
|
||||
else
|
||||
{
|
||||
reader.Read();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (XmlException)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fetches the data from XML node.
|
||||
/// </summary>
|
||||
|
|
Loading…
Reference in New Issue
Block a user