diff options
| author | Bond_009 <bond.009@outlook.com> | 2021-02-19 16:06:54 +0100 |
|---|---|---|
| committer | Bond_009 <bond.009@outlook.com> | 2021-02-19 16:09:23 +0100 |
| commit | b2700ecf4466fbd4998929d33f45c483de4a063a (patch) | |
| tree | 423296ed837dd036f1345297f966accd51967e2f /MediaBrowser.Model/Entities | |
| parent | 5379fa0bd082bd8e1b15bbb1f6517cab932ee2bb (diff) | |
TMDB: Also search with IMDB or TVDB Id if specified
Diffstat (limited to 'MediaBrowser.Model/Entities')
| -rw-r--r-- | MediaBrowser.Model/Entities/ProviderIdsExtensions.cs | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/MediaBrowser.Model/Entities/ProviderIdsExtensions.cs b/MediaBrowser.Model/Entities/ProviderIdsExtensions.cs index 98097477c..c643f1ecd 100644 --- a/MediaBrowser.Model/Entities/ProviderIdsExtensions.cs +++ b/MediaBrowser.Model/Entities/ProviderIdsExtensions.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; namespace MediaBrowser.Model.Entities { @@ -35,8 +36,9 @@ namespace MediaBrowser.Model.Entities /// </summary> /// <param name="instance">The instance.</param> /// <param name="name">The name.</param> - /// <returns>System.String.</returns> - public static string? GetProviderId(this IHasProviderIds instance, string name) + /// <param name="id">The provider id.</param> + /// <returns><c>true</c> if a provider id with the given name was found; otherwise <c>false</c>.</returns> + public static bool TryGetProviderId(this IHasProviderIds instance, string name, [MaybeNullWhen(false)] out string id) { if (instance == null) { @@ -45,11 +47,35 @@ namespace MediaBrowser.Model.Entities if (instance.ProviderIds == null) { - return null; + id = string.Empty; + return false; } - instance.ProviderIds.TryGetValue(name, out string? id); - return string.IsNullOrEmpty(id) ? null : id; + return instance.ProviderIds.TryGetValue(name, out id); + } + + /// <summary> + /// Gets a provider id. + /// </summary> + /// <param name="instance">The instance.</param> + /// <param name="provider">The provider.</param> + /// <param name="id">The provider id.</param> + /// <returns><c>true</c> if a provider id with the given name was found; otherwise <c>false</c>.</returns> + public static bool TryGetProviderId(this IHasProviderIds instance, MetadataProvider provider, [MaybeNullWhen(false)] out string id) + { + return instance.TryGetProviderId(provider.ToString(), out id); + } + + /// <summary> + /// Gets a provider id. + /// </summary> + /// <param name="instance">The instance.</param> + /// <param name="name">The name.</param> + /// <returns>System.String.</returns> + public static string? GetProviderId(this IHasProviderIds instance, string name) + { + instance.TryGetProviderId(name, out string? id); + return id; } /// <summary> |
