Media cleaner logging improvements and refactors #6
22
Jellyfin.Plugin.MediaCleaner/Controllers/StateController.cs
Normal file
22
Jellyfin.Plugin.MediaCleaner/Controllers/StateController.cs
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
using Jellyfin.Plugin.MediaCleaner.Data;
|
||||||
|
using Jellyfin.Plugin.MediaCleaner.Models;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace Jellyfin.Plugin.MediaCleaner.Controllers;
|
||||||
|
|
||||||
|
[Route("mediacleaner/state")]
|
||||||
|
public class StateController : Controller
|
||||||
|
{
|
||||||
|
private readonly PluginState _state;
|
||||||
|
public StateController(PluginState state) => _state = state;
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult Get() => Ok(_state.GetSeriesInfo());
|
||||||
|
|
||||||
|
[HttpPost("add")]
|
||||||
|
public IActionResult AddSeriesInfo([FromBody] SeriesInfo seriesInfo)
|
||||||
|
{
|
||||||
|
_state.AddSeriesInfo(seriesInfo);
|
||||||
|
return Ok();
|
||||||
|
}
|
||||||
|
}
|
||||||
29
Jellyfin.Plugin.MediaCleaner/Data/PluginState.cs
Normal file
29
Jellyfin.Plugin.MediaCleaner/Data/PluginState.cs
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using Jellyfin.Plugin.MediaCleaner.Models;
|
||||||
|
|
||||||
|
namespace Jellyfin.Plugin.MediaCleaner.Data;
|
||||||
|
|
||||||
|
public class PluginState
|
||||||
|
{
|
||||||
|
private readonly object _lock = new();
|
||||||
|
private List<SeriesInfo> _seriesInfo = new List<SeriesInfo>
|
||||||
|
{
|
||||||
|
new SeriesInfo { SeriesName = "TestName", Id = System.Guid.NewGuid() }
|
||||||
|
};
|
||||||
|
|
||||||
|
public void AddSeriesInfo(SeriesInfo seriesInfo)
|
||||||
|
{
|
||||||
|
lock (_lock)
|
||||||
|
{
|
||||||
|
_seriesInfo.Add(seriesInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<SeriesInfo> GetSeriesInfo()
|
||||||
|
{
|
||||||
|
lock (_lock)
|
||||||
|
{
|
||||||
|
return _seriesInfo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -22,8 +22,8 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Remove="Configuration\settings.html" />
|
<None Remove="Configuration\settings.html" />
|
||||||
<EmbeddedResource Include="Configuration\settings.html" />
|
<EmbeddedResource Include="Configuration\settings.html" />
|
||||||
<None Remove="Pages\home.html" />
|
<None Remove="Pages\*" />
|
||||||
<EmbeddedResource Include="Pages\home.html" />
|
<EmbeddedResource Include="Pages\*" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<div data-role="page" class="page type-interior pluginConfigurationPage withTabs">
|
<div data-role="page" class="page type-interior pluginConfigurationPage withTabs"
|
||||||
|
data-controller="__plugin/media_cleaner_table.js">
|
||||||
<div data-role="content">
|
<div data-role="content">
|
||||||
<div class="content-primary">
|
<div class="content-primary">
|
||||||
<div>
|
<div>
|
||||||
@@ -6,6 +7,15 @@
|
|||||||
<a href="#configurationpage?name=Settings">Settings</a>
|
<a href="#configurationpage?name=Settings">Settings</a>
|
||||||
</div>
|
</div>
|
||||||
<h2>Media Cleaner</h2>
|
<h2>Media Cleaner</h2>
|
||||||
|
<table id="seriesTable">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>ID</th>
|
||||||
|
<th>Series Name</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody></tbody>
|
||||||
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
27
Jellyfin.Plugin.MediaCleaner/Pages/media_cleaner_table.js
Normal file
27
Jellyfin.Plugin.MediaCleaner/Pages/media_cleaner_table.js
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
var table = document.getElementById("seriesTable");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const getMediaCleanerState = async () => {
|
||||||
|
const response = await fetch('/mediacleaner/state');
|
||||||
|
|
||||||
|
if(!response.ok){
|
||||||
|
throw new Error(`Response status: ${response.status}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
return response.json();
|
||||||
|
}
|
||||||
|
|
||||||
|
var state = await getMediaCleanerState();
|
||||||
|
|
||||||
|
console.log("State: ", state);
|
||||||
|
|
||||||
|
for(let i = 0; i < state.length; i++){
|
||||||
|
var row = table.insertRow(-1);
|
||||||
|
var cell1 = row.insertCell(0);
|
||||||
|
var cell2 = row.insertCell(1);
|
||||||
|
var cell3 = row.insertCell(2);
|
||||||
|
cell1.innerHTML = state[i].Id;
|
||||||
|
cell2.innerHTML = state[i].SeriesName;
|
||||||
|
cell3.innerHTML = state[i].Seasons.length;
|
||||||
|
}
|
||||||
@@ -2,11 +2,13 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using Jellyfin.Plugin.MediaCleaner.Configuration;
|
using Jellyfin.Plugin.MediaCleaner.Configuration;
|
||||||
|
using Jellyfin.Plugin.MediaCleaner.Data;
|
||||||
using MediaBrowser.Common.Configuration;
|
using MediaBrowser.Common.Configuration;
|
||||||
using MediaBrowser.Common.Plugins;
|
using MediaBrowser.Common.Plugins;
|
||||||
using MediaBrowser.Controller.Entities;
|
using MediaBrowser.Controller.Entities;
|
||||||
using MediaBrowser.Model.Plugins;
|
using MediaBrowser.Model.Plugins;
|
||||||
using MediaBrowser.Model.Serialization;
|
using MediaBrowser.Model.Serialization;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
namespace Jellyfin.Plugin.MediaCleaner;
|
namespace Jellyfin.Plugin.MediaCleaner;
|
||||||
|
|
||||||
@@ -53,6 +55,11 @@ public class Plugin : BasePlugin<PluginConfiguration>, IHasWebPages
|
|||||||
EmbeddedResourcePath = string.Format(CultureInfo.InvariantCulture, "{0}.Pages.home.html", GetType().Namespace),
|
EmbeddedResourcePath = string.Format(CultureInfo.InvariantCulture, "{0}.Pages.home.html", GetType().Namespace),
|
||||||
EnableInMainMenu = true,
|
EnableInMainMenu = true,
|
||||||
},
|
},
|
||||||
|
new PluginPageInfo
|
||||||
|
{
|
||||||
|
Name = "media_cleaner_table.js",
|
||||||
|
EmbeddedResourcePath = string.Format(CultureInfo.InvariantCulture, "{0}.Pages.media_cleaner_table.js", GetType().Namespace),
|
||||||
|
}
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
13
Jellyfin.Plugin.MediaCleaner/PluginServiceRegistrator.cs
Normal file
13
Jellyfin.Plugin.MediaCleaner/PluginServiceRegistrator.cs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
using Jellyfin.Plugin.MediaCleaner.Data;
|
||||||
|
using MediaBrowser.Controller;
|
||||||
|
using MediaBrowser.Controller.Plugins;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
|
namespace Jellyfin.Plugin.MediaCleaner;
|
||||||
|
public class PluginServiceRegistrator : IPluginServiceRegistrator
|
||||||
|
{
|
||||||
|
public void RegisterServices(IServiceCollection serviceCollection, IServerApplicationHost applicationHost)
|
||||||
|
{
|
||||||
|
serviceCollection.AddSingleton<PluginState>();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user