mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-07 03:48:06 +02:00
Merge branch 'master' of https://github.com/MediaBrowser/MediaBrowser
This commit is contained in:
commit
5d8ed2c16f
3 changed files with 61 additions and 4 deletions
18
MediaBrowser.Providers/Extensions/XDocumentExtensions.cs
Normal file
18
MediaBrowser.Providers/Extensions/XDocumentExtensions.cs
Normal file
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -45,6 +45,7 @@
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="Extensions\XDocumentExtensions.cs" />
|
||||||
<Compile Include="Extensions\XmlExtensions.cs" />
|
<Compile Include="Extensions\XmlExtensions.cs" />
|
||||||
<Compile Include="FanartBaseProvider.cs" />
|
<Compile Include="FanartBaseProvider.cs" />
|
||||||
<Compile Include="FolderProviderFromXml.cs" />
|
<Compile Include="FolderProviderFromXml.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.Common.Net;
|
||||||
using MediaBrowser.Controller.Configuration;
|
using MediaBrowser.Controller.Configuration;
|
||||||
using MediaBrowser.Controller.Entities;
|
using MediaBrowser.Controller.Entities;
|
||||||
|
@ -258,7 +260,30 @@ namespace MediaBrowser.Providers.TV
|
||||||
{
|
{
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
IEnumerable<XmlDocument> 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();
|
var doc = new XmlDocument();
|
||||||
doc.LoadXml(episodeNode.OuterXml);
|
doc.LoadXml(episodeNode.OuterXml);
|
||||||
|
|
||||||
|
@ -281,7 +306,8 @@ namespace MediaBrowser.Providers.TV
|
||||||
}
|
}
|
||||||
if (!episode.LockedFields.Contains(MetadataFields.Overview))
|
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)
|
if (usingAbsoluteData)
|
||||||
episode.IndexNumber = doc.SafeGetInt32("//absolute_number", -1);
|
episode.IndexNumber = doc.SafeGetInt32("//absolute_number", -1);
|
||||||
|
@ -289,7 +315,8 @@ namespace MediaBrowser.Providers.TV
|
||||||
episode.IndexNumber = doc.SafeGetInt32("//EpisodeNumber");
|
episode.IndexNumber = doc.SafeGetInt32("//EpisodeNumber");
|
||||||
if (!episode.LockedFields.Contains(MetadataFields.Name))
|
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);
|
episode.CommunityRating = doc.SafeGetSingle("//Rating", -1, 10);
|
||||||
var firstAired = doc.SafeGetString("//FirstAired");
|
var firstAired = doc.SafeGetString("//FirstAired");
|
||||||
|
@ -314,7 +341,18 @@ namespace MediaBrowser.Providers.TV
|
||||||
episode.AddPerson(person);
|
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");
|
var directors = doc.SafeGetString("//Director");
|
||||||
if (directors != null)
|
if (directors != null)
|
||||||
|
|
Loading…
Reference in a new issue