Refactor of plugin structure to make more sense compared to the default template
This commit is contained in:
@@ -3,20 +3,13 @@ using System.Collections.ObjectModel;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Model.Plugins;
|
||||
|
||||
namespace Jellyfin.Plugin.MediaCleaner.Configuration;
|
||||
namespace Jellyfin.Plugin.MediaCleaner;
|
||||
|
||||
/// <summary>
|
||||
/// Plugin configuration.
|
||||
/// </summary>
|
||||
public class PluginConfiguration : BasePluginConfiguration
|
||||
public class Configuration : BasePluginConfiguration
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="PluginConfiguration"/> class.
|
||||
/// </summary>
|
||||
public PluginConfiguration()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the http address for your Radarr instance.
|
||||
/// </summary>
|
||||
@@ -1,136 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Media Cleaner</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="MediaCleanerConfigPage" data-role="page" class="page type-interior pluginConfigurationPage" data-require="emby-input,emby-button,emby-select,emby-checkbox">
|
||||
<div data-role="content">
|
||||
<div class="content-primary">
|
||||
<form id="MediaCleanerConfigForm">
|
||||
<div class="inputContainer">
|
||||
<label class="inputLabel inputLabelUnfocused" for="RadarrHTTPAddress">Radarr Address (http)</label>
|
||||
<input id="RadarrHTTPAddress" name="RadarrHTTPAddress" type="text" is="emby-input" />
|
||||
<div class="fieldDescription">The http address of your radarr instance.</div>
|
||||
</div>
|
||||
<div class="inputContainer">
|
||||
<label class="inputLabel inputLabelUnfocused" for="RadarrPort">Radarr Port</label>
|
||||
<input id="RadarrPort" name="RadarrPort" type="text" is="emby-input" />
|
||||
<div class="fieldDescription">The port of your radarr instance.</div>
|
||||
</div>
|
||||
<div class="inputContainer">
|
||||
<label class="inputLabel inputLabelUnfocused" for="RadarrAPIKey">Radarr API Key</label>
|
||||
<input id="RadarrAPIKey" name="RadarrAPIKey" type="text" is="emby-input" />
|
||||
<div class="fieldDescription">The api key used by your radarr instance</div>
|
||||
</div>
|
||||
<div class="inputContainer">
|
||||
<label class="inputLabel inputLabelUnfocused" for="SonarrHTTPAddress">Sonarr Address (http)</label>
|
||||
<input id="SonarrHTTPAddress" name="SonarrHTTPAddress" type="text" is="emby-input" />
|
||||
<div class="fieldDescription">The http address of your sonarr instance.</div>
|
||||
</div>
|
||||
<div class="inputContainer">
|
||||
<label class="inputLabel inputLabelUnfocused" for="SonarrPort">Sonarr Port</label>
|
||||
<input id="SonarrPort" name="SonarrPort" type="text" is="emby-input" />
|
||||
<div class="fieldDescription">The port of your sonarr instance.</div>
|
||||
</div>
|
||||
<div class="inputContainer">
|
||||
<label class="inputLabel inputLabelUnfocused" for="SonarrAPIKey">Sonarr API Key</label>
|
||||
<input id="SonarrAPIKey" name="SonarrAPIKey" type="text" is="emby-input" />
|
||||
<div class="fieldDescription">The api key used by your sonarr instance</div>
|
||||
</div>
|
||||
<div class="inputContainer">
|
||||
<label class="inputLabel inputLabelUnfocused" for="StaleMediaCutoff">Stale Media Cutoff</label>
|
||||
<input id="StaleMediaCutoff" name="StaleMediaCutoff" type="number" is="emby-input" style="width: 20%;"/>
|
||||
<div class="fieldDescription">How many days to wait before marking files as stale</div>
|
||||
</div>
|
||||
<div class="checkboxContainer checkboxContainer-withDescription">
|
||||
<label class="emby-checkbox-label">
|
||||
<input id="DebugMode" name="DebugMode" type="checkbox" is="emby-checkbox" />
|
||||
<span>Debug Mode</span>
|
||||
</label>
|
||||
</div>
|
||||
<!-- <div class="selectContainer">
|
||||
<label class="selectLabel" for="Options">Several Options</label>
|
||||
<select is="emby-select" id="Options" name="Options" class="emby-select-withcolor emby-select">
|
||||
<option id="optOneOption" value="OneOption">One Option</option>
|
||||
<option id="optAnotherOption" value="AnotherOption">Another Option</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="inputContainer">
|
||||
<label class="inputLabel inputLabelUnfocused" for="AnInteger">An Integer</label>
|
||||
<input id="AnInteger" name="AnInteger" type="number" is="emby-input" min="0" />
|
||||
<div class="fieldDescription">A Description</div>
|
||||
</div>
|
||||
<div class="checkboxContainer checkboxContainer-withDescription">
|
||||
<label class="emby-checkbox-label">
|
||||
<input id="TrueFalseSetting" name="TrueFalseCheckBox" type="checkbox" is="emby-checkbox" />
|
||||
<span>A Checkbox</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="inputContainer">
|
||||
<label class="inputLabel inputLabelUnfocused" for="AString">A String</label>
|
||||
<input id="AString" name="AString" type="text" is="emby-input" />
|
||||
<div class="fieldDescription">Another Description</div>
|
||||
</div> -->
|
||||
<div>
|
||||
<button is="emby-button" type="submit" class="raised button-submit block emby-button">
|
||||
<span>Save</span>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
var MediaCleanerConfig = {
|
||||
pluginUniqueId: 'fef007a8-3e8f-4aa8-a22e-486a387f4192'
|
||||
};
|
||||
|
||||
document.querySelector('#MediaCleanerConfigPage')
|
||||
.addEventListener('pageshow', function() {
|
||||
Dashboard.showLoadingMsg();
|
||||
ApiClient.getPluginConfiguration(MediaCleanerConfig.pluginUniqueId).then(function (config) {
|
||||
// document.querySelector('#Options').value = config.Options;
|
||||
// document.querySelector('#AnInteger').value = config.AnInteger;
|
||||
// document.querySelector('#TrueFalseSetting').checked = config.TrueFalseSetting;
|
||||
// document.querySelector('#AString').value = config.AString;
|
||||
document.querySelector('#RadarrHTTPAddress').value = config.RadarrHTTPAddress;
|
||||
document.querySelector('#RadarrPort').value = config.RadarrPort;
|
||||
document.querySelector('#RadarrAPIKey').value = config.RadarrAPIKey;
|
||||
document.querySelector('#SonarrHTTPAddress').value = config.SonarrHTTPAddress;
|
||||
document.querySelector('#SonarrPort').value = config.SonarrPort;
|
||||
document.querySelector('#SonarrAPIKey').value = config.SonarrAPIKey;
|
||||
document.querySelector('#StaleMediaCutoff').value = config.StaleMediaCutoff;
|
||||
document.querySelector('#DebugMode').checked = config.DebugMode;
|
||||
Dashboard.hideLoadingMsg();
|
||||
});
|
||||
});
|
||||
|
||||
document.querySelector('#MediaCleanerConfigForm')
|
||||
.addEventListener('submit', function(e) {
|
||||
Dashboard.showLoadingMsg();
|
||||
ApiClient.getPluginConfiguration(MediaCleanerConfig.pluginUniqueId).then(function (config) {
|
||||
// config.Options = document.querySelector('#Options').value;
|
||||
// config.AnInteger = document.querySelector('#AnInteger').value;
|
||||
// config.TrueFalseSetting = document.querySelector('#TrueFalseSetting').checked;
|
||||
// config.AString = document.querySelector('#AString').value;
|
||||
config.RadarrHTTPAddress = document.querySelector('#RadarrHTTPAddress').value;
|
||||
config.RadarrPort = document.querySelector('#RadarrPort').value;
|
||||
config.RadarrAPIKey = document.querySelector('#RadarrAPIKey').value;
|
||||
config.SonarrHTTPAddress = document.querySelector('#SonarrHTTPAddress').value;
|
||||
config.SonarrPort = document.querySelector('#SonarrPort').value;
|
||||
config.SonarrAPIKey = document.querySelector('#SonarrAPIKey').value;
|
||||
config.StaleMediaCutoff = document.querySelector('#StaleMediaCutoff').value;
|
||||
config.DebugMode = document.querySelector('#DebugMode').checked;
|
||||
ApiClient.updatePluginConfiguration(MediaCleanerConfig.pluginUniqueId, config).then(function (result) {
|
||||
Dashboard.processPluginConfigurationUpdateResult(result);
|
||||
});
|
||||
});
|
||||
|
||||
e.preventDefault();
|
||||
return false;
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -2,7 +2,6 @@ using Jellyfin.Plugin.MediaCleaner.Data;
|
||||
using Jellyfin.Plugin.MediaCleaner;
|
||||
using Jellyfin.Plugin.MediaCleaner.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Jellyfin.Plugin.MediaCleaner.Configuration;
|
||||
|
||||
namespace Jellyfin.Plugin.MediaCleaner.Controllers;
|
||||
|
||||
@@ -10,7 +9,7 @@ namespace Jellyfin.Plugin.MediaCleaner.Controllers;
|
||||
public class StateController(MediaCleanerState state) : Controller
|
||||
{
|
||||
private readonly MediaCleanerState _state = state;
|
||||
private static PluginConfiguration Configuration =>
|
||||
private static Configuration Configuration =>
|
||||
Plugin.Instance!.Configuration;
|
||||
|
||||
[HttpGet("getSeriesInfo")]
|
||||
|
||||
@@ -1,12 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Jellyfin.Plugin.MediaCleaner.Configuration;
|
||||
using Jellyfin.Plugin.MediaCleaner.Models;
|
||||
using Jellyfin.Plugin.MediaCleaner.ScheduledTasks;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Jellyfin.Plugin.MediaCleaner.Helpers;
|
||||
@@ -30,6 +23,6 @@ public class LoggingHelper(ILogger logger)
|
||||
_logger.LogInformation(message, args);
|
||||
}
|
||||
|
||||
private static PluginConfiguration Configuration =>
|
||||
private static Configuration Configuration =>
|
||||
Plugin.Instance!.Configuration;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using Jellyfin.Database.Implementations.Entities;
|
||||
using Jellyfin.Plugin.MediaCleaner.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
@@ -12,7 +10,7 @@ public class MovieHelper(ILogger logger)
|
||||
{
|
||||
private readonly LoggingHelper _loggingHelper = new(logger);
|
||||
|
||||
private static PluginConfiguration Configuration =>
|
||||
private static Configuration Configuration =>
|
||||
Plugin.Instance!.Configuration;
|
||||
|
||||
public bool IsMovieStale(BaseItem movie)
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using Jellyfin.Database.Implementations.Entities;
|
||||
using Jellyfin.Database.Implementations.Entities.Libraries;
|
||||
using Jellyfin.Plugin.MediaCleaner.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
@@ -15,7 +12,7 @@ public class SeriesHelper(ILogger logger)
|
||||
{
|
||||
private readonly LoggingHelper _loggingHelper = new(logger);
|
||||
|
||||
private static PluginConfiguration Configuration =>
|
||||
private static Configuration Configuration =>
|
||||
Plugin.Instance!.Configuration;
|
||||
|
||||
private List<BaseItem> ProcessEpisodes(IReadOnlyCollection<BaseItem> episodes)
|
||||
|
||||
@@ -20,8 +20,6 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="Configuration\settings.html" />
|
||||
<EmbeddedResource Include="Configuration\settings.html" />
|
||||
<None Remove="Pages\*" />
|
||||
<EmbeddedResource Include="Pages\*" />
|
||||
</ItemGroup>
|
||||
|
||||
55
Jellyfin.Plugin.MediaCleaner/Pages/configuration.html
Normal file
55
Jellyfin.Plugin.MediaCleaner/Pages/configuration.html
Normal file
@@ -0,0 +1,55 @@
|
||||
<div id="MediaCleanerConfigPage" data-role="page" class="page type-interior pluginConfigurationPage" data-require="emby-input,emby-button,emby-select,emby-checkbox" data-controller="__plugin/configuration.js">
|
||||
<div data-role="content">
|
||||
<div class="content-primary">
|
||||
<form id="MediaCleanerConfigForm">
|
||||
<h2>Media Cleaner Configuration</h2>
|
||||
<div class="inputContainer">
|
||||
<label class="inputLabel inputLabelUnfocused" for="RadarrHTTPAddress">Radarr Address (http)</label>
|
||||
<input id="RadarrHTTPAddress" name="RadarrHTTPAddress" type="text" is="emby-input" />
|
||||
<div class="fieldDescription">The http address of your radarr instance.</div>
|
||||
</div>
|
||||
<div class="inputContainer">
|
||||
<label class="inputLabel inputLabelUnfocused" for="RadarrPort">Radarr Port</label>
|
||||
<input id="RadarrPort" name="RadarrPort" type="text" is="emby-input" />
|
||||
<div class="fieldDescription">The port of your radarr instance.</div>
|
||||
</div>
|
||||
<div class="inputContainer">
|
||||
<label class="inputLabel inputLabelUnfocused" for="RadarrAPIKey">Radarr API Key</label>
|
||||
<input id="RadarrAPIKey" name="RadarrAPIKey" type="text" is="emby-input" />
|
||||
<div class="fieldDescription">The api key used by your radarr instance</div>
|
||||
</div>
|
||||
<div class="inputContainer">
|
||||
<label class="inputLabel inputLabelUnfocused" for="SonarrHTTPAddress">Sonarr Address (http)</label>
|
||||
<input id="SonarrHTTPAddress" name="SonarrHTTPAddress" type="text" is="emby-input" />
|
||||
<div class="fieldDescription">The http address of your sonarr instance.</div>
|
||||
</div>
|
||||
<div class="inputContainer">
|
||||
<label class="inputLabel inputLabelUnfocused" for="SonarrPort">Sonarr Port</label>
|
||||
<input id="SonarrPort" name="SonarrPort" type="text" is="emby-input" />
|
||||
<div class="fieldDescription">The port of your sonarr instance.</div>
|
||||
</div>
|
||||
<div class="inputContainer">
|
||||
<label class="inputLabel inputLabelUnfocused" for="SonarrAPIKey">Sonarr API Key</label>
|
||||
<input id="SonarrAPIKey" name="SonarrAPIKey" type="text" is="emby-input" />
|
||||
<div class="fieldDescription">The api key used by your sonarr instance</div>
|
||||
</div>
|
||||
<div class="inputContainer">
|
||||
<label class="inputLabel inputLabelUnfocused" for="StaleMediaCutoff">Stale Media Cutoff</label>
|
||||
<input id="StaleMediaCutoff" name="StaleMediaCutoff" type="number" is="emby-input" style="width: 20%;"/>
|
||||
<div class="fieldDescription">How many days to wait before marking files as stale</div>
|
||||
</div>
|
||||
<div class="checkboxContainer checkboxContainer-withDescription">
|
||||
<label class="emby-checkbox-label">
|
||||
<input id="DebugMode" name="DebugMode" type="checkbox" is="emby-checkbox" />
|
||||
<span>Debug Mode</span>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<button is="emby-button" type="submit" class="raised button-submit block emby-button">
|
||||
<span>Save</span>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
40
Jellyfin.Plugin.MediaCleaner/Pages/configuration.js
Normal file
40
Jellyfin.Plugin.MediaCleaner/Pages/configuration.js
Normal file
@@ -0,0 +1,40 @@
|
||||
var MediaCleanerConfig = {
|
||||
pluginUniqueId: 'fef007a8-3e8f-4aa8-a22e-486a387f4192'
|
||||
};
|
||||
|
||||
document.querySelector('#MediaCleanerConfigPage')
|
||||
.addEventListener('pageshow', function() {
|
||||
Dashboard.showLoadingMsg();
|
||||
ApiClient.getPluginConfiguration(MediaCleanerConfig.pluginUniqueId).then(function (config) {
|
||||
document.querySelector('#RadarrHTTPAddress').value = config.RadarrHTTPAddress;
|
||||
document.querySelector('#RadarrPort').value = config.RadarrPort;
|
||||
document.querySelector('#RadarrAPIKey').value = config.RadarrAPIKey;
|
||||
document.querySelector('#SonarrHTTPAddress').value = config.SonarrHTTPAddress;
|
||||
document.querySelector('#SonarrPort').value = config.SonarrPort;
|
||||
document.querySelector('#SonarrAPIKey').value = config.SonarrAPIKey;
|
||||
document.querySelector('#StaleMediaCutoff').value = config.StaleMediaCutoff;
|
||||
document.querySelector('#DebugMode').checked = config.DebugMode;
|
||||
Dashboard.hideLoadingMsg();
|
||||
});
|
||||
});
|
||||
|
||||
document.querySelector('#MediaCleanerConfigForm')
|
||||
.addEventListener('submit', function(e) {
|
||||
Dashboard.showLoadingMsg();
|
||||
ApiClient.getPluginConfiguration(MediaCleanerConfig.pluginUniqueId).then(function (config) {
|
||||
config.RadarrHTTPAddress = document.querySelector('#RadarrHTTPAddress').value;
|
||||
config.RadarrPort = document.querySelector('#RadarrPort').value;
|
||||
config.RadarrAPIKey = document.querySelector('#RadarrAPIKey').value;
|
||||
config.SonarrHTTPAddress = document.querySelector('#SonarrHTTPAddress').value;
|
||||
config.SonarrPort = document.querySelector('#SonarrPort').value;
|
||||
config.SonarrAPIKey = document.querySelector('#SonarrAPIKey').value;
|
||||
config.StaleMediaCutoff = document.querySelector('#StaleMediaCutoff').value;
|
||||
config.DebugMode = document.querySelector('#DebugMode').checked;
|
||||
ApiClient.updatePluginConfiguration(MediaCleanerConfig.pluginUniqueId, config).then(function (result) {
|
||||
Dashboard.processPluginConfigurationUpdateResult(result);
|
||||
});
|
||||
});
|
||||
|
||||
e.preventDefault();
|
||||
return false;
|
||||
});
|
||||
@@ -5,7 +5,7 @@
|
||||
<link rel="stylesheet" href="/web/configurationpage?name=home.css" />
|
||||
<div id="loading">Loading...</div>
|
||||
<div id="homepage" style="visibility: hidden;">
|
||||
<button class="links" data-target="configurationpage?name=Settings">Settings</button>
|
||||
<button class="links" data-target="configurationpage?name=Configuration">Configuration</button>
|
||||
<h2>Media Cleaner</h2>
|
||||
|
||||
<h3 id="moviesTitle"></h3>
|
||||
|
||||
@@ -1,21 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using Jellyfin.Plugin.MediaCleaner.Configuration;
|
||||
using Jellyfin.Plugin.MediaCleaner.Data;
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Common.Plugins;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Model.Plugins;
|
||||
using MediaBrowser.Model.Serialization;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Jellyfin.Plugin.MediaCleaner;
|
||||
|
||||
/// <summary>
|
||||
/// The main plugin.
|
||||
/// </summary>
|
||||
public class Plugin : BasePlugin<PluginConfiguration>, IHasWebPages
|
||||
public class Plugin : BasePlugin<Configuration>, IHasWebPages
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Plugin"/> class.
|
||||
@@ -46,8 +42,13 @@ public class Plugin : BasePlugin<PluginConfiguration>, IHasWebPages
|
||||
[
|
||||
new PluginPageInfo
|
||||
{
|
||||
Name = "Settings",
|
||||
EmbeddedResourcePath = string.Format(CultureInfo.InvariantCulture, "{0}.Configuration.settings.html", GetType().Namespace),
|
||||
Name = "configuration.js",
|
||||
EmbeddedResourcePath = string.Format(CultureInfo.InvariantCulture, "{0}.Pages.configuration.js", GetType().Namespace),
|
||||
},
|
||||
new PluginPageInfo
|
||||
{
|
||||
Name = "Configuration",
|
||||
EmbeddedResourcePath = string.Format(CultureInfo.InvariantCulture, "{0}.Pages.configuration.html", GetType().Namespace),
|
||||
},
|
||||
new PluginPageInfo
|
||||
{
|
||||
|
||||
@@ -1,25 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Data.Common;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Reflection.Metadata.Ecma335;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Jellyfin.Data.Enums;
|
||||
using Jellyfin.Database.Implementations.Entities;
|
||||
using Jellyfin.Database.Implementations.Entities.Libraries;
|
||||
using Jellyfin.Plugin.MediaCleaner.Configuration;
|
||||
using Jellyfin.Plugin.MediaCleaner.Helpers;
|
||||
using Jellyfin.Plugin.MediaCleaner;
|
||||
using Jellyfin.Plugin.MediaCleaner.Models;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Model.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Jellyfin.Plugin.MediaCleaner;
|
||||
|
||||
Reference in New Issue
Block a user