E4: API dei video fermi e «Salva il fotogramma»

«È un video fermo?» dal visualizzatore (POST /api/media/{id}/still, con
400/404/409/503 e niente salvato negli errori) e l'esito su ogni video
dell'elemento (media[].still), perché l'interfaccia di WP6 lo mostri.

«Salva il fotogramma» salva il fotogramma scelto dall'analisi (il più
nitido, mai uno scuro, risposta 45): «Scarica» da
/api/media/{id}/still/frame con il nome …_fotogramma.png, e «Nella
cartella delle copie» con frames.mode "fermo" attraverso pianificatore,
impostazioni del lavoro e copiatore (FrameMode.Still, suffisso
_fotogramma, stessa identità delle copie dei fotogrammi di E3). Vale per
un video solo (risposta 46); un video non fermo o mai analizzato si
conta come notStill e non si copia.

«Cerca i video fermi» per una selezione: conferma con i conteggi,
avvio, avanzamento e «Interrompi» (/api/still-videos/*). Tutti i DTO nel
FebeJsonContext; i comandi passano dal controllo dell'Origin. Il servizio
registra con ILogger e FebeApp lo chiude all'arresto prima dell'archivio.
LEGGIMI di Febe.Web aggiornato; prove dell'API su video costruiti.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-29 15:29:06 +01:00
1 parent 4f238f2c9f
commit 51150fb611
17 files changed
+695 -18

No files matched your search

+2 -1
View File
@@ -94,7 +94,8 @@ public sealed record MediaDto(
bool Damaged = false,
IReadOnlyList<MediaCopyDto>? Copies = null,
bool? FramesAvailable = null,
IReadOnlyList<MediaConversionDto>? Conversions = null);
IReadOnlyList<MediaConversionDto>? Conversions = null,
StillVideoDto? Still = null);
/// <summary>Everything the viewer shows of an entry.</summary>
public sealed record EntryDto(
+18 -2
View File
@@ -3,6 +3,7 @@ using Febe.Core.Domain;
using Febe.Core.Export;
using Febe.Core.Library;
using Febe.Core.Library.Conversion;
using Febe.Core.Library.StillVideos;
using Febe.Core.Storage;
using Febe.Web.Export;
using Febe.Web.Library;
@@ -582,7 +583,8 @@ public static class ExportApi
plan.PhotosSkipped,
plan.Frames,
plan.OverCap,
PlanSummary(plan, frames));
PlanSummary(plan, frames),
plan.NotStill);
}
/// <summary>
@@ -605,6 +607,11 @@ public static class ExportApi
{
parts.Add(ExportFrames.OverCapMessage);
}
if (plan.NotStill > 0)
{
parts.Add(StillVideoText.NotStill);
}
}
else
{
@@ -764,8 +771,15 @@ public static class ExportApi
"istante" or "at" => FrameMode.At,
"ogni" or "every" => FrameMode.Every,
"numero" or "count" => FrameMode.Count,
"fermo" or "still" => FrameMode.Still,
_ => throw new BadRequestException("Modo dei fotogrammi sconosciuto: «Questo istante», «Uno ogni k secondi» o «N in tutto»."),
};
if (mode == FrameMode.Still && (body.AtMs is not null || body.EveryMs is not null || body.Count is not null))
{
// The instant is the analysis' own (tappa E4): one asked by the page would be another frame.
throw new BadRequestException("«Salva il fotogramma» prende il fotogramma scelto dall'analisi: niente istante, intervallo o numero.");
}
return new ExportFramesRequest(
mode,
mode == FrameMode.At ? TimeSpan.FromMilliseconds(Math.Max(0, body.AtMs ?? 0)) : null,
@@ -1029,7 +1043,9 @@ public static class ExportApi
[.. start.Runs.Select(r => r.Id)],
Plan(start.Plan, root, frames),
start.Runs.Count == 0
? "Niente da copiare: i file scelti sono già copiati, non si esportano o non sono in libreria."
? start.Plan.NotStill > 0 && start.Plan.Files == 0
? StillVideoText.NotStill + ": niente da copiare."
: "Niente da copiare: i file scelti sono già copiati, non si esportano o non sono in libreria."
: "Copia avviata: segui l'avanzamento nella Dashboard, scheda Esportazione.");
private static ExportRunDto Run(ExportRun run, ExportRunSummary summary, IReadOnlyDictionary<long, string> labels, IClock clock, bool running)
+54 -3
View File
@@ -158,7 +158,8 @@ public sealed record CopyJobRequestDto(
/// <summary>
/// Which frames (spec §4.10 «Fotogrammi»): <paramref name="Mode"/> <c>istante</c> (at <paramref name="AtMs"/>),
/// <c>ogni</c> (every <paramref name="EveryMs"/>, at least 100) or <c>numero</c> (<paramref name="Count"/> in all, 1 to
/// 1.000); <paramref name="Format"/> <c>jpg</c>, <c>png</c> (the default) or <c>webplossless</c>.
/// 1.000), or <c>fermo</c> («Salva il fotogramma» of one still video, tappa E4: the instant of its analysis, nothing
/// else); <paramref name="Format"/> <c>jpg</c>, <c>png</c> (the default) or <c>webplossless</c>.
/// </summary>
public sealed record FramesRequestDto(string? Mode, long? AtMs = null, long? EveryMs = null, int? Count = null, string? Format = null);
@@ -186,7 +187,8 @@ public sealed record ExportPlanDestinationDto(
/// converted, <paramref name="Lossy"/> «con perdita»; a frames job: <paramref name="Videos"/>,
/// <paramref name="PhotosSkipped"/>, <paramref name="Frames"/> and <paramref name="OverCap"/> (videos over 1.000
/// frames: the job is refused). <paramref name="Summary"/>: the line of the dialog («312 file · 41 già copiati, saltati ·
/// circa 3 HEIC copiati come sono · circa 4,2 GB · con perdita»).
/// circa 3 HEIC copiati come sono · circa 4,2 GB · con perdita»). Tappa E4, «Salva il fotogramma»:
/// <paramref name="NotStill"/> videos that are not «Fermo» or were never analysed (skipped).
/// </summary>
public sealed record ExportPlanDto(
int Files,
@@ -204,7 +206,8 @@ public sealed record ExportPlanDto(
int PhotosSkipped = 0,
int Frames = 0,
int OverCap = 0,
string? Summary = null);
string? Summary = null,
int NotStill = 0);
/// <summary>The jobs a «Copia in…» started, one per destination (empty: nothing to copy), and the plan it followed.</summary>
public sealed record ExportJobDto(IReadOnlyList<long> RunIds, ExportPlanDto Plan, string Message);
@@ -356,3 +359,51 @@ public sealed record ConversionActionRequest(long ConversionId);
/// the library made from them («elimino gli elementi interi, 9 file e 2 file convertiti»).
/// </summary>
public sealed record EntryDeletionPreviewDto(int Entries, int Files, int ConvertedFiles);
// ---------------------------------------------------------------------------------------------- still videos (tappa E4)
/// <summary>
/// The analysis of a video («È un video fermo?», spec §4.10, tappa E4), on <see cref="MediaDto.Still"/> and as the answer
/// of <c>POST /api/media/{id}/still</c>; a video never analysed has none. <paramref name="Outcome"/>: <c>still</c>,
/// <c>moving</c> or <c>notAnalyzable</c>; <paramref name="Current"/>: made by the algorithm of this Febe (otherwise
/// «Analizza di nuovo»); <paramref name="FrameAtMs"/> and <paramref name="FrameLabel"/> («0:01,125»): the frame
/// «Salva il fotogramma» saves, only on <c>still</c>; <paramref name="Note"/>: English codes separated by spaces
/// (<c>FrameNotAvailable</c>, <c>DurationUnknown</c>, <c>Unreadable</c>, <c>TooSlow</c>, <c>AllDark</c>,
/// <c>SingleColor</c>, <c>SmallMotion</c>); <paramref name="Day"/>: the local day of the analysis (yyyy-MM-dd).
/// </summary>
public sealed record StillVideoDto(string Outcome, bool Current, long? FrameAtMs, string? FrameLabel, string? Note, string Day);
/// <summary>
/// The selection of «Cerca i video fermi»: exactly one of <paramref name="MediaIds"/>, <paramref name="EntryIds"/>
/// (every video of those entries), <paramref name="Query"/> with <paramref name="Mode"/>, or <paramref name="AccountId"/>.
/// </summary>
public sealed record StillVideosSelectionRequest(IReadOnlyList<long>? MediaIds, IReadOnlyList<long>? EntryIds, string? Query, string? Mode, long? AccountId = null);
/// <summary>
/// <c>POST /api/still-videos/plan</c>: the confirmation of «Cerca i video fermi», by file (two entries of one video count
/// once). <paramref name="Videos"/> = <paramref name="ToAnalyse"/> + <paramref name="AlreadyAnalysed"/> (skipped) +
/// <paramref name="Missing"/> (not in the library); <paramref name="PhotosSkipped"/>: photos of the selection;
/// <paramref name="Summary"/>: «28 video da analizzare · 12 già analizzati · le 5 foto si saltano»;
/// <paramref name="Waiting"/>: why the job would wait now (an engine session, an import, copies or a rebuild), or null.
/// </summary>
public sealed record StillVideosPlanDto(int Videos, int ToAnalyse, int AlreadyAnalysed, int PhotosSkipped, int Missing, string Summary, string? Waiting);
/// <summary>
/// The job «Cerca i video fermi» (<c>GET /api/still-videos/progress</c>, and the answer of start and stop):
/// <paramref name="Done"/> of <paramref name="Total"/> settled as <paramref name="Still"/>, <paramref name="Moving"/>,
/// <paramref name="NotAnalyzable"/> or <paramref name="Skipped"/> (file gone or changed); <paramref name="Stopped"/>:
/// ended by «Interrompi»; <paramref name="Waiting"/>: why it waits now; <paramref name="CurrentMediaId"/>: the file analysed
/// now; <paramref name="Summary"/>: «Analizzati 28 video: 3 fermi, 24 in movimento, 1 non analizzabile».
/// </summary>
public sealed record StillVideosProgressDto(
bool Running,
int Total,
int Done,
int Still,
int Moving,
int NotAnalyzable,
int Skipped,
bool Stopped,
string? Waiting,
long? CurrentMediaId,
string Summary);
+4
View File
@@ -115,4 +115,8 @@ namespace Febe.Web.Api;
[JsonSerializable(typeof(FramesTokenDto))]
[JsonSerializable(typeof(ConversionActionRequest))]
[JsonSerializable(typeof(EntryDeletionPreviewDto))]
[JsonSerializable(typeof(StillVideoDto))]
[JsonSerializable(typeof(StillVideosSelectionRequest))]
[JsonSerializable(typeof(StillVideosPlanDto))]
[JsonSerializable(typeof(StillVideosProgressDto))]
public sealed partial class FebeJsonContext : JsonSerializerContext;
+15 -3
View File
@@ -4,6 +4,7 @@ using Febe.Core.Domain;
using Febe.Core.Export;
using Febe.Core.Library;
using Febe.Core.Library.Conversion;
using Febe.Core.Library.StillVideos;
using Febe.Core.Storage;
using Febe.Web.Export;
using Febe.Web.Library;
@@ -63,6 +64,11 @@ public static class FramesApi
{
var video = await VideoAsync(storage, files, id, ct).ConfigureAwait(false);
var request = ExportApi.Frames(new FramesRequestDto(mode ?? "numero", at, every, count, "png"));
if (request.Mode == FrameMode.Still)
{
throw new BadRequestException(StillVideoText.FromViewerOnly);
}
ExportPlanner.Validate(new ExportJobRequest(new ExportSelection.Media([id]), Frames: request));
var info = await frames.InfoAsync(video.Path, video.Media.Sha256, ct).ConfigureAwait(false);
var durationMs = (long)info.Duration.TotalMilliseconds;
@@ -231,6 +237,12 @@ public static class FramesApi
private static async Task<FramesSelection> SelectionAsync(FramesSelectionRequest body, IFebeStorage storage, IMediaFileResolver files, FrameService frames, IClock clock, CancellationToken ct)
{
var request = body.Frames is { } f ? ExportApi.Frames(f) : throw new BadRequestException("Scegli quali fotogrammi.");
if (request.Mode == FrameMode.Still)
{
// «Scarica» of «Salva il fotogramma» is /api/media/{id}/still/frame (StillVideosApi).
throw new BadRequestException(StillVideoText.FromViewerOnly);
}
var selection = ExportApi.Request(new CopyJobRequestDto(body.MediaIds, body.EntryIds, body.Query, body.Mode, null), clock).Selection;
ExportPlanner.Validate(new ExportJobRequest(selection, Frames: request));
var accounts = (await storage.Accounts.ListAsync(ct).ConfigureAwait(false)).ToDictionary(a => a.Id);
@@ -387,10 +399,10 @@ public static class FramesApi
// ---------------------------------------------------------------------------------------------- helpers
private sealed record VideoFile(Account Account, Media Media, string Path);
internal sealed record VideoFile(Account Account, Media Media, string Path);
/// <summary>A present video of the library on disk; 404 otherwise.</summary>
private static async Task<VideoFile> VideoAsync(IFebeStorage storage, IMediaFileResolver files, long mediaId, CancellationToken ct)
internal static async Task<VideoFile> VideoAsync(IFebeStorage storage, IMediaFileResolver files, long mediaId, CancellationToken ct)
{
var media = await storage.Media.GetAsync(mediaId, ct).ConfigureAwait(false) ?? throw new NotFoundException("File non trovato.");
if (media.Kind != MediaKind.Video)
@@ -404,7 +416,7 @@ public static class FramesApi
return new VideoFile(account, media, path);
}
private static string Stem(Media media) =>
internal static string Stem(Media media) =>
media.RelativePath is { } relative ? Path.GetFileNameWithoutExtension(LibraryLayout.ToPlatform(relative)) : "video-" + media.Id.ToString(CultureInfo.InvariantCulture);
/// <summary>The file of a Converted or Superseded conversion of a present account, or null.</summary>
+7 -1
View File
@@ -274,6 +274,9 @@ public static class LibraryApi
var avatar = await AccountsApi.AvatarAsync(storage, account.Id, ct).ConfigureAwait(false);
var copies = await EntryCopiesContext.LoadAsync(storage, account, ct).ConfigureAwait(false);
var converted = conversions is null ? [] : await storage.Conversions.ListByEntryAsync(id, ct).ConfigureAwait(false);
// «È un video fermo?» (tappa E4): the analyses of the entry's videos, in one read, by SHA-256 of the file.
var videoShas = stored.Media.Where(m => m.Kind == MediaKind.Video && m.Sha256 is { Length: 64 }).Select(m => m.Sha256!.ToLowerInvariant()).Distinct(StringComparer.Ordinal).ToList();
var analyses = videoShas.Count == 0 ? null : await storage.VideoAnalyses.GetManyAsync(videoShas, ct).ConfigureAwait(false);
var media = new List<MediaDto>(stored.Media.Count);
foreach (var m in stored.Media)
{
@@ -303,7 +306,10 @@ public static class LibraryApi
damaged,
copies is null ? null : await copies.CopiesAsync(storage, m, now, zone, ct).ConfigureAwait(false),
await FramesAvailableAsync(frames, m, path, ct).ConfigureAwait(false),
conversions is null ? null : FramesApi.Conversions(conversions, account, converted.Where(c => c.MediaId == m.Id))));
conversions is null ? null : FramesApi.Conversions(conversions, account, converted.Where(c => c.MediaId == m.Id)),
m.Kind == MediaKind.Video && m.Sha256 is { Length: 64 } sha && analyses is not null && analyses.TryGetValue(sha.ToLowerInvariant(), out var analysis)
? StillVideosApi.Dto(analysis, clock)
: null));
}
return new EntryDto(
+142
View File
@@ -0,0 +1,142 @@
using Febe.Core.Abstractions;
using Febe.Core.Domain;
using Febe.Core.Export;
using Febe.Core.Library;
using Febe.Core.Library.StillVideos;
using Febe.Core.Storage;
using Febe.Web.Export;
using Febe.Web.Library;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;
namespace Febe.Web.Api;
/// <summary>
/// Still videos (spec §4.10, tappa E4), only on request, never in the background: «È un video fermo?» of one video
/// from the viewer (also during an engine session, within 30 s, answer 43), the frame of «Salva il fotogramma» for
/// «Scarica» (<c>…_fotogramma.png</c>, the sharpest frame the analysis looked at, answer 45), and the job «Cerca i video
/// fermi» of a selection with its confirmation, progress and «Interrompi» (answer 41). «Salva il fotogramma» to the
/// folder of the copies goes through <c>/api/export/plan</c> and <c>/start</c> with <c>frames: { mode: "fermo" }</c>.
/// Every command passes the Origin check of the security middleware like any other. Nothing here writes a file.
/// </summary>
public static class StillVideosApi
{
public static void Map(IEndpointRouteBuilder endpoints)
{
ArgumentNullException.ThrowIfNull(endpoints);
endpoints.MapPost("/api/media/{id:long}/still", async (long id, StillVideoService stills, IClock clock, CancellationToken ct) =>
{
var answer = await stills.AnalyseNowAsync(id, ct).ConfigureAwait(false);
return answer.Kind switch
{
StillVideoAnswerKind.Analysed => ApiHttp.Json(Dto(answer.Analysis!, clock), FebeJsonContext.Default.StillVideoDto),
StillVideoAnswerKind.NotAVideo => throw new BadRequestException(answer.Message!),
StillVideoAnswerKind.SourceChanged => throw new ApiStatusException(409, answer.Message!),
StillVideoAnswerKind.TooSlow => throw new ApiStatusException(503, answer.Message!),
_ => throw new NotFoundException(answer.Message ?? StillVideoText.NotFound),
};
});
endpoints.MapGet("/api/media/{id:long}/still/frame", async (long id, string? format, int? max, string? download, HttpContext context, IFebeStorage storage, IMediaFileResolver files, FrameService frames, CancellationToken ct) =>
{
var video = await FramesApi.VideoAsync(storage, files, id, ct).ConfigureAwait(false);
var analysis = video.Media.Sha256 is { Length: 64 } sha ? await storage.VideoAnalyses.GetAsync(sha.ToLowerInvariant(), ct).ConfigureAwait(false) : null;
if (analysis is not { Outcome: VideoAnalysisOutcome.Still, FrameAt: { } at })
{
throw new ApiStatusException(409, StillVideoText.NotStill + ".");
}
int? side = max is { } m ? Math.Clamp(m, 16, FrameService.MaxPreview) : null;
var chosen = string.IsNullOrWhiteSpace(format) && side is not null ? ExportFormat.Jpg : ExportApi.ParseFrameFormat(format);
var frame = await frames.FrameAsync(video.Path, video.Media.Sha256, at, chosen, side, ct).ConfigureAwait(false);
// A new analysis can choose another frame at the same address: never kept by the browser.
context.Response.Headers.CacheControl = "private, no-cache";
if (download is "1" or "true")
{
var name = FrameService.FileName(FramesApi.Stem(video.Media), FrameMode.Still, frame.Actual, 0, 1, chosen);
return Results.File(frame.Data, frame.ContentType, name);
}
return Results.File(frame.Data, frame.ContentType);
});
endpoints.MapPost("/api/still-videos/plan", async (HttpContext context, StillVideoService stills, LongWorkGate gate, IEngineSessionState session, IClock clock, CancellationToken ct) =>
{
var body = await ApiHttp.BodyAsync(context, FebeJsonContext.Default.StillVideosSelectionRequest).ConfigureAwait(false);
var selection = Selection(body, clock);
var plan = await ExportApi.GuardAsync(() => stills.PlanAsync(selection, ct)).ConfigureAwait(false);
return ApiHttp.Json(
new StillVideosPlanDto(plan.Videos, plan.ToAnalyse, plan.AlreadyAnalysed, plan.PhotosSkipped, plan.Missing, StillVideoText.PlanSummary(plan), Waiting(gate, session)),
FebeJsonContext.Default.StillVideosPlanDto);
});
endpoints.MapPost("/api/still-videos/start", async (HttpContext context, StillVideoService stills, IClock clock, CancellationToken ct) =>
{
var body = await ApiHttp.BodyAsync(context, FebeJsonContext.Default.StillVideosSelectionRequest).ConfigureAwait(false);
var selection = Selection(body, clock);
var progress = await ExportApi.GuardAsync(() => stills.StartAsync(selection, ct)).ConfigureAwait(false);
return ApiHttp.Json(Progress(progress), FebeJsonContext.Default.StillVideosProgressDto);
});
endpoints.MapGet("/api/still-videos/progress", (StillVideoService stills) =>
ApiHttp.Json(Progress(stills.Progress), FebeJsonContext.Default.StillVideosProgressDto));
endpoints.MapPost("/api/still-videos/stop", (StillVideoService stills) =>
ApiHttp.Json(Progress(stills.Stop()), FebeJsonContext.Default.StillVideosProgressDto));
}
/// <summary>The analysis of a video as the viewer shows it.</summary>
public static StillVideoDto Dto(VideoAnalysis analysis, IClock clock)
{
ArgumentNullException.ThrowIfNull(analysis);
ArgumentNullException.ThrowIfNull(clock);
var still = analysis.Outcome == VideoAnalysisOutcome.Still ? analysis.FrameAt : null;
return new StillVideoDto(
Outcome(analysis.Outcome),
analysis.Algorithm >= StillVideoAnalyzer.Algorithm,
still is { } at ? ExportFrames.ActualMs(at) : null,
still is { } shown ? ExportFrames.Label(shown) : null,
analysis.Note,
ApiMapping.Day(DateOnly.FromDateTime(LocalCalendar.ToLocal(analysis.AnalyzedAt, clock.LocalZone))));
}
/// <summary>The wire name of an outcome: <c>still</c>, <c>moving</c>, <c>notAnalyzable</c>.</summary>
public static string Outcome(VideoAnalysisOutcome outcome) => outcome switch
{
VideoAnalysisOutcome.Still => "still",
VideoAnalysisOutcome.Moving => "moving",
_ => "notAnalyzable",
};
private static StillVideosProgressDto Progress(StillVideoProgress p) => new(
p.Running,
p.Total,
p.Done,
p.Still,
p.Moving,
p.NotAnalyzable,
p.Skipped,
p.Stopped,
p.Waiting,
p.CurrentMediaId,
StillVideoText.Summary(p));
/// <summary>Exactly one selection, as «Copia in…» and «Fotogrammi…» take it.</summary>
private static ExportSelection Selection(StillVideosSelectionRequest body, IClock clock)
{
var chosen = (body.MediaIds is { Count: > 0 } ? 1 : 0) + (body.EntryIds is { Count: > 0 } ? 1 : 0) + (body.Query is not null ? 1 : 0) + (body.AccountId is not null ? 1 : 0);
if (chosen != 1)
{
throw new BadRequestException(StillVideoText.NoSelection);
}
return ExportApi.Request(new CopyJobRequestDto(body.MediaIds, body.EntryIds, body.Query, body.Mode, body.AccountId), clock).Selection;
}
/// <summary>Why the job would wait now (the dialog says it), or null.</summary>
private static string? Waiting(LongWorkGate gate, IEngineSessionState session) =>
session.InSession ? StillVideoText.InSession : gate.Busy is not null ? StillVideoText.LongWork : null;
}
+4
View File
@@ -112,6 +112,8 @@ public static class FebeWeb
var clock = sp.GetRequiredService<IClock>();
var changes = sp.GetRequiredService<LibraryChanges>();
var files = sp.GetRequiredService<IMediaFileResolver>();
// Italian text and exception type names only (never paths), to the log of the composition (Febe's in FebeApp).
var logger = sp.GetService<ILoggerFactory>()?.CreateLogger("Febe.VideoFermi");
return new StillVideoService(new StillVideoEnvironment
{
Storage = sp.GetRequiredService<IFebeStorage>(),
@@ -120,6 +122,7 @@ public static class FebeWeb
Gate = sp.GetRequiredService<LongWorkGate>(),
Session = sp.GetRequiredService<IEngineSessionState>(),
Changed = accountId => changes.Publish(new LibraryChange(clock.Now, accountId, "fermi")),
Log = logger is null ? null : message => logger.LogWarning("{Message}", message),
});
});
services.AddHttpContextAccessor();
@@ -185,6 +188,7 @@ public static class FebeWeb
ImportApi.Map(endpoints);
ExportApi.Map(endpoints);
FramesApi.Map(endpoints);
StillVideosApi.Map(endpoints);
DuplicatesApi.Map(endpoints);
SearchApi.Map(endpoints);
RemoteViewSocket.Map(endpoints);
+4 -1
View File
@@ -76,6 +76,7 @@ Tutti con un ripiego registrato con `TryAdd`; la composizione registra i propri
| `ExportRootOptions` (Core, copie esterne §4.10) | Docker: `/esporta` **non dichiarata** (nulla si scrive); desktop: qualsiasi cartella | Server: `--esporta`/`FEBE_ESPORTA` (attiva solo se c'è un montaggio su `/esporta` o sotto); dimostrazione: la sua `esporta`, mostrata come `/esporta` (`ShownAs`) |
| `IExportDisk` (Core) | `SystemExportDisk` (spazio libero delle lettere di unità, FAT32 dal tipo del file system) | Desktop: `WindowsExportDisk` (anche le condivisioni di rete come `\\nas\foto`); prove e dimostrazione: misure fisse |
| `IEngineSessionState` (Core) | `NoEngineSession`: le copie non aspettano mai | `Febe.App`: `RuntimeSessionState` sul motore (fra una sessione e l'altra, D10) |
| `StillVideoService` (Core, tappa E4) | Uno solo sull'archivio, sui file della libreria (`IMediaFileResolver`), su `LongWorkGate` e `IEngineSessionState`, con lo SHA-256 controllato prima di ogni analisi; il registro riceve solo testo italiano e nomi di eccezioni | La dimostrazione ne vuole uno con `VerifySource = false` (i suoi SHA-256 non sono quelli dei file); le prove, budget diversi. `Febe.App` usa il ripiego e lo chiude all'arresto prima dell'archivio |
| `ExportHub` (`Export/`) | Costruisce l'unico `ExportService` al primo uso (e segna «interrotto» ciò che l'arresto ha fermato, `Recovered`); a lavoro finito pubblica `LibraryChange` con motivo `export` | Nessuno |
- `ImportHub.LibrarySettingsChanged()` va chiamato quando cambiano cartella o schema dei nomi (lo fa già
@@ -143,8 +144,10 @@ sono anche `day` (`aaaa-mm-gg`) e `clock` calcolati sul fuso di Febe.
| `GET /api/export/library-conversion`, `GET /library-conversion/preview?photo=&video=`, `POST /library-conversion/retry`, `/pause`, `/resume` | Conversione della libreria (tappa E3): `pending`, `converted`, `failed`, `asIs`, `paused`, `waiting`, `text`; la domanda «Converti anche i N già in libreria?» (`{ files, bytes, text }`); «Riprova», «Metti in pausa», «Riprendi» |
| `GET /api/export/folders?path=`, `POST /api/export/pick-folder` (`{ destinationId }`), `/check-folder` (`{ path }`), `/naming-preview` | Scelta della cartella: in Docker l'elenco sotto `/esporta` (solo se attiva; `..` è 400), sul desktop la finestra del sistema; controllo con spazio libero e FAT32; «Risultato» dei nomi |
| `POST /api/export/destinations`, `PUT/DELETE /api/export/destinations/{id}`, `GET /{id}/status`, `POST /{id}/resume`, `/{id}/check` | Cartelle: tipi `postFoto`, `postVideo`, `storie`, `evidenza`, `taggati`, `profilo`; `photoFormat` e `videoFormat` (vuoti o `general`: come le impostazioni generali); un cambio di cartella dà un id nuovo; togliere non cancella nulla; «Riprova» (sonda, poi riprende i lavori in pausa); «Controlla le copie» |
| `POST /api/export/plan`, `/start` (`{ mediaIds \| entryIds \| query+mode \| accountId, copyAgain, photoFormat?, videoFormat?, frames? }`, uno solo), `POST /api/export/copy-again` (`{ copyId }`) | «Copia in…»: riepilogo (con `asIs`, `converted`, `lossy`, `videos`, `photosSkipped`, `frames`, `overCap`, `summary`), avvio (`runIds`, il piano, un messaggio), «Copia di nuovo» di un file tolto o superato nella sua forma esatta. `frames` (`{ mode: "istante"\|"ogni"\|"numero", atMs, everyMs, count, format }`) copia fotogrammi dei video invece dei file; non va insieme ai formati |
| `POST /api/export/plan`, `/start` (`{ mediaIds \| entryIds \| query+mode \| accountId, copyAgain, photoFormat?, videoFormat?, frames? }`, uno solo), `POST /api/export/copy-again` (`{ copyId }`) | «Copia in…»: riepilogo (con `asIs`, `converted`, `lossy`, `videos`, `photosSkipped`, `frames`, `overCap`, `summary`), avvio (`runIds`, il piano, un messaggio), «Copia di nuovo» di un file tolto o superato nella sua forma esatta. `frames` (`{ mode: "istante"\|"ogni"\|"numero", atMs, everyMs, count, format }`) copia fotogrammi dei video invece dei file; non va insieme ai formati. `mode: "fermo"` (tappa E4) è «Salva il fotogramma» → «Nella cartella delle copie»: un solo file (`mediaIds` di uno), solo `format`, l'istante è quello dell'analisi, nome `…_fotogramma.<ext>`; un video non «Fermo» o mai analizzato si salta (`notStill`, «Non è un video fermo, o non è stato analizzato») |
| `GET /api/media/{id}/frames/info`, `GET /api/media/{id}/frame?at=ms&format=&max=&download=1`, `GET /api/media/{id}/frames/instants?mode=&at=&every=&count=` (ms) | Fotogrammi (`Api/FramesApi.cs`, `Export/FrameService.cs`): se un video li dà; un fotogramma (anteprima con `max` fino a 480 px, JPG; scaricamento a piena risoluzione, PNG se non si sceglie, nome con l'istante vero); gli istanti di una modalità con etichette e suffissi. Uno alla volta, 30 s al più (503 dopo) |
| `POST /api/media/{id}/still`, `GET /api/media/{id}/still/frame?format=&max=&download=1` | Video fermi (`Api/StillVideosApi.cs`, `StillVideoService` di Core, tappa E4), solo a richiesta: «È un video fermo?» analizza subito un video (anche durante una sessione del motore, una analisi alla volta, 30 s al più: 503 «L'analisi richiede troppo tempo: avviala dalla selezione», niente salvato; 400 una foto, 404 file assente, 409 file cambiato) e risponde con `still` (`outcome` `still`\|`moving`\|`notAnalyzable`, `current`, `frameAtMs`, `frameLabel`, `note` in codici inglesi, `day`), lo stesso che ha ogni video del visualizzatore in `media[].still` (null se mai analizzato). Il fotogramma di «Salva il fotogramma» → «Scarica»: quello scelto dall'analisi (il più nitido, mai uno scuro), PNG se non si sceglie, nome `…_fotogramma.<ext>`, `max` per l'anteprima (JPG); 409 se il video non è «Fermo». Mai in cache |
| `POST /api/still-videos/plan`, `/start` (`{ mediaIds \| entryIds \| query+mode \| accountId }`, uno solo), `GET /api/still-videos/progress`, `POST /api/still-videos/stop` | «Cerca i video fermi»: conteggi della conferma per file (`toAnalyse`, `alreadyAnalysed`, `photosSkipped`, `missing`, `summary`, `waiting` se ora aspetterebbe); un lavoro in memoria, un video alla volta, mai durante una sessione del motore né con importazione, copie, ricostruzione o uno zip di fotogrammi (aspetta, `waiting` dice perché), 2 minuti per video (oltre «Non analizzabile»); avanzamento con `summary` («Analizzati 28 video: 3 fermi, 24 in movimento, 1 non analizzabile»); «Interrompi» non salva il video in corso. Non riprende da solo alla riapertura; i già analizzati si saltano. Ogni esito salvato pubblica `LibraryChange` con motivo `fermi` |
| `POST /api/frames/plan`, `POST /api/frames/download-token` (`{ mediaIds \| entryIds \| query+mode, frames }`), `GET /api/frames/download/{token}` | «Fotogrammi…» → «Scarica»: riepilogo; un gettone in memoria (5 minuti, una volta sola); un fotogramma è un'immagine, da 2 a 500 uno zip scritto mentre parte (senza compressione, `<account>/<nome>`). Oltre 20 serve il motore fermo e nessun altro lavoro lungo (409 altrimenti) |
| `GET /api/conversions/{id}/file[?download=1]`, `POST /api/conversions/show-in-folder` (`{ conversionId }`), `POST /api/entries/delete-preview` (`{ ids }`) | File convertiti della libreria (`conversions` di ogni file del visualizzatore, con `framesAvailable` per i video e `frameAtMs`, `frameLabel`, `notes` nelle copie); quanti file e file convertiti toglierebbe «Elimina dalla libreria» |
| `GET /api/export/progress`, `GET /api/export/runs?limit=`, `POST /api/export/interrupt`, `/resume`, `/runs/{id}/resume`, `/runs/{id}/discard`, `GET /runs/{id}/report` | Scheda Esportazione della Dashboard: avanzamento, lavori, interruzione, ripresa, annullamento (i file copiati restano), resoconto (al più 200 problemi) |