diff options
| author | Claus Vium <clausvium@gmail.com> | 2019-08-15 19:54:01 +0200 |
|---|---|---|
| committer | Claus Vium <clausvium@gmail.com> | 2019-08-15 19:54:01 +0200 |
| commit | 11504321b5e76a0eb9bda57bfcae4f85df994384 (patch) | |
| tree | 9dfd849690124e1411c550a1f97a397e3550b090 | |
| parent | f7f3627bb12eb06e104d5c52e074c45c37e6e4ca (diff) | |
Handle negative roleStartIndex since not all guest stars have roles
| -rw-r--r-- | MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeProvider.cs | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeProvider.cs b/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeProvider.cs index 5249a3fc0..5b0f326c0 100644 --- a/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeProvider.cs +++ b/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeProvider.cs @@ -205,31 +205,38 @@ namespace MediaBrowser.Providers.TV.TheTVDB var currentActor = episode.GuestStars[i]; var roleStartIndex = currentActor.IndexOf('('); - var roles = new List<string> {currentActor.Substring(roleStartIndex + 1)}; - var name = currentActor.Substring(0, roleStartIndex).Trim(); - - // Fetch all roles - for (var j = i + 1; j < episode.GuestStars.Length; ++j) + string name = currentActor; + string role = ""; + if (roleStartIndex != -1) { - var currentRole = episode.GuestStars[j]; - var roleEndIndex = currentRole.IndexOf(')'); + var roles = new List<string> {currentActor.Substring(roleStartIndex + 1)}; + name = name.Substring(0, roleStartIndex).Trim(); - if (roleEndIndex != -1) + // Fetch all roles + for (var j = i + 1; j < episode.GuestStars.Length; ++j) { - roles.Add(currentRole.TrimEnd(')')); - // Update the outer index (keep in mind it adds 1 after the iteration) - i = j; - break; + var currentRole = episode.GuestStars[j]; + var roleEndIndex = currentRole.IndexOf(')'); + + if (roleEndIndex != -1) + { + roles.Add(currentRole.TrimEnd(')')); + // Update the outer index (keep in mind it adds 1 after the iteration) + i = j; + break; + } + + roles.Add(currentRole); } - roles.Add(currentRole); + role = string.Join(", ", roles); } result.AddPerson(new PersonInfo { Type = PersonType.GuestStar, Name = name, - Role = string.Join(", ", roles) + Role = role }); } |
