Add schema to TubeArchivist URL if not present in settings
This commit is contained in:
@@ -1,4 +1,8 @@
|
|||||||
|
using System;
|
||||||
|
using System.Data;
|
||||||
|
using Jellyfin.Plugin.TubeArchivistMetadata.Utilities;
|
||||||
using MediaBrowser.Model.Plugins;
|
using MediaBrowser.Model.Plugins;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace Jellyfin.Plugin.TubeArchivistMetadata.Configuration
|
namespace Jellyfin.Plugin.TubeArchivistMetadata.Configuration
|
||||||
{
|
{
|
||||||
@@ -7,13 +11,25 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.Configuration
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class PluginConfiguration : BasePluginConfiguration
|
public class PluginConfiguration : BasePluginConfiguration
|
||||||
{
|
{
|
||||||
|
private ILogger _logger;
|
||||||
|
private string _tubeArchivistUrl;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="PluginConfiguration"/> class.
|
/// Initializes a new instance of the <see cref="PluginConfiguration"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public PluginConfiguration()
|
public PluginConfiguration()
|
||||||
{
|
{
|
||||||
|
if (Plugin.Instance == null)
|
||||||
|
{
|
||||||
|
throw new DataException("Uninitialized plugin!");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_logger = Plugin.Instance.Logger;
|
||||||
|
}
|
||||||
|
|
||||||
CollectionTitle = "YouTube";
|
CollectionTitle = "YouTube";
|
||||||
TubeArchivistUrl = string.Empty;
|
_tubeArchivistUrl = string.Empty;
|
||||||
TubeArchivistApiKey = string.Empty;
|
TubeArchivistApiKey = string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -25,7 +41,26 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.Configuration
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets TubeArchivist URL.
|
/// Gets or sets TubeArchivist URL.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string TubeArchivistUrl { get; set; }
|
public string TubeArchivistUrl
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _tubeArchivistUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value.StartsWith("http://", StringComparison.CurrentCulture) || value.StartsWith("https://", StringComparison.CurrentCulture))
|
||||||
|
{
|
||||||
|
_tubeArchivistUrl = Utils.SanitizeUrl(value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_logger.LogInformation("{Message}", "Given TubeArchivist URL contains no schema. Adding http://...");
|
||||||
|
_tubeArchivistUrl = Utils.SanitizeUrl("http://" + value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets TubeArchivist API key.
|
/// Gets or sets TubeArchivist API key.
|
||||||
|
|||||||
Reference in New Issue
Block a user