fixes #529 - Exception list for Artist with separators
This commit is contained in:
parent
a7eeb253d3
commit
de6d3d09ba
|
@ -206,7 +206,9 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup />
|
<ItemGroup>
|
||||||
|
<EmbeddedResource Include="MediaInfo\whitelist.txt" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition=" '$(ConfigurationName)' != 'Release Mono' " />
|
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition=" '$(ConfigurationName)' != 'Release Mono' " />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using MediaBrowser.Common.Extensions;
|
using System.IO;
|
||||||
|
using MediaBrowser.Common.Extensions;
|
||||||
using MediaBrowser.Controller.Entities;
|
using MediaBrowser.Controller.Entities;
|
||||||
using MediaBrowser.Controller.Entities.Audio;
|
using MediaBrowser.Controller.Entities.Audio;
|
||||||
using MediaBrowser.Controller.Library;
|
using MediaBrowser.Controller.Library;
|
||||||
|
@ -185,7 +186,7 @@ namespace MediaBrowser.Providers.MediaInfo
|
||||||
audio.SetProviderId(MetadataProviders.MusicBrainzReleaseGroup, FFProbeHelpers.GetDictionaryValue(tags, "MusicBrainz Release Group Id"));
|
audio.SetProviderId(MetadataProviders.MusicBrainzReleaseGroup, FFProbeHelpers.GetDictionaryValue(tags, "MusicBrainz Release Group Id"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly char[] _nameDelimiters = new[] { '/', '|', ';', '\\' };
|
private readonly char[] _nameDelimiters = { '/', '|', ';', '\\' };
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Splits the specified val.
|
/// Splits the specified val.
|
||||||
|
@ -210,13 +211,62 @@ namespace MediaBrowser.Providers.MediaInfo
|
||||||
val = val.Replace(" featuring ", ArtistReplaceValue, StringComparison.OrdinalIgnoreCase)
|
val = val.Replace(" featuring ", ArtistReplaceValue, StringComparison.OrdinalIgnoreCase)
|
||||||
.Replace(" feat. ", ArtistReplaceValue, StringComparison.OrdinalIgnoreCase);
|
.Replace(" feat. ", ArtistReplaceValue, StringComparison.OrdinalIgnoreCase);
|
||||||
|
|
||||||
|
var artistsFound = new List<string>();
|
||||||
|
|
||||||
|
foreach (var whitelistArtist in GetSplitWhitelist())
|
||||||
|
{
|
||||||
|
if (val.IndexOf(whitelistArtist, StringComparison.OrdinalIgnoreCase) != -1)
|
||||||
|
{
|
||||||
|
val = val.Replace(whitelistArtist, "|", StringComparison.OrdinalIgnoreCase);
|
||||||
|
|
||||||
|
// TODO: Preserve casing from original tag
|
||||||
|
artistsFound.Add(whitelistArtist);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 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;
|
var delimeter = _nameDelimiters;
|
||||||
|
|
||||||
return val.Split(delimeter, StringSplitOptions.RemoveEmptyEntries)
|
var artists = val.Split(delimeter, StringSplitOptions.RemoveEmptyEntries)
|
||||||
.Where(i => !string.IsNullOrWhiteSpace(i))
|
.Where(i => !string.IsNullOrWhiteSpace(i))
|
||||||
.Select(i => i.Trim());
|
.Select(i => i.Trim());
|
||||||
|
|
||||||
|
artistsFound.AddRange(artists);
|
||||||
|
return artistsFound;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private List<string> _splitWhiteList = null;
|
||||||
|
|
||||||
|
private IEnumerable<string> GetSplitWhitelist()
|
||||||
|
{
|
||||||
|
if (_splitWhiteList == null)
|
||||||
|
{
|
||||||
|
var file = GetType().Namespace + ".whitelist.txt";
|
||||||
|
|
||||||
|
using (var stream = GetType().Assembly.GetManifestResourceStream(file))
|
||||||
|
{
|
||||||
|
using (var reader = new StreamReader(stream))
|
||||||
|
{
|
||||||
|
var list = new List<string>();
|
||||||
|
|
||||||
|
while (!reader.EndOfStream)
|
||||||
|
{
|
||||||
|
var val = reader.ReadLine();
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(val))
|
||||||
|
{
|
||||||
|
list.Add(val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_splitWhiteList = list;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return _splitWhiteList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user