mirror of
https://github.com/Cleanuparr/Cleanuparr.git
synced 2026-04-11 17:49:15 -04:00
renamed classes; added series search call
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
using Common.Configuration;
|
||||
using Executable.Jobs;
|
||||
using Infrastructure.Verticals.FrozenTorrent;
|
||||
using Infrastructure.Verticals.BlockedTorrent;
|
||||
|
||||
namespace Executable;
|
||||
using Quartz;
|
||||
@@ -23,8 +23,8 @@ public static class DependencyInjection
|
||||
|
||||
private static IServiceCollection AddServices(this IServiceCollection services) =>
|
||||
services
|
||||
.AddTransient<FrozenTorrentJob>()
|
||||
.AddTransient<FrozenTorrentHandler>();
|
||||
.AddTransient<BlockedTorrentJob>()
|
||||
.AddTransient<BlockedTorrentHandler>();
|
||||
|
||||
private static IServiceCollection AddQuartzServices(this IServiceCollection services, IConfiguration configuration) =>
|
||||
services
|
||||
@@ -37,24 +37,24 @@ public static class DependencyInjection
|
||||
throw new NullReferenceException("Quartz configuration is null");
|
||||
}
|
||||
|
||||
q.AddFrozenTorrentJob(config.FrozenTorrentTrigger);
|
||||
q.AddBlockedTorrentJob(config.BlockedTorrentTrigger);
|
||||
})
|
||||
.AddQuartzHostedService(opt =>
|
||||
{
|
||||
opt.WaitForJobsToComplete = true;
|
||||
});
|
||||
|
||||
private static void AddFrozenTorrentJob(this IServiceCollectionQuartzConfigurator q, string trigger)
|
||||
private static void AddBlockedTorrentJob(this IServiceCollectionQuartzConfigurator q, string trigger)
|
||||
{
|
||||
q.AddJob<FrozenTorrentJob>(opts =>
|
||||
q.AddJob<BlockedTorrentJob>(opts =>
|
||||
{
|
||||
opts.WithIdentity(nameof(FrozenTorrentJob));
|
||||
opts.WithIdentity(nameof(BlockedTorrentJob));
|
||||
});
|
||||
|
||||
q.AddTrigger(opts =>
|
||||
{
|
||||
opts.ForJob(nameof(FrozenTorrentJob))
|
||||
.WithIdentity($"{nameof(FrozenTorrentJob)}-trigger")
|
||||
opts.ForJob(nameof(BlockedTorrentJob))
|
||||
.WithIdentity($"{nameof(BlockedTorrentJob)}-trigger")
|
||||
.WithCronSchedule(trigger);
|
||||
});
|
||||
}
|
||||
|
||||
29
code/Executable/Jobs/BlockedTorrentJob.cs
Normal file
29
code/Executable/Jobs/BlockedTorrentJob.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using Infrastructure.Verticals.BlockedTorrent;
|
||||
using Quartz;
|
||||
|
||||
namespace Executable.Jobs;
|
||||
|
||||
[DisallowConcurrentExecution]
|
||||
public sealed class BlockedTorrentJob : IJob
|
||||
{
|
||||
private ILogger<BlockedTorrentJob> _logger;
|
||||
private BlockedTorrentHandler _handler;
|
||||
|
||||
public BlockedTorrentJob(ILogger<BlockedTorrentJob> logger, BlockedTorrentHandler handler)
|
||||
{
|
||||
_logger = logger;
|
||||
_handler = handler;
|
||||
}
|
||||
|
||||
public async Task Execute(IJobExecutionContext context)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _handler.HandleAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"{nameof(BlockedTorrentJob)} failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
using Infrastructure.Verticals.FrozenTorrent;
|
||||
using Quartz;
|
||||
|
||||
namespace Executable.Jobs;
|
||||
|
||||
[DisallowConcurrentExecution]
|
||||
public sealed class FrozenTorrentJob : IJob
|
||||
{
|
||||
private ILogger<FrozenTorrentJob> _logger;
|
||||
private FrozenTorrentHandler _handler;
|
||||
|
||||
public FrozenTorrentJob(ILogger<FrozenTorrentJob> logger, FrozenTorrentHandler handler)
|
||||
{
|
||||
_logger = logger;
|
||||
_handler = handler;
|
||||
}
|
||||
|
||||
public async Task Execute(IJobExecutionContext context)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _handler.HandleAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"{nameof(FrozenTorrentJob)} failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@
|
||||
}
|
||||
},
|
||||
"QuartzConfig": {
|
||||
"FrozenTorrentTrigger": "0 0/5 * * * ?"
|
||||
"BlockedTorrentTrigger": "0 0/5 * * * ?"
|
||||
},
|
||||
"QBitConfig": {
|
||||
"Url": "http://localhost:8080",
|
||||
|
||||
Reference in New Issue
Block a user