42 lines
1.3 KiB
C#
42 lines
1.3 KiB
C#
using Jellyfin.Plugin.SRFPlay.Configuration;
|
|
using MediaBrowser.Controller.Entities;
|
|
|
|
namespace Jellyfin.Plugin.SRFPlay.Utilities;
|
|
|
|
/// <summary>
|
|
/// Extension methods for common plugin operations.
|
|
/// </summary>
|
|
public static class Extensions
|
|
{
|
|
/// <summary>
|
|
/// Gets the SRF URN from the item's provider IDs.
|
|
/// </summary>
|
|
/// <param name="item">The base item.</param>
|
|
/// <returns>The SRF URN, or null if not found or empty.</returns>
|
|
public static string? GetSrfUrn(this BaseItem item)
|
|
{
|
|
return item.ProviderIds.TryGetValue("SRF", out var urn) && !string.IsNullOrEmpty(urn)
|
|
? urn
|
|
: null;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Converts the BusinessUnit enum to its lowercase string representation.
|
|
/// </summary>
|
|
/// <param name="businessUnit">The business unit.</param>
|
|
/// <returns>The lowercase string representation.</returns>
|
|
public static string ToLowerString(this BusinessUnit businessUnit)
|
|
{
|
|
return businessUnit.ToString().ToLowerInvariant();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the plugin configuration safely, returning null if not available.
|
|
/// </summary>
|
|
/// <returns>The plugin configuration, or null if not available.</returns>
|
|
public static PluginConfiguration? GetPluginConfig()
|
|
{
|
|
return Plugin.Instance?.Configuration;
|
|
}
|
|
}
|