don't split artists by commas

This commit is contained in:
Luke Pulverenti 2013-09-08 11:54:57 -04:00
parent 9566876da4
commit 6d099c63d8

View file

@ -114,7 +114,7 @@ namespace MediaBrowser.Providers.MediaInfo
if (!string.IsNullOrWhiteSpace(composer)) if (!string.IsNullOrWhiteSpace(composer))
{ {
foreach (var person in Split(composer)) foreach (var person in Split(composer, true))
{ {
audio.AddPerson(new PersonInfo { Name = person, Type = PersonType.Composer }); audio.AddPerson(new PersonInfo { Name = person, Type = PersonType.Composer });
} }
@ -131,7 +131,7 @@ namespace MediaBrowser.Providers.MediaInfo
} }
else else
{ {
audio.Artists = Split(artist) audio.Artists = Split(artist, false)
.Distinct(StringComparer.OrdinalIgnoreCase) .Distinct(StringComparer.OrdinalIgnoreCase)
.ToList(); .ToList();
@ -181,12 +181,13 @@ namespace MediaBrowser.Providers.MediaInfo
/// Splits the specified val. /// Splits the specified val.
/// </summary> /// </summary>
/// <param name="val">The val.</param> /// <param name="val">The val.</param>
/// <param name="allowSplitByComma">if set to <c>true</c> [allow split by comma].</param>
/// <returns>System.String[][].</returns> /// <returns>System.String[][].</returns>
private IEnumerable<string> Split(string val) private IEnumerable<string> Split(string val, bool allowSplitByComma)
{ {
// Only use the comma as a delimeter if there are no slashes or pipes. // Only use the comma as a delimeter if there are no slashes or pipes.
// We want to be careful not to split names that have commas in them // We want to be careful not to split names that have commas in them
var delimeter = _nameDelimiters.Any(i => val.IndexOf(i) != -1) ? _nameDelimiters : new[] { ',' }; var delimeter = allowSplitByComma ? (_nameDelimiters.Any(i => val.IndexOf(i) != -1) ? _nameDelimiters : new[] { ',' }) : _nameDelimiters;
return val.Split(delimeter, StringSplitOptions.RemoveEmptyEntries) return val.Split(delimeter, StringSplitOptions.RemoveEmptyEntries)
.Where(i => !string.IsNullOrWhiteSpace(i)) .Where(i => !string.IsNullOrWhiteSpace(i))
@ -206,7 +207,7 @@ namespace MediaBrowser.Providers.MediaInfo
if (!string.IsNullOrEmpty(val)) if (!string.IsNullOrEmpty(val))
{ {
// Sometimes the artist name is listed here, account for that // Sometimes the artist name is listed here, account for that
var studios = Split(val).Where(i => !audio.HasArtist(i)); var studios = Split(val, true).Where(i => !audio.HasArtist(i));
foreach (var studio in studios) foreach (var studio in studios)
{ {
@ -228,7 +229,7 @@ namespace MediaBrowser.Providers.MediaInfo
{ {
audio.Genres.Clear(); audio.Genres.Clear();
foreach (var genre in Split(val)) foreach (var genre in Split(val, true))
{ {
audio.AddGenre(genre); audio.AddGenre(genre);
} }