L'ordine dei tipi (storie, evidenza, post, reel, taggati) ora vale anche per il singolo account: nella scheda account → Impostazioni si sceglie «Come le impostazioni generali» o un ordine suo, con lo stesso elenco da trascinare (o Su/Giù da tastiera) di Limiti e comportamento, ora un modulo solo (download-order.js). Il motore pesa le visite con l'ordine dell'account, la coda dei file mette ogni file al posto del suo tipo nell'ordine del suo account, stabile dentro il tipo (scadenza, scoperta, elemento, posizione). Perché nessun tipo resti fermo per sempre quando il tetto dei dati finisce prima della coda, un posto su otto di ogni giro della coda va al file che aspetta da più tempo, di qualunque tipo. I reel non si inventano (regola 9): un post è reel se viene dalla scheda Reel o se la risposta ha product_type «clips», valore visto nei campioni ripuliti. Il segno si scrive da solo e non si toglie mai, così una copia vecchia non sposta di nuovo i file in coda. Migrazione 0002_ordine_scaricamento (account.download_order, entry.is_reel): prende il primo numero dopo quelle unite, E1 userà il successivo. Prove su motore (seme fisso), coda, lettori, ricette e API; dimostrazione con un account che ha l'ordine suo; guida e decisioni aggiornate. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
193 lines
7.4 KiB
C#
193 lines
7.4 KiB
C#
using System.Text;
|
|
using Febe.Core.Domain;
|
|
|
|
namespace Febe.Core.Collection.Readers;
|
|
|
|
/// <summary>One version of a file as the page received it: an address with its size.</summary>
|
|
/// <param name="Url">Signed address: never logged (spec §13.2).</param>
|
|
/// <param name="Width">Width in pixels, when given.</param>
|
|
/// <param name="Height">Height in pixels, when given.</param>
|
|
/// <param name="HasAudio">For videos: whether the rendition carries audio; null when the response does not say.</param>
|
|
public sealed record FileVersion(string Url, int? Width, int? Height, bool? HasAudio)
|
|
{
|
|
public long Area => (long)(Width ?? 0) * (Height ?? 0);
|
|
|
|
private bool PrintMembers(StringBuilder builder)
|
|
{
|
|
builder.Append($"Width = {Width}, Height = {Height}, HasAudio = {HasAudio}");
|
|
return true;
|
|
}
|
|
}
|
|
|
|
/// <summary>One file of a content item, with the version chosen for download (spec §6.5 point 1).</summary>
|
|
/// <param name="Kind">Photo or video.</param>
|
|
/// <param name="InstagramId">Identifier of this file of a series, when the site gives one.</param>
|
|
/// <param name="Best">Largest image, or best video version complete with audio.</param>
|
|
/// <param name="Cover">For videos: the largest cover image.</param>
|
|
/// <param name="Duration">Video duration, when given.</param>
|
|
public sealed record ContentFile(MediaKind Kind, string? InstagramId, FileVersion Best, FileVersion? Cover, TimeSpan? Duration)
|
|
{
|
|
/// <summary>
|
|
/// Place of the file in its series, from 1, counting the children the response declares even when one of them
|
|
/// cannot be read (no versions yet): a missing file leaves a gap instead of moving the following ones. Null for
|
|
/// a content with a single file.
|
|
/// </summary>
|
|
public int? Position { get; init; }
|
|
}
|
|
|
|
/// <summary>A profile as it appears in a response (author of content, profile page, list of followed profiles).</summary>
|
|
public sealed record ProfileInfo
|
|
{
|
|
public required string Id { get; init; }
|
|
|
|
public required string Username { get; init; }
|
|
|
|
public string? DisplayName { get; init; }
|
|
|
|
public bool? IsPrivate { get; init; }
|
|
|
|
public bool? IsFollowed { get; init; }
|
|
|
|
public int? PostCount { get; init; }
|
|
|
|
/// <summary>Largest version of the profile picture.</summary>
|
|
public FileVersion? Picture { get; init; }
|
|
|
|
/// <summary>Publication time of the latest active story (stories bar).</summary>
|
|
public DateTimeOffset? LatestStoryAt { get; init; }
|
|
|
|
/// <summary>True when the response presents this profile as the connected account (H10).</summary>
|
|
public bool IsViewer { get; init; }
|
|
}
|
|
|
|
/// <summary>A content node: a post, a story or an item of a highlight collection.</summary>
|
|
public sealed record ContentItem
|
|
{
|
|
public required string Id { get; init; }
|
|
|
|
public string? Code { get; init; }
|
|
|
|
public required DateTimeOffset TakenAt { get; init; }
|
|
|
|
/// <summary>Caption: never logged.</summary>
|
|
public string? Caption { get; init; }
|
|
|
|
public ProfileInfo? Owner { get; init; }
|
|
|
|
public bool Pinned { get; init; }
|
|
|
|
public DateTimeOffset? ExpiresAt { get; init; }
|
|
|
|
/// <summary>The files in order (one for a single photo or video, several for a series).</summary>
|
|
public required IReadOnlyList<ContentFile> Files { get; init; }
|
|
|
|
/// <summary>False when the series declares more files than the response carries: Post singolo completes it.</summary>
|
|
public bool IsComplete { get; init; } = true;
|
|
|
|
/// <summary>Identifier of the highlight collection the item was found in, if any.</summary>
|
|
public string? HighlightId { get; init; }
|
|
|
|
/// <summary>Order of appearance in the response, from 0.</summary>
|
|
public int Order { get; init; }
|
|
|
|
/// <summary>The response marks it as a reel, or it was found in the Reel tab (spec §7.2, «Cosa scaricare prima»).</summary>
|
|
public bool IsReel { get; init; }
|
|
|
|
private bool PrintMembers(StringBuilder builder)
|
|
{
|
|
builder.Append($"Id = {Id}, Code = {Code}, TakenAt = {TakenAt:O}, Owner = {Owner?.Username}, Pinned = {Pinned}, IsReel = {IsReel}, Files = {Files.Count}, IsComplete = {IsComplete}");
|
|
return true;
|
|
}
|
|
}
|
|
|
|
/// <summary>A highlight collection, with its contents when the response carries them.</summary>
|
|
public sealed record HighlightInfo
|
|
{
|
|
public required string Id { get; init; }
|
|
|
|
public required string Title { get; init; }
|
|
|
|
public ProfileInfo? Owner { get; init; }
|
|
|
|
public FileVersion? Cover { get; init; }
|
|
|
|
public IReadOnlyList<ContentItem> Items { get; init; } = [];
|
|
|
|
public int Order { get; init; }
|
|
}
|
|
|
|
/// <summary>Pagination information of a page of data.</summary>
|
|
public sealed record PageInfo(bool? HasMore, string? Cursor);
|
|
|
|
/// <summary>What the reader made of a response.</summary>
|
|
public enum ReadShape
|
|
{
|
|
/// <summary>At least one content, profile or highlight was recognized.</summary>
|
|
Recognized,
|
|
|
|
/// <summary>Nothing to read (empty lists, a bare status): not an error, but counts as an empty page.</summary>
|
|
Empty,
|
|
|
|
/// <summary>A shape the vocabulary does not describe: event «formato non riconosciuto» (spec §6.4).</summary>
|
|
Unrecognized,
|
|
|
|
/// <summary>
|
|
/// Nothing the vocabulary speaks about: none of its relevance keys appears anywhere (promotions, logging, a search
|
|
/// box). Ignored: neither data, nor an empty page, nor an unknown shape (<see cref="ReaderVocabulary.Relevance"/>).
|
|
/// </summary>
|
|
Unrelated,
|
|
}
|
|
|
|
/// <summary>Everything one response gave, detached from the JSON document (which is disposed right after).</summary>
|
|
public sealed record ReadResult
|
|
{
|
|
public static ReadResult EmptyResult { get; } = new() { Shape = ReadShape.Empty };
|
|
|
|
public required ReadShape Shape { get; init; }
|
|
|
|
public IReadOnlyList<ContentItem> Contents { get; init; } = [];
|
|
|
|
public IReadOnlyList<ProfileInfo> Profiles { get; init; } = [];
|
|
|
|
public IReadOnlyList<HighlightInfo> Highlights { get; init; } = [];
|
|
|
|
public PageInfo? Page { get; init; }
|
|
|
|
public ProfileInfo? Viewer { get; init; }
|
|
|
|
/// <summary>
|
|
/// Identifier of the connected account, also when the answer describes it with nothing else (Instagram's
|
|
/// <c>xdt_viewer.user</c>): a profile with this identifier in another answer is the connected account (H10).
|
|
/// </summary>
|
|
public string? ViewerId { get; init; }
|
|
|
|
/// <summary>For unrecognized responses: the key structure, without any value (spec §6.4).</summary>
|
|
public string? KeyStructure { get; init; }
|
|
|
|
/// <summary>
|
|
/// The answer of the site's search box (issue #37), when this response is one. Its profiles are not in
|
|
/// <see cref="Profiles"/>, so a search answer never looks like a page of the followed list or a profile check.
|
|
/// </summary>
|
|
public SearchAnswer? Search { get; init; }
|
|
}
|
|
|
|
/// <summary>The profiles a search box answer gave, in their order (issue #37). Never printed with names.</summary>
|
|
public sealed record SearchAnswer(IReadOnlyList<SearchProfile> Hits)
|
|
{
|
|
private bool PrintMembers(StringBuilder builder)
|
|
{
|
|
builder.Append($"Hits = {Hits.Count}");
|
|
return true;
|
|
}
|
|
}
|
|
|
|
/// <summary>One profile of a search answer. Private and followed are never in the answer: they stay null.</summary>
|
|
public sealed record SearchProfile(int Position, ProfileInfo Profile, bool? IsVerified)
|
|
{
|
|
private bool PrintMembers(StringBuilder builder)
|
|
{
|
|
builder.Append($"Position = {Position}, HasPicture = {Profile.Picture is not null}, IsVerified = {IsVerified}");
|
|
return true;
|
|
}
|
|
}
|