E3: API di formati e fotogrammi, conversione della libreria e demo

Porta le funzioni della tappa E3 fino all'interfaccia web, così che WP4
possa costruire le schermate su indirizzi veri.

- Impostazioni, cartelle delle copie e «Copia in…» hanno i formati
  (nomi original, jpg, png, webplossless, mp4); il riepilogo dice cosa si
  converte, cosa resta com'è e se c'è perdita. «Copia di nuovo» rifà la
  copia nella sua forma esatta.
- Fotogrammi: informazioni di un video, un fotogramma (anteprima o
  scaricamento), gli istanti di una modalità, «Scarica» di uno o di uno
  zip scritto mentre parte, con il permesso dei lavori lunghi oltre 20.
  Kestrel non vede mai scritture sincrone: il piccolo descrittore che lo
  zip di .NET 10 scrive in modo sincrono parte con la scrittura seguente.
- Conversione della libreria: stato, la domanda «Converti anche i N già
  in libreria?», riprova, pausa e ripresa; il visualizzatore mostra i
  file convertiti, e le eliminazioni li contano.
- Demo: un video H.264 scritto in casa (solo macroblocchi I_PCM) per
  ogni video, una copia in PNG, un fotogramma e due conversioni; la
  conversione non parte mai.

Due prove cambiano con il comportamento: i video della demo ora si
aprono, e un file non copiato può avere il segno «solo fotogramma».

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-28 01:02:37 +01:00
1 parent 724c5bda6f
commit ab0d717424
25 files changed
+2559 -95

No files matched your search

+153 -16
View File
@@ -43,11 +43,16 @@ public sealed record ExportDestinationDto(
bool? Reachable = null,
long? FreeBytes = null,
bool Orphan = false,
string? FormerUsername = null);
string? FormerUsername = null,
string? PhotoFormat = null,
string? VideoFormat = null);
/// <summary>
/// <c>GET /api/export</c>: Impostazioni → Esportazione and the notice of the Dashboard. <paramref name="SamePost"/>:
/// <c>onePerAccount</c> or <c>oneOnly</c>. <paramref name="UnfinishedRuns"/>: interrupted or paused jobs («Riprendi»).
/// Formats (tappa E3) on the wire: <c>original</c>, <c>jpg</c>, <c>png</c>, <c>webplossless</c>, <c>mp4</c>; the
/// library ones are <c>original</c> while the conversion of the library is off. <paramref name="LibraryConversion"/>:
/// the state of that conversion.
/// </summary>
public sealed record ExportOverviewDto(
ExportRootDto Root,
@@ -56,10 +61,44 @@ public sealed record ExportOverviewDto(
IReadOnlyList<ExportDestinationDto> Own,
IReadOnlyList<long> ActiveRunIds,
int UnfinishedRuns,
ExportSchemesDto Library);
ExportSchemesDto Library,
string PhotoFormat = "original",
string VideoFormat = "original",
string LibraryPhotoFormat = "original",
string LibraryVideoFormat = "original",
LibraryConversionDto? LibraryConversion = null);
/// <summary><c>PUT /api/export/settings</c>: «Lo stesso post in due account», <c>onePerAccount</c> or <c>oneOnly</c>.</summary>
public sealed record ExportSettingsRequest(string SamePost);
/// <summary>
/// The conversion of the library (tappa E3, spec §4.10): files in the queue, converted, failed («Riprova»), that never
/// convert (<paramref name="AsIs"/>: «non si convertono»), «In pausa», and why it waits (Italian, null when it does
/// not): an import, a copy or a rebuild at work, an engine session, low space. <paramref name="Text"/>: the status line
/// («In coda 12 · convertiti 340 · non riusciti 2 · non si convertono 3»). <paramref name="On"/>: a library format is
/// chosen.
/// </summary>
public sealed record LibraryConversionDto(int Pending, int Converted, int Failed, int AsIs, bool Paused, string? Waiting, string Text, bool On);
/// <summary>
/// <c>PUT /api/export/settings</c>, every field optional (null keeps it): «Lo stesso post in due account»
/// (<c>onePerAccount</c> or <c>oneOnly</c>), the formats of the copies and of the library (wire names).
/// <paramref name="ConvertExisting"/>: the answer «Anche i N già in libreria» when a library format is turned on.
/// </summary>
public sealed record ExportSettingsRequest(
string? SamePost = null,
string? PhotoFormat = null,
string? VideoFormat = null,
string? LibraryPhotoFormat = null,
string? LibraryVideoFormat = null,
bool? ConvertExisting = null);
/// <summary>What <c>PUT /api/export/settings</c> did: a message, the overview after the change, the files queued.</summary>
public sealed record ExportSettingsSavedDto(string Message, ExportOverviewDto Overview, int Queued = 0);
/// <summary>
/// «Converti anche i N file già in libreria?»: <paramref name="Files"/> that would enter the queue, the bytes of their
/// originals («circa») and the line of the question («gli originali occupano circa 3,1 GB; i convertiti possono occupare
/// di più»).
/// </summary>
public sealed record LibraryConversionPreviewDto(int Files, long Bytes, string Text);
/// <summary>Docker: the subfolders of a folder of <c>/esporta</c>. <paramref name="Relative"/> is "" for the root.</summary>
public sealed record ExportFolderListDto(string Relative, string? Parent, string Display, IReadOnlyList<SourceFolderDto> Folders);
@@ -88,7 +127,9 @@ public sealed record ExportDestinationRequest(
string? HighlightNamingScheme,
string? ProfileNamingScheme,
bool Automatic = false,
bool OnlyNew = true);
bool OnlyNew = true,
string? PhotoFormat = null,
string? VideoFormat = null);
/// <summary>A saved destination (a change of folder gives a new id) and the warnings of its schemes.</summary>
public sealed record ExportDestinationSavedDto(ExportDestinationDto Destination, IReadOnlyList<string> Warnings);
@@ -97,7 +138,10 @@ public sealed record ExportDestinationSavedDto(ExportDestinationDto Destination,
/// What a «Copia in…» copies: exactly one of <paramref name="MediaIds"/> (files of «Tutte le foto» or the viewer),
/// <paramref name="EntryIds"/> (a grouped selection), <paramref name="Query"/> (the filter of the Libreria, as its query
/// string, with <paramref name="Mode"/> <c>grouped</c> or <c>files</c>) or <paramref name="AccountId"/> (every file of
/// the account). <paramref name="CopyAgain"/>: «Copia di nuovo anche i tolti o superati».
/// the account). <paramref name="CopyAgain"/>: «Copia di nuovo anche i tolti o superati». Tappa E3:
/// <paramref name="PhotoFormat"/>/<paramref name="VideoFormat"/> override the destination's for this request only
/// (null: as the destination); <paramref name="Frames"/> makes it a frames job («Fotogrammi…» → «Nella cartella delle
/// copie»), without formats.
/// </summary>
public sealed record CopyJobRequestDto(
IReadOnlyList<long>? MediaIds,
@@ -105,7 +149,20 @@ public sealed record CopyJobRequestDto(
string? Query,
string? Mode,
long? AccountId,
bool CopyAgain = false);
bool CopyAgain = false,
string? PhotoFormat = null,
string? VideoFormat = null,
FramesRequestDto? Frames = null);
/// <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>.
/// </summary>
public sealed record FramesRequestDto(string? Mode, long? AtMs = null, long? EveryMs = null, int? Count = null, string? Format = null);
/// <summary>Files of a plan copied as they are, of one kind («3 HEIC copiati come sono»).</summary>
public sealed record ExportPlanAsIsDto(string Label, int Files);
/// <summary>A destination of a plan. <paramref name="Problem"/>: why it cannot be written now (paused, not reachable).</summary>
public sealed record ExportPlanDestinationDto(
@@ -123,7 +180,12 @@ public sealed record ExportPlanDestinationDto(
/// <summary>
/// The summary of «Copia in…» (spec §10.3). <paramref name="Files"/>/<paramref name="Bytes"/>: what will be written
/// (with «Copia di nuovo» the tolti/superati too). <paramref name="NotExported"/>: of accounts that are not exported
/// (switch off, no destination, type not taken). <paramref name="Missing"/>: not in the library.
/// (switch off, no destination, type not taken). <paramref name="Missing"/>: not in the library. Tappa E3:
/// <paramref name="AsIs"/> files predicted copied as they are («circa»), <paramref name="Converted"/> predicted
/// 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»).
/// </summary>
public sealed record ExportPlanDto(
int Files,
@@ -133,7 +195,15 @@ public sealed record ExportPlanDto(
int NotExported,
int Missing,
IReadOnlyList<ExportPlanDestinationDto> Destinations,
bool HasDestination = true);
bool HasDestination = true,
IReadOnlyList<ExportPlanAsIsDto>? AsIs = null,
int Converted = 0,
bool Lossy = false,
int Videos = 0,
int PhotosSkipped = 0,
int Frames = 0,
int OverCap = 0,
string? Summary = null);
/// <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);
@@ -174,24 +244,33 @@ public sealed record ExportRunDto(
int Done,
bool Running = false);
/// <summary>The files of one account in a job (<paramref name="Copied"/> counts written and adopted files).</summary>
public sealed record ExportReportAccountDto(long? AccountId, string Username, int Copied, int AlreadyCopied, int Skipped, int Failed);
/// <summary>
/// The files of one account in a job (<paramref name="Copied"/> counts written and adopted files).
/// <paramref name="AsIs"/>: files copied as they are, by kind («HEIC» → 3).
/// </summary>
public sealed record ExportReportAccountDto(long? AccountId, string Username, int Copied, int AlreadyCopied, int Skipped, int Failed, IReadOnlyDictionary<string, int>? AsIs = null);
/// <summary>A file of the report that needs a look, with its reason in Italian.</summary>
public sealed record ExportReportLineDto(long ItemId, string Username, string? Path, string State, string Text);
/// <summary>The report of a job (at most 200 problems).</summary>
/// <summary>
/// The report of a job (at most 200 problems). <paramref name="Notes"/> (tappa E3): files copied or adopted with a note
/// (what a conversion could not keep, a file copied as it is), at most 200.
/// </summary>
public sealed record ExportReportDto(
ExportRunDto Run,
IReadOnlyDictionary<string, int> ByState,
long BytesCopied,
IReadOnlyList<ExportReportAccountDto> Accounts,
IReadOnlyList<ExportReportLineDto> Problems);
IReadOnlyList<ExportReportLineDto> Problems,
IReadOnlyList<ExportReportLineDto>? Notes = null);
/// <summary>
/// A copy of a file of the viewer (spec §4.6, §4.10). <paramref name="State"/>: copied, removed, superseded, failed;
/// <paramref name="Variant"/>: whole (tappa E2 copies originals only). <paramref name="ForAccount"/>: with «Una copia
/// sola», the account it was copied for when it is another one. <paramref name="CanCopyAgain"/>: «Copia di nuovo».
/// <paramref name="Variant"/>: whole, converted or frame; <paramref name="Format"/>: the wire name of a converted copy or
/// of a frame (null for a whole one); <paramref name="FrameAtMs"/> and <paramref name="FrameLabel"/> («0:01,25») for a
/// frame. <paramref name="ForAccount"/>: with «Una copia sola», the account it was copied for when it is another one.
/// <paramref name="CanCopyAgain"/>: «Copia di nuovo» of that same form. <paramref name="Notes"/>: why it failed.
/// </summary>
public sealed record MediaCopyDto(
long CopyId,
@@ -203,7 +282,17 @@ public sealed record MediaCopyDto(
long? FrameAtMs,
LocalTimeDto At,
string? ForAccount,
bool CanCopyAgain);
bool CanCopyAgain,
string? FrameLabel = null,
string? Notes = null);
/// <summary>
/// A converted file of the library next to its original (tappa E3, spec §4.10): <paramref name="Format"/> (wire name),
/// <paramref name="State"/> <c>pending</c>, <c>converted</c>, <c>failed</c>, <c>asIs</c> («non si converte»),
/// <c>superseded</c> or <c>removed</c>, its size, and <paramref name="Notes"/>: what was not kept, or why it failed or
/// does not convert. <paramref name="Available"/>: the file is on disk («Scarica», «Mostra nella cartella»).
/// </summary>
public sealed record MediaConversionDto(long Id, string Format, string State, long? Bytes, string? Notes, bool Available, string? FileName);
/// <summary>
/// «Copie esterne» of the account card. <paramref name="Destination"/>: the effective one (its own folder, else the
@@ -218,3 +307,51 @@ public sealed record ExportAccountDto(
int NotCopied,
int RemovedOrSuperseded,
int Failed);
// ---------------------------------------------------------------------------------------------- frames (tappa E3)
/// <summary>
/// <c>GET /api/media/{id}/frames/info</c>: whether frames can be taken from the video (<paramref name="Unavailable"/>:
/// «Fotogramma non disponibile per questo video»), its length and its size as shown (rotation applied).
/// </summary>
public sealed record FrameInfoDto(bool Available, string? Unavailable, long DurationMs, int Width, int Height, bool HasAudio);
/// <summary>
/// One instant of a frames request: the one asked for, the one really shown (the frame's identity, ms rounded up), its
/// label («0:01,25») and the suffix of its file name (<c>_t0m01s250</c>, <c>_f001</c>).
/// </summary>
public sealed record FrameInstantDto(int Index, long RequestedMs, long ActualMs, string Label, string Suffix);
/// <summary>
/// <c>GET /api/media/{id}/frames/instants</c>: the instants of a mode for one video (at most 1.000). <paramref name="Total"/>:
/// how many it asks; <paramref name="Problem"/>: why none is given (over 1.000, not available).
/// </summary>
public sealed record FrameInstantsDto(long DurationMs, int Total, bool OverCap, string? Problem, IReadOnlyList<FrameInstantDto> Instants);
/// <summary>
/// The frames of a selection («Fotogrammi…» from the selection bars): exactly one of <paramref name="MediaIds"/>,
/// <paramref name="EntryIds"/> (every video of those entries) or <paramref name="Query"/> with <paramref name="Mode"/>,
/// and which frames.
/// </summary>
public sealed record FramesSelectionRequest(IReadOnlyList<long>? MediaIds, IReadOnlyList<long>? EntryIds, string? Query, string? Mode, FramesRequestDto? Frames);
/// <summary>
/// <c>POST /api/frames/plan</c>: what «Scarica» would give. <paramref name="NotAvailable"/>: videos without frames (or
/// not on disk); <paramref name="OverCap"/>: videos over 1.000 frames; <paramref name="TooManyToDownload"/>: more than
/// 500 frames («Nella cartella delle copie»); <paramref name="NeedsQuiet"/>: more than 20 (only outside engine sessions
/// and other long work). <paramref name="Problem"/>: why «Scarica» cannot run now; <paramref name="Summary"/>: the line
/// of the dialog («12 fotogrammi da 4 video · le 3 foto si saltano»).
/// </summary>
public sealed record FramesPlanDto(int Videos, int PhotosSkipped, int NotAvailable, int Frames, int OverCap, bool TooManyToDownload, bool NeedsQuiet, string? Problem, string Summary);
/// <summary>A download of frames ready: open <paramref name="Url"/> once within 5 minutes.</summary>
public sealed record FramesTokenDto(string Token, int Frames, string Url);
/// <summary>A converted file of the library («Mostra nella cartella»).</summary>
public sealed record ConversionActionRequest(long ConversionId);
/// <summary>
/// What «Elimina dalla libreria» would remove (tappa E3, spec §4.6): the entries, their files and the converted files of
/// 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);