Updated state to scan library first before looking for stale media to ensure data in table is accurate
This commit is contained in:
@@ -32,7 +32,11 @@ public class StateController(MediaCleanerState state) : Controller
|
|||||||
public IActionResult GetMovieInfo() => Ok(_state.GetMovieInfo());
|
public IActionResult GetMovieInfo() => Ok(_state.GetMovieInfo());
|
||||||
|
|
||||||
[HttpGet("updateState")]
|
[HttpGet("updateState")]
|
||||||
public IActionResult GetUpdateState() => Ok(_state.UpdateState());
|
public async Task<IActionResult> GetUpdateState()
|
||||||
|
{
|
||||||
|
await _state.UpdateState().ConfigureAwait(false);
|
||||||
|
return Ok();
|
||||||
|
}
|
||||||
|
|
||||||
[HttpGet("getMoviesTitle")]
|
[HttpGet("getMoviesTitle")]
|
||||||
public IActionResult GetMoviesTitle() =>
|
public IActionResult GetMoviesTitle() =>
|
||||||
|
|||||||
@@ -11,18 +11,32 @@ using System.Net.Http;
|
|||||||
using System;
|
using System;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
using MediaBrowser.Model.Tasks;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
namespace Jellyfin.Plugin.MediaCleaner.Data;
|
namespace Jellyfin.Plugin.MediaCleaner.Data;
|
||||||
|
|
||||||
public class MediaCleanerState(ILogger<StaleMediaScanner> logger, ILibraryManager libraryManager)
|
public class MediaCleanerState(ILogger<StaleMediaScanner> logger, ILibraryManager libraryManager, ITaskManager taskManager)
|
||||||
{
|
{
|
||||||
private readonly Lock _lock = new();
|
private readonly Lock _lock = new();
|
||||||
private IEnumerable<MediaInfo> _mediaInfo = [];
|
private IEnumerable<MediaInfo> _mediaInfo = [];
|
||||||
private readonly StaleMediaScanner _staleMediaScanner = new(logger, libraryManager);
|
private readonly StaleMediaScanner _staleMediaScanner = new(logger, libraryManager);
|
||||||
|
// private readonly ILibraryManager _libraryManager = libraryManager;
|
||||||
|
private readonly ITaskManager _taskManager = taskManager;
|
||||||
|
|
||||||
public async Task UpdateState()
|
public async Task UpdateState()
|
||||||
{
|
{
|
||||||
|
// First re-scan library and then scan for stale media.
|
||||||
|
IScheduledTaskWorker? refreshLibraryWorker = _taskManager.ScheduledTasks.FirstOrDefault(task => task.ScheduledTask.Key == "RefreshLibrary");
|
||||||
|
|
||||||
|
if(refreshLibraryWorker != null)
|
||||||
|
{
|
||||||
|
await _taskManager.Execute(refreshLibraryWorker, new TaskOptions()).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
|
||||||
_mediaInfo = await _staleMediaScanner.ScanStaleMedia().ConfigureAwait(false);
|
_mediaInfo = await _staleMediaScanner.ScanStaleMedia().ConfigureAwait(false);
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<SeriesInfo>> GetTvSeriesInfo()
|
public async Task<IEnumerable<SeriesInfo>> GetTvSeriesInfo()
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<div data-role="content">
|
<div data-role="content">
|
||||||
<div class="content-primary">
|
<div class="content-primary">
|
||||||
<link rel="stylesheet" href="/web/configurationpage?name=global.css" />
|
<link rel="stylesheet" href="/web/configurationpage?name=global.css" />
|
||||||
<div id="loading">Loading...</div>
|
<div id="loading">Loading... This may take some time whilst we scan your library and retrieve data from Radarr and Sonarr to accurately fill tables.</div>
|
||||||
<div id="homepage" style="visibility: hidden;">
|
<div id="homepage" style="visibility: hidden;">
|
||||||
<button class="links" data-target="configurationpage?name=Configuration">Configuration</button>
|
<button class="links" data-target="configurationpage?name=Configuration">Configuration</button>
|
||||||
<h2>Media Cleaner</h2>
|
<h2>Media Cleaner</h2>
|
||||||
|
|||||||
@@ -56,8 +56,6 @@ const updateMediaCleanerState = async () => {
|
|||||||
if(!response.ok){
|
if(!response.ok){
|
||||||
throw new Error(`Response status: ${response.status}`)
|
throw new Error(`Response status: ${response.status}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
return response.json();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const getMediaCleanerAnimeSeriesTitle = async () => {
|
const getMediaCleanerAnimeSeriesTitle = async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user