mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-07-22 05:30:46 +02:00
Fixes #308 - Parse GuestStars roles
This commit is contained in:
parent
8879240fc1
commit
7418a247ca
|
@ -1,4 +1,5 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
using MediaBrowser.Common.Extensions;
|
using MediaBrowser.Common.Extensions;
|
||||||
using MediaBrowser.Common.Net;
|
using MediaBrowser.Common.Net;
|
||||||
|
@ -313,9 +314,17 @@ namespace MediaBrowser.Providers.TV
|
||||||
if (actors != null)
|
if (actors != null)
|
||||||
{
|
{
|
||||||
// Sometimes tvdb actors have leading spaces
|
// Sometimes tvdb actors have leading spaces
|
||||||
foreach (var person in actors.Split(new[] {'|'}, StringSplitOptions.RemoveEmptyEntries)
|
var persons = Regex.Matches(actors, @"([^|()]|\([^)]*\)*)+")
|
||||||
.Where(i => !string.IsNullOrWhiteSpace(i))
|
.Cast<Match>()
|
||||||
.Select(str => new PersonInfo {Type = PersonType.GuestStar, Name = str.Trim()}))
|
.Select(m => m.Value).Where(i => !string.IsNullOrWhiteSpace(i) && !string.IsNullOrEmpty(i));
|
||||||
|
foreach (var person in persons.Select(str => {
|
||||||
|
var nameGroup = str.Split(new[] {'('}, 2, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
var name = nameGroup[0].Trim();
|
||||||
|
var roles = nameGroup.Count() > 1 ? nameGroup[1].Trim() : null;
|
||||||
|
if (roles != null)
|
||||||
|
roles = roles.EndsWith(")") ? roles.Substring(0, roles.Length - 1) : roles;
|
||||||
|
return new PersonInfo {Type = PersonType.GuestStar, Name = name, Role = roles};
|
||||||
|
}))
|
||||||
{
|
{
|
||||||
episode.AddPerson(person);
|
episode.AddPerson(person);
|
||||||
}
|
}
|
||||||
|
@ -325,9 +334,18 @@ namespace MediaBrowser.Providers.TV
|
||||||
var extraActors = xmlDocument.SafeGetString("//GuestStars");
|
var extraActors = xmlDocument.SafeGetString("//GuestStars");
|
||||||
if (extraActors == null) continue;
|
if (extraActors == null) continue;
|
||||||
// Sometimes tvdb actors have leading spaces
|
// Sometimes tvdb actors have leading spaces
|
||||||
foreach (var person in extraActors.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries)
|
var persons = Regex.Matches(extraActors, @"([^|()]|\([^)]*\)*)+")
|
||||||
.Where(i => !string.IsNullOrWhiteSpace(i))
|
.Cast<Match>()
|
||||||
.Select(str => new PersonInfo { Type = PersonType.GuestStar, Name = str.Trim() }).Where(person => !episode.People.Any(x=>x.Type == person.Type && x.Name == person.Name)))
|
.Select(m => m.Value).Where(i => !string.IsNullOrWhiteSpace(i) && !string.IsNullOrEmpty(i));
|
||||||
|
foreach (var person in persons.Select(str => {
|
||||||
|
var nameGroup = str.Split(new[] {'('}, 2, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
var name = nameGroup[0].Trim();
|
||||||
|
var roles = nameGroup.Count() > 1 ? nameGroup[1].Trim() : null;
|
||||||
|
if (roles != null)
|
||||||
|
roles = roles.EndsWith(")") ? roles.Substring(0, roles.Length - 1) : roles;
|
||||||
|
return new PersonInfo {Type = PersonType.GuestStar, Name = name, Role = roles};
|
||||||
|
}).Where(person => !episode.People.Any(x => x.Type == person.Type && x.Name == person.Name))
|
||||||
|
)
|
||||||
{
|
{
|
||||||
episode.AddPerson(person);
|
episode.AddPerson(person);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue