Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Sep 24, 2024
2 parents d4f65c9 + 30be00a commit 56b48a4
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 6 deletions.
6 changes: 3 additions & 3 deletions MediaBrowser.Model/Configuration/LibraryOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down Expand Up @@ -126,8 +127,7 @@ public LibraryOptions()
[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; }

Expand Down
32 changes: 32 additions & 0 deletions MediaBrowser.Model/Extensions/LibraryOptionsExtension.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System;
using System.Linq;
using MediaBrowser.Model.Configuration;

namespace MediaBrowser.Model.Extensions;

/// <summary>
/// Extensions for <see cref="LibraryOptions"/>.
/// </summary>
public static class LibraryOptionsExtension
{
/// <summary>
/// Get the custom tag delimiters.
/// </summary>
/// <param name="options">This LibraryOptions.</param>
/// <returns>CustomTagDelimiters in char[].</returns>
public static char[] GetCustomTagDelimiters(this LibraryOptions options)
{
ArgumentNullException.ThrowIfNull(options);

return options.CustomTagDelimiters.Select<string, char?>(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();
}
}
7 changes: 4 additions & 3 deletions MediaBrowser.Providers/MediaInfo/AudioFileProber.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using MediaBrowser.Model.Dlna;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Extensions;
using MediaBrowser.Model.MediaInfo;
using Microsoft.Extensions.Logging;

Expand Down Expand Up @@ -178,7 +179,7 @@ private async Task FetchDataFromTags(Audio audio, Model.MediaInfo.MediaInfo medi

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)
Expand Down Expand Up @@ -210,7 +211,7 @@ private async Task FetchDataFromTags(Audio audio, Model.MediaInfo.MediaInfo medi

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)
Expand Down Expand Up @@ -313,7 +314,7 @@ private async Task FetchDataFromTags(Audio audio, Model.MediaInfo.MediaInfo medi

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
Expand Down

0 comments on commit 56b48a4

Please sign in to comment.