| | | 1 | | using Anichron.Core.Data.Repository; |
| | | 2 | | using Anichron.Core.Domain; |
| | | 3 | | using Anichron.Worker.Ingestion.Extraction; |
| | | 4 | | using Anichron.Worker.Ingestion.Pipeline; |
| | | 5 | | using Anichron.Worker.Ingestion.Proxy; |
| | | 6 | | using NodaTime; |
| | | 7 | | |
| | | 8 | | namespace Anichron.Worker.Ingestion.Classification; |
| | | 9 | | |
| | | 10 | | internal sealed class NewContentWriter( |
| | | 11 | | IMediaAssetRepository repository, |
| | | 12 | | IClock clock, |
| | | 13 | | PairedMovResolver pairedMovResolver, |
| | | 14 | | PairedMovProxyWriter pairedMovProxyWriter, |
| | | 15 | | CaptureZones captureZones) |
| | 42 | 16 | | : ProcessedContentWriter(pairedMovResolver, pairedMovProxyWriter, captureZones) |
| | | 17 | | { |
| | 42 | 18 | | public override IReadOnlyCollection<FileOutcome> Outcomes => [FileOutcome.New]; |
| | | 19 | | |
| | | 20 | | protected override Task<MediaAsset> WriteAssetAsync(IngestionContext context, CancellationToken ct) |
| | 41 | 21 | | { |
| | 41 | 22 | | var relativePath = context.Item.RelativePath; |
| | 41 | 23 | | var content = ContentOf(context, context.AssetId); |
| | 41 | 24 | | var asset = new MediaAsset |
| | 41 | 25 | | { |
| | 41 | 26 | | Id = context.AssetId, |
| | 41 | 27 | | StorageConfigId = context.Config.Id, |
| | 41 | 28 | | FilePath = relativePath, |
| | 41 | 29 | | FileName = Path.GetFileName(relativePath), |
| | 41 | 30 | | IsSoftDeleted = false, |
| | 41 | 31 | | LastSeenOnNas = clock.GetCurrentInstant(), |
| | 41 | 32 | | }; |
| | 41 | 33 | | content.ApplyTo(asset); |
| | | 34 | | |
| | 41 | 35 | | repository.Add(asset); |
| | 41 | 36 | | repository.AddProxyFiles(content.Proxies); |
| | 41 | 37 | | return Task.FromResult(asset); |
| | 41 | 38 | | } |
| | | 39 | | } |