2025-04-16 18:26:31 +08:00
|
|
|
|
using System.Text.Json.Nodes;
|
2025-04-17 18:46:41 +08:00
|
|
|
|
using Core;
|
2025-04-16 18:26:31 +08:00
|
|
|
|
using Interface.Jobs;
|
2025-02-27 16:58:21 +08:00
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
|
|
|
|
|
|
|
namespace WebApi.Controllers;
|
|
|
|
|
|
|
|
|
|
|
|
public class JobTriggerController : BaseController
|
|
|
|
|
|
{
|
|
|
|
|
|
private readonly ILogTotalNotifyJobRegistry _logTotalNotifyJobRegistry;
|
|
|
|
|
|
private readonly IDiskActionMonitorRegistry _diskActionMonitorRegistry;
|
|
|
|
|
|
private readonly IHealthyTaskRegistry _healthyTaskRegistry;
|
|
|
|
|
|
private readonly IRSyncTaskRegistry _rSyncTaskRegistry;
|
|
|
|
|
|
private readonly IStartupRegistry _startupRegistry;
|
|
|
|
|
|
private readonly IShutdownRegistry _shutdownRegistry;
|
|
|
|
|
|
private readonly IChineseNfoRegistry _chineseNfoRegistry;
|
2025-03-07 12:05:39 +08:00
|
|
|
|
private readonly IDiskMonitorRegistry _diskMonitorRegistry;
|
2025-02-27 16:58:21 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// ctor
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public JobTriggerController(
|
|
|
|
|
|
ILogTotalNotifyJobRegistry logTotalNotifyJobRegistry,
|
|
|
|
|
|
IDiskActionMonitorRegistry diskActionMonitorRegistry,
|
|
|
|
|
|
IHealthyTaskRegistry healthyTaskRegistry,
|
|
|
|
|
|
IRSyncTaskRegistry rSyncTaskRegistry,
|
2025-04-16 18:26:31 +08:00
|
|
|
|
IStartupRegistry startupRegistry,
|
|
|
|
|
|
IShutdownRegistry shutdownRegistry,
|
2025-03-07 12:05:39 +08:00
|
|
|
|
IChineseNfoRegistry chineseNfoRegistry,
|
|
|
|
|
|
IDiskMonitorRegistry diskMonitorRegistry)
|
2025-02-27 16:58:21 +08:00
|
|
|
|
{
|
|
|
|
|
|
_logTotalNotifyJobRegistry = logTotalNotifyJobRegistry;
|
|
|
|
|
|
_diskActionMonitorRegistry = diskActionMonitorRegistry;
|
|
|
|
|
|
_healthyTaskRegistry = healthyTaskRegistry;
|
|
|
|
|
|
_rSyncTaskRegistry = rSyncTaskRegistry;
|
|
|
|
|
|
_startupRegistry = startupRegistry;
|
|
|
|
|
|
_shutdownRegistry = shutdownRegistry;
|
|
|
|
|
|
_chineseNfoRegistry = chineseNfoRegistry;
|
2025-03-07 12:05:39 +08:00
|
|
|
|
_diskMonitorRegistry = diskMonitorRegistry;
|
2025-02-27 16:58:21 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[HttpGet]
|
|
|
|
|
|
public string LogTotalNotify()
|
|
|
|
|
|
{
|
|
|
|
|
|
_logTotalNotifyJobRegistry.Job();
|
|
|
|
|
|
|
|
|
|
|
|
return "OK";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[HttpGet]
|
|
|
|
|
|
public string DiskActionMonitor()
|
|
|
|
|
|
{
|
|
|
|
|
|
_diskActionMonitorRegistry.Job();
|
|
|
|
|
|
|
|
|
|
|
|
return "OK";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[HttpGet]
|
|
|
|
|
|
public string HealthyTask()
|
|
|
|
|
|
{
|
|
|
|
|
|
_healthyTaskRegistry.Job();
|
|
|
|
|
|
|
|
|
|
|
|
return "OK";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[HttpGet]
|
|
|
|
|
|
public string RSyncTask()
|
|
|
|
|
|
{
|
|
|
|
|
|
_rSyncTaskRegistry.Job();
|
|
|
|
|
|
|
|
|
|
|
|
return "OK";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[HttpGet]
|
|
|
|
|
|
public string Startup()
|
|
|
|
|
|
{
|
|
|
|
|
|
_startupRegistry.Job();
|
|
|
|
|
|
|
|
|
|
|
|
return "OK";
|
|
|
|
|
|
}
|
2025-04-16 18:26:31 +08:00
|
|
|
|
|
2025-02-27 16:58:21 +08:00
|
|
|
|
[HttpGet]
|
|
|
|
|
|
public string Shutdown()
|
|
|
|
|
|
{
|
|
|
|
|
|
_shutdownRegistry.Job();
|
2025-04-16 18:26:31 +08:00
|
|
|
|
|
2025-02-27 16:58:21 +08:00
|
|
|
|
return "OK";
|
|
|
|
|
|
}
|
2025-04-16 18:26:31 +08:00
|
|
|
|
|
2025-02-27 16:58:21 +08:00
|
|
|
|
[HttpGet]
|
|
|
|
|
|
public string CancelShutdown()
|
|
|
|
|
|
{
|
|
|
|
|
|
_shutdownRegistry.CancelShutdown();
|
2025-04-16 18:26:31 +08:00
|
|
|
|
|
2025-02-27 16:58:21 +08:00
|
|
|
|
return "OK";
|
|
|
|
|
|
}
|
2025-04-16 18:26:31 +08:00
|
|
|
|
|
2025-02-27 16:58:21 +08:00
|
|
|
|
[HttpGet]
|
2025-04-16 18:26:31 +08:00
|
|
|
|
public string ConvertChineseNfo(
|
|
|
|
|
|
bool ignoreLocked = false,
|
|
|
|
|
|
bool ignoreCompleted = false)
|
2025-02-27 16:58:21 +08:00
|
|
|
|
{
|
2025-04-16 18:26:31 +08:00
|
|
|
|
_chineseNfoRegistry.Job(ignoreLocked: ignoreLocked, ignoreCompleted: ignoreCompleted);
|
|
|
|
|
|
|
2025-02-27 16:58:21 +08:00
|
|
|
|
return "OK";
|
|
|
|
|
|
}
|
2025-04-16 18:26:31 +08:00
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
|
public async Task<string> SonarrChangedConvertChineseNfo()
|
|
|
|
|
|
{
|
|
|
|
|
|
var body = Request.Body;
|
|
|
|
|
|
|
|
|
|
|
|
using var reader = new StreamReader(body);
|
|
|
|
|
|
var text = await reader.ReadToEndAsync();
|
|
|
|
|
|
|
|
|
|
|
|
var json = JsonNode.Parse(text);
|
|
|
|
|
|
|
|
|
|
|
|
var tmdbId = json?["series"]?["tmdbId"]?.ToString();
|
|
|
|
|
|
var seasonNumber = json?["episodes"]?[0]?["seasonNumber"]?.ToString();
|
|
|
|
|
|
var episodeNumber = json?["episodes"]?[0]?["episodeNumber"]?.ToString();
|
2025-04-17 18:46:41 +08:00
|
|
|
|
var path = json?["series"]?["path"]?.ToString();
|
|
|
|
|
|
var eventType = json?["eventType"]?.ToString();
|
|
|
|
|
|
|
|
|
|
|
|
await WxNotify.SendCommonAsync($"SonarrChangedConvertChineseNfo: {tmdbId}, {seasonNumber}, {episodeNumber}, {path}, {eventType}");
|
2025-04-16 18:26:31 +08:00
|
|
|
|
|
|
|
|
|
|
_chineseNfoRegistry.Job(tmdbId: tmdbId, seasonNumber: seasonNumber, episodeNumber: episodeNumber);
|
|
|
|
|
|
|
|
|
|
|
|
return "OK";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-03-07 12:05:39 +08:00
|
|
|
|
[HttpGet]
|
|
|
|
|
|
public string DiskMonitor()
|
|
|
|
|
|
{
|
|
|
|
|
|
_diskMonitorRegistry.Job();
|
2025-04-16 18:26:31 +08:00
|
|
|
|
|
2025-03-07 12:05:39 +08:00
|
|
|
|
return "OK";
|
|
|
|
|
|
}
|
2025-02-27 16:58:21 +08:00
|
|
|
|
}
|