diff --git a/MediaBrowser.Model/Entities/ProviderIdsExtensions.cs b/MediaBrowser.Model/Entities/ProviderIdsExtensions.cs
index ce4b0ec92e..62a2f3ce84 100644
--- a/MediaBrowser.Model/Entities/ProviderIdsExtensions.cs
+++ b/MediaBrowser.Model/Entities/ProviderIdsExtensions.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
+using System.Linq;
namespace MediaBrowser.Model.Entities
{
@@ -9,6 +10,16 @@ namespace MediaBrowser.Model.Entities
///
public static class ProviderIdsExtensions
{
+ ///
+ /// Case insensitive dictionary of string representation.
+ ///
+ private static readonly Dictionary _metadataProviderEnumDictionary =
+ Enum.GetValues()
+ .ToDictionary(
+ enumValue => enumValue.ToString(),
+ enumValue => enumValue.ToString(),
+ StringComparer.OrdinalIgnoreCase);
+
///
/// Checks if this instance has an id for the given provider.
///
@@ -108,7 +119,7 @@ namespace MediaBrowser.Model.Entities
/// The instance.
/// The name.
/// The value.
- public static void SetProviderId(this IHasProviderIds instance, string name, string value)
+ public static void SetProviderId(this IHasProviderIds instance, string name, string? value)
{
if (instance == null)
{
@@ -125,7 +136,15 @@ namespace MediaBrowser.Model.Entities
// Ensure it exists
instance.ProviderIds ??= new Dictionary(StringComparer.OrdinalIgnoreCase);
- instance.ProviderIds[name] = value;
+ // Match on internal MetadataProvider enum string values before adding arbitrary providers
+ if (_metadataProviderEnumDictionary.TryGetValue(name, out var enumValue))
+ {
+ instance.ProviderIds[enumValue] = value;
+ }
+ else
+ {
+ instance.ProviderIds[name] = value;
+ }
}
}