src/Cli/Program.cs
+5
-15
diff --git a/src/Cli/Program.cs b/src/Cli/Program.cs
index 19b7a50..fc0c9dc 100644
@@ -1,4 +1,4 @@
using System.Linq;
using System;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
@@ -30,21 +30,11 @@ var logger = app.Services.GetRequiredService<ILogger<Program>>();
using var scope = app.Services.CreateScope();
var clipRepository = scope.ServiceProvider.GetRequiredService<IClipRepository>();
var clip = await clipRepository
.GetLatest(limit: 1, cancellationToken: lifetime.ApplicationStopping)
.FirstOrDefaultAsync(lifetime.ApplicationStopping);
if (clip is null)
var cutoffDateTime = DateTimeOffset.Parse(args[0]);
var clips = clipRepository.GetCreatedBefore(cutoffDateTime, lifetime.ApplicationStopping);
await foreach (var clip in clips)
{
logger.LogInformation("No clips in repository");
return;
logger.LogInformation("{ClipId} was created before {CutoffDateTime}", clip.Id, cutoffDateTime);
}
logger.LogInformation("Uploading {ClipId}", clip.Id);
var youTubeUploader = app.Services.GetRequiredKeyedService<IUploader>("YouTube");
var upload = await youTubeUploader.Upload(clip, lifetime.ApplicationStopping);
logger.LogInformation("Clip uploaded at {Url}", upload.CanonicalUrl);
await app.StopAsync();
src/Cli/Properties/launchSettings.json
+1
-1
diff --git a/src/Cli/Properties/launchSettings.json b/src/Cli/Properties/launchSettings.json
index e91d42b..756f498 100644
@@ -8,7 +8,7 @@
"environmentVariables": {
"DOTNET_ENVIRONMENT": "Development"
},
"commandLineArgs": "D:/slopper/media/S01E01.mkv D:/slopper/media/"
"commandLineArgs": "2026-05-11 12:00:00.000000+00:00"
}
}
}
src/Infrastructure/Database/Slopper/ClipRepository.cs
+8
-2
diff --git a/src/Infrastructure/Database/Slopper/ClipRepository.cs b/src/Infrastructure/Database/Slopper/ClipRepository.cs
index 7c4d150..5d2dac9 100644
@@ -26,9 +26,15 @@ internal sealed class ClipRepository(SlopperDbContext slopperContext) : IClipRep
public IAsyncEnumerable<Clip> GetCreatedBefore(DateTimeOffset before, CancellationToken cancellationToken) =>
slopperContext
.Clips.Include(c => c.Tags)
.Clips.FromSqlInterpolated(
$"""
SELECT *
FROM Clips
WHERE CreatedAt < {before:O} AND RemovedAt IS NULL
"""
)
.Include(c => c.Tags)
.Include(c => c.Uploads)
.Where(c => c.CreatedAt < before && c.RemovedAt == null)
.OrderByDescending(c => c.Id)
.AsAsyncEnumerable();