aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Lavado <anthonylavado@users.noreply.github.com>2019-08-17 02:22:07 -0400
committerGitHub <noreply@github.com>2019-08-17 02:22:07 -0400
commit28d707604bb297d83603de85ac0f7ca6170795ee (patch)
treec0b00d1a6a70e879500006edb33b020b7cbfd4e2
parentf1f4b1a184313de94379c4ee3b0dcded0c10395f (diff)
parente4158d9703c8490a0a918422cb2180fec5cb65b9 (diff)
Merge pull request #1629 from cvium/fix_tvdb_guest_stars
Fix tvdb guest stars with multiple roles
-rw-r--r--MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeProvider.cs48
1 files changed, 39 insertions, 9 deletions
diff --git a/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeProvider.cs b/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeProvider.cs
index 112ad0560..e5287048d 100644
--- a/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeProvider.cs
+++ b/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeProvider.cs
@@ -179,24 +179,54 @@ namespace MediaBrowser.Providers.TV.TheTVDB
});
}
- foreach (var person in episode.GuestStars)
+ // GuestStars is a weird list of names and roles
+ // Example:
+ // 1: Some Actor (Role1
+ // 2: Role2
+ // 3: Role3)
+ // 4: Another Actor (Role1
+ // ...
+ for (var i = 0; i < episode.GuestStars.Length; ++i)
{
- var index = person.IndexOf('(');
- string role = null;
- var name = person;
+ var currentActor = episode.GuestStars[i];
+ var roleStartIndex = currentActor.IndexOf('(');
- if (index != -1)
+ if (roleStartIndex == -1)
{
- role = person.Substring(index + 1).Trim().TrimEnd(')');
+ result.AddPerson(new PersonInfo
+ {
+ Type = PersonType.GuestStar,
+ Name = currentActor,
+ Role = string.Empty
+ });
+ continue;
+ }
+
+ var roles = new List<string> {currentActor.Substring(roleStartIndex + 1)};
- name = person.Substring(0, index).Trim();
+ // Fetch all roles
+ for (var j = i + 1; j < episode.GuestStars.Length; ++j)
+ {
+ var currentRole = episode.GuestStars[j];
+ var roleEndIndex = currentRole.IndexOf(')');
+
+ if (roleEndIndex == -1)
+ {
+ roles.Add(currentRole);
+ continue;
+ }
+
+ roles.Add(currentRole.TrimEnd(')'));
+ // Update the outer index (keep in mind it adds 1 after the iteration)
+ i = j;
+ break;
}
result.AddPerson(new PersonInfo
{
Type = PersonType.GuestStar,
- Name = name,
- Role = role
+ Name = currentActor.Substring(0, roleStartIndex).Trim(),
+ Role = string.Join(", ", roles)
});
}