📄
src/Cli/Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using System; using System.Linq; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using Slopper.Cli; using Slopper.Cli.YouTubeAuth; using Slopper.Domain; using Slopper.Domain.Describer; using Slopper.Infrastructure.Ai; using Slopper.Infrastructure.Database; using Slopper.Infrastructure.Ffmpeg; using Slopper.Infrastructure.YouTube; var builder = Host.CreateApplicationBuilder(); builder.ConfigureOpenTelemetry(); builder.Services.AddClipSelector().AddClipGenerator().AddCleaner(); builder.Services.AddJellyfinDatabase().AddSlopperDatabase().AddFfmpegServices().AddAi().AddYouTubeUploader(); builder.Services.AddYouTubeAuth(); using var app = builder.Build(); await app.StartAsync(); var lifetime = app.Services.GetRequiredService<IHostApplicationLifetime>(); var logger = app.Services.GetRequiredService<ILogger<Program>>(); using var scope = app.Services.CreateScope(); var timeProvider = scope.ServiceProvider.GetRequiredService<TimeProvider>(); var clipDescriber = scope.ServiceProvider.GetRequiredService<ClipDescriber>(); var utcNow = timeProvider.GetUtcNow(); var media = new MediaItem(Guid.Parse(args[0]), args[1], new Subtitles.Embedded(int.Parse(args[2]))); var start = TimeSpan.Parse(args[3]); var duration = TimeSpan.Parse(args[4]); var description = await clipDescriber.DescribeClip(media, start, duration, lifetime.ApplicationStopping); logger.LogInformation("Description: {Caption} ({Tags})", description.Caption, description.Tags.Select(t => t.Value)); await app.StopAsync();