diff --git a/MediaBrowser.Model/Configuration/LibraryOptions.cs b/MediaBrowser.Model/Configuration/LibraryOptions.cs index 04283cc9ec..6054ba34e5 100644 --- a/MediaBrowser.Model/Configuration/LibraryOptions.cs +++ b/MediaBrowser.Model/Configuration/LibraryOptions.cs @@ -2,12 +2,13 @@ using System; using System.ComponentModel; +using System.Linq; namespace MediaBrowser.Model.Configuration { public class LibraryOptions { - private static readonly char[] _defaultTagDelimiters = ['/', '|', ';', '\\']; + private static readonly string[] _defaultTagDelimiters = ["/", "|", ";", "\\"]; public LibraryOptions() { @@ -126,8 +127,7 @@ namespace MediaBrowser.Model.Configuration [DefaultValue(false)] public bool UseCustomTagDelimiters { get; set; } - [DefaultValue(typeof(LibraryOptions), nameof(_defaultTagDelimiters))] - public char[] CustomTagDelimiters { get; set; } + public string[] CustomTagDelimiters { get; set; } public string[] DelimiterWhitelist { get; set; } diff --git a/MediaBrowser.Model/Extensions/LibraryOptionsExtension.cs b/MediaBrowser.Model/Extensions/LibraryOptionsExtension.cs new file mode 100644 index 0000000000..4a814f22a3 --- /dev/null +++ b/MediaBrowser.Model/Extensions/LibraryOptionsExtension.cs @@ -0,0 +1,32 @@ +using System; +using System.Linq; +using MediaBrowser.Model.Configuration; + +namespace MediaBrowser.Model.Extensions; + +/// +/// Extensions for . +/// +public static class LibraryOptionsExtension +{ + /// + /// Get the custom tag delimiters. + /// + /// This LibraryOptions. + /// CustomTagDelimiters in char[]. + public static char[] GetCustomTagDelimiters(this LibraryOptions options) + { + ArgumentNullException.ThrowIfNull(options); + + return options.CustomTagDelimiters.Select(x => + { + var isChar = char.TryParse(x, out var c); + if (isChar) + { + return c; + } + + return null; + }).Where(x => x is not null).Select(x => x!.Value).ToArray(); + } +} diff --git a/MediaBrowser.Providers/MediaInfo/AudioFileProber.cs b/MediaBrowser.Providers/MediaInfo/AudioFileProber.cs index 80bb1a514c..cb233d31e7 100644 --- a/MediaBrowser.Providers/MediaInfo/AudioFileProber.cs +++ b/MediaBrowser.Providers/MediaInfo/AudioFileProber.cs @@ -16,6 +16,7 @@ using MediaBrowser.Controller.Providers; using MediaBrowser.Model.Dlna; using MediaBrowser.Model.Dto; using MediaBrowser.Model.Entities; +using MediaBrowser.Model.Extensions; using MediaBrowser.Model.MediaInfo; using Microsoft.Extensions.Logging; @@ -178,7 +179,7 @@ namespace MediaBrowser.Providers.MediaInfo if (libraryOptions.UseCustomTagDelimiters) { - albumArtists = albumArtists.SelectMany(a => SplitWithCustomDelimiter(a, libraryOptions.CustomTagDelimiters, libraryOptions.DelimiterWhitelist)).ToArray(); + albumArtists = albumArtists.SelectMany(a => SplitWithCustomDelimiter(a, libraryOptions.GetCustomTagDelimiters(), libraryOptions.DelimiterWhitelist)).ToArray(); } foreach (var albumArtist in albumArtists) @@ -210,7 +211,7 @@ namespace MediaBrowser.Providers.MediaInfo if (libraryOptions.UseCustomTagDelimiters) { - performers = performers.SelectMany(p => SplitWithCustomDelimiter(p, libraryOptions.CustomTagDelimiters, libraryOptions.DelimiterWhitelist)).ToArray(); + performers = performers.SelectMany(p => SplitWithCustomDelimiter(p, libraryOptions.GetCustomTagDelimiters(), libraryOptions.DelimiterWhitelist)).ToArray(); } foreach (var performer in performers) @@ -313,7 +314,7 @@ namespace MediaBrowser.Providers.MediaInfo if (libraryOptions.UseCustomTagDelimiters) { - genres = genres.SelectMany(g => SplitWithCustomDelimiter(g, libraryOptions.CustomTagDelimiters, libraryOptions.DelimiterWhitelist)).ToArray(); + genres = genres.SelectMany(g => SplitWithCustomDelimiter(g, libraryOptions.GetCustomTagDelimiters(), libraryOptions.DelimiterWhitelist)).ToArray(); } audio.Genres = options.ReplaceAllMetadata || audio.Genres is null || audio.Genres.Length == 0