diff --git a/MediaBrowser.Common/Extensions/BaseExtensions.cs b/MediaBrowser.Common/Extensions/BaseExtensions.cs
index 6d95cfa576..452c471593 100644
--- a/MediaBrowser.Common/Extensions/BaseExtensions.cs
+++ b/MediaBrowser.Common/Extensions/BaseExtensions.cs
@@ -20,9 +20,40 @@ namespace MediaBrowser.Common.Extensions
{
// http://stackoverflow.com/questions/1349023/how-can-i-strip-html-from-text-in-net
const string pattern = @"<(.|\n)*?>";
+
return Regex.Replace(htmlString, pattern, string.Empty).Trim();
}
+ ///
+ /// Replaces the specified STR.
+ ///
+ /// The STR.
+ /// The old value.
+ /// The new value.
+ /// The comparison.
+ /// System.String.
+ public static string Replace(this string str, string oldValue, string newValue, StringComparison comparison)
+ {
+ var sb = new StringBuilder();
+
+ var previousIndex = 0;
+ var index = str.IndexOf(oldValue, comparison);
+
+ while (index != -1)
+ {
+ sb.Append(str.Substring(previousIndex, index - previousIndex));
+ sb.Append(newValue);
+ index += oldValue.Length;
+
+ previousIndex = index;
+ index = str.IndexOf(oldValue, index, comparison);
+ }
+
+ sb.Append(str.Substring(previousIndex));
+
+ return sb.ToString();
+ }
+
///
/// Gets the M d5.
///
diff --git a/MediaBrowser.Providers/MediaInfo/FFProbeAudioInfoProvider.cs b/MediaBrowser.Providers/MediaInfo/FFProbeAudioInfoProvider.cs
index b9ef39be9f..3594c53c5b 100644
--- a/MediaBrowser.Providers/MediaInfo/FFProbeAudioInfoProvider.cs
+++ b/MediaBrowser.Providers/MediaInfo/FFProbeAudioInfoProvider.cs
@@ -1,4 +1,5 @@
-using MediaBrowser.Common.MediaInfo;
+using MediaBrowser.Common.Extensions;
+using MediaBrowser.Common.MediaInfo;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio;
@@ -114,7 +115,7 @@ namespace MediaBrowser.Providers.MediaInfo
if (!string.IsNullOrWhiteSpace(composer))
{
- foreach (var person in Split(composer, true))
+ foreach (var person in Split(composer))
{
audio.AddPerson(new PersonInfo { Name = person, Type = PersonType.Composer });
}
@@ -131,7 +132,7 @@ namespace MediaBrowser.Providers.MediaInfo
}
else
{
- audio.Artists = Split(artist, false)
+ audio.Artists = SplitArtists(artist)
.Distinct(StringComparer.OrdinalIgnoreCase)
.ToList();
@@ -181,13 +182,28 @@ namespace MediaBrowser.Providers.MediaInfo
/// Splits the specified val.
///
/// The val.
- /// if set to true [allow split by comma].
/// System.String[][].
- private IEnumerable Split(string val, bool allowSplitByComma)
+ private IEnumerable Split(string val)
{
// 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
- var delimeter = allowSplitByComma ? (_nameDelimiters.Any(i => val.IndexOf(i) != -1) ? _nameDelimiters : new[] { ',' }) : _nameDelimiters;
+ var delimeter = _nameDelimiters.Any(i => val.IndexOf(i) != -1) ? _nameDelimiters : new[] { ',' };
+
+ return val.Split(delimeter, StringSplitOptions.RemoveEmptyEntries)
+ .Where(i => !string.IsNullOrWhiteSpace(i))
+ .Select(i => i.Trim());
+ }
+
+ private const string ArtistReplaceValue = " | ";
+
+ private IEnumerable SplitArtists(string val)
+ {
+ val = val.Replace(" featuring ", ArtistReplaceValue, StringComparison.OrdinalIgnoreCase)
+ .Replace(" feat. ", ArtistReplaceValue, StringComparison.OrdinalIgnoreCase);
+
+ // 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
+ var delimeter = _nameDelimiters;
return val.Split(delimeter, StringSplitOptions.RemoveEmptyEntries)
.Where(i => !string.IsNullOrWhiteSpace(i))
@@ -207,7 +223,7 @@ namespace MediaBrowser.Providers.MediaInfo
if (!string.IsNullOrEmpty(val))
{
// Sometimes the artist name is listed here, account for that
- var studios = Split(val, true).Where(i => !audio.HasArtist(i));
+ var studios = Split(val).Where(i => !audio.HasArtist(i));
foreach (var studio in studios)
{
@@ -229,7 +245,7 @@ namespace MediaBrowser.Providers.MediaInfo
{
audio.Genres.Clear();
- foreach (var genre in Split(val, true))
+ foreach (var genre in Split(val))
{
audio.AddGenre(genre);
}