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 Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Jellyfin.Plugin.TubeArchivistMetadata.Configuration
|
||||
{
|
||||
@@ -7,13 +11,25 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.Configuration
|
||||
/// </summary>
|
||||
public class PluginConfiguration : BasePluginConfiguration
|
||||
{
|
||||
private ILogger _logger;
|
||||
private string _tubeArchivistUrl;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="PluginConfiguration"/> class.
|
||||
/// </summary>
|
||||
public PluginConfiguration()
|
||||
{
|
||||
if (Plugin.Instance == null)
|
||||
{
|
||||
throw new DataException("Uninitialized plugin!");
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger = Plugin.Instance.Logger;
|
||||
}
|
||||
|
||||
CollectionTitle = "YouTube";
|
||||
TubeArchivistUrl = string.Empty;
|
||||
_tubeArchivistUrl = string.Empty;
|
||||
TubeArchivistApiKey = string.Empty;
|
||||
}
|
||||
|
||||
@@ -25,7 +41,26 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.Configuration
|
||||
/// <summary>
|
||||
/// Gets or sets TubeArchivist URL.
|
||||
/// </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>
|
||||
/// Gets or sets TubeArchivist API key.
|
||||
|
||||
Reference in New Issue
Block a user