diff --git a/MediaBrowser.Providers/Extensions/XDocumentExtensions.cs b/MediaBrowser.Providers/Extensions/XDocumentExtensions.cs
new file mode 100644
index 000000000..9df920955
--- /dev/null
+++ b/MediaBrowser.Providers/Extensions/XDocumentExtensions.cs
@@ -0,0 +1,18 @@
+using System.Xml;
+using System.Xml.Linq;
+
+namespace MediaBrowser.Providers.Extensions
+{
+ public static class XDocumentExtensions
+ {
+ public static XmlDocument ToXmlDocument(this XElement xDocument)
+ {
+ var xmlDocument = new XmlDocument();
+ using (var xmlReader = xDocument.CreateReader())
+ {
+ xmlDocument.Load(xmlReader);
+ }
+ return xmlDocument;
+ }
+ }
+}
\ No newline at end of file
diff --git a/MediaBrowser.Providers/MediaBrowser.Providers.csproj b/MediaBrowser.Providers/MediaBrowser.Providers.csproj
index f8aa4e272..74397a458 100644
--- a/MediaBrowser.Providers/MediaBrowser.Providers.csproj
+++ b/MediaBrowser.Providers/MediaBrowser.Providers.csproj
@@ -45,6 +45,7 @@
+
diff --git a/MediaBrowser.Providers/TV/RemoteEpisodeProvider.cs b/MediaBrowser.Providers/TV/RemoteEpisodeProvider.cs
index 0ddc84c65..e67dd254b 100644
--- a/MediaBrowser.Providers/TV/RemoteEpisodeProvider.cs
+++ b/MediaBrowser.Providers/TV/RemoteEpisodeProvider.cs
@@ -1,4 +1,6 @@
-using MediaBrowser.Common.Extensions;
+using System.Collections.Generic;
+using System.Xml.Linq;
+using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities;
@@ -258,7 +260,30 @@ namespace MediaBrowser.Providers.TV
{
return status;
}
+ IEnumerable extraEpisodesNode = new XmlDocument[]{};
+ if (episode.IndexNumberEnd.HasValue)
+ {
+ var seriesXDocument = XDocument.Load(new XmlNodeReader(seriesXml));
+ if (usingAbsoluteData)
+ {
+ extraEpisodesNode =
+ seriesXDocument.Descendants("Episode")
+ .Where(
+ x =>
+ int.Parse(x.Element("absolute_number").Value) > episode.IndexNumber &&
+ int.Parse(x.Element("absolute_number").Value) <= episode.IndexNumberEnd.Value).OrderBy(x => x.Element("absolute_number").Value).Select(x => x.ToXmlDocument());
+ }
+ else
+ {
+ var all =
+ seriesXDocument.Descendants("Episode").Where(x => int.Parse(x.Element("SeasonNumber").Value) == seasonNumber.Value);
+
+ var xElements = all.Where(x => int.Parse(x.Element("EpisodeNumber").Value) > episode.IndexNumber && int.Parse(x.Element("EpisodeNumber").Value) <= episode.IndexNumberEnd.Value);
+ extraEpisodesNode = xElements.OrderBy(x => x.Element("EpisodeNumber").Value).Select(x => x.ToXmlDocument());
+ }
+
+ }
var doc = new XmlDocument();
doc.LoadXml(episodeNode.OuterXml);
@@ -281,7 +306,8 @@ namespace MediaBrowser.Providers.TV
}
if (!episode.LockedFields.Contains(MetadataFields.Overview))
{
- episode.Overview = doc.SafeGetString("//Overview");
+ var extraOverview = extraEpisodesNode.Aggregate("", (current, xmlDocument) => current + ("\r\n\r\n" + xmlDocument.SafeGetString("//Overview")));
+ episode.Overview = doc.SafeGetString("//Overview") + extraOverview;
}
if (usingAbsoluteData)
episode.IndexNumber = doc.SafeGetInt32("//absolute_number", -1);
@@ -289,7 +315,8 @@ namespace MediaBrowser.Providers.TV
episode.IndexNumber = doc.SafeGetInt32("//EpisodeNumber");
if (!episode.LockedFields.Contains(MetadataFields.Name))
{
- episode.Name = doc.SafeGetString("//EpisodeName");
+ var extraNames = extraEpisodesNode.Aggregate("", (current, xmlDocument) => current + (", " + xmlDocument.SafeGetString("//EpisodeName")));
+ episode.Name = doc.SafeGetString("//EpisodeName") + extraNames;
}
episode.CommunityRating = doc.SafeGetSingle("//Rating", -1, 10);
var firstAired = doc.SafeGetString("//FirstAired");
@@ -314,7 +341,18 @@ namespace MediaBrowser.Providers.TV
episode.AddPerson(person);
}
}
-
+ foreach (var xmlDocument in extraEpisodesNode)
+ {
+ var extraActors = xmlDocument.SafeGetString("//GuestStars");
+ if (extraActors == null) continue;
+ // Sometimes tvdb actors have leading spaces
+ foreach (var person in extraActors.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries)
+ .Where(i => !string.IsNullOrWhiteSpace(i))
+ .Select(str => new PersonInfo { Type = PersonType.GuestStar, Name = str.Trim() }).Where(person => !episode.People.Any(x=>x.Type == person.Type && x.Name == person.Name)))
+ {
+ episode.AddPerson(person);
+ }
+ }
var directors = doc.SafeGetString("//Director");
if (directors != null)