| | | 1 | | using Anichron.Core.Domain; |
| | | 2 | | using Anichron.Worker.Ingestion.Extraction; |
| | | 3 | | using Anichron.Worker.Ingestion.Pipeline; |
| | | 4 | | using Anichron.Worker.Ingestion.Proxy; |
| | | 5 | | |
| | | 6 | | namespace Anichron.Worker.Ingestion.Classification; |
| | | 7 | | |
| | 63 | 8 | | internal abstract class ProcessedContentWriter( |
| | 63 | 9 | | PairedMovResolver pairedMovResolver, |
| | 63 | 10 | | PairedMovProxyWriter pairedMovProxyWriter, |
| | 63 | 11 | | CaptureZones captureZones) : IOutcomeWriter |
| | | 12 | | { |
| | | 13 | | public abstract IReadOnlyCollection<FileOutcome> Outcomes { get; } |
| | | 14 | | |
| | | 15 | | public async Task<MediaAsset> WriteAsync(IngestionContext context, CancellationToken ct) |
| | 61 | 16 | | { |
| | 61 | 17 | | var asset = await WriteAssetAsync(context, ct); |
| | 61 | 18 | | var classification = context.Classification!; |
| | 61 | 19 | | if (classification.Secondary is { DefersToAnotherRow: false }) |
| | 17 | 20 | | { |
| | 17 | 21 | | var mov = await pairedMovResolver.PairAsync(context, asset, ct); |
| | 17 | 22 | | await pairedMovProxyWriter.WriteMissingAsync(context, mov, ct); |
| | 17 | 23 | | } |
| | | 24 | | |
| | 61 | 25 | | return asset; |
| | 61 | 26 | | } |
| | | 27 | | |
| | | 28 | | protected abstract Task<MediaAsset> WriteAssetAsync(IngestionContext context, CancellationToken ct); |
| | | 29 | | |
| | | 30 | | /// <summary>The processed file's content, with the proxies this attempt registered for <paramref name="assetId"/>.< |
| | | 31 | | /// <param name="context">The processed item.</param> |
| | | 32 | | /// <param name="assetId">The row that takes the content.</param> |
| | | 33 | | protected AssetContent ContentOf(IngestionContext context, Guid assetId) |
| | 61 | 34 | | { |
| | 61 | 35 | | var extracted = context.Extracted!; |
| | 61 | 36 | | return new AssetContent( |
| | 61 | 37 | | context.ContentHash!, |
| | 61 | 38 | | captureZones.DateOf(extracted), |
| | 61 | 39 | | context.Item.PrimaryMediaType, |
| | 61 | 40 | | extracted.Description, |
| | 61 | 41 | | context.Blurhash, |
| | 61 | 42 | | context.ProxyFilesOf(assetId)); |
| | 61 | 43 | | } |
| | | 44 | | } |