Feat : Preview on streamers
All checks were successful
release / build (push) Successful in 27s
release / verify-windows (push) Successful in 1m27s

This commit is contained in:
jeanotx32
2026-08-12 16:23:43 +02:00
parent eae694d49a
commit 58aadee97d
7 changed files with 159 additions and 4 deletions

View File

@@ -161,6 +161,9 @@ addColumnIfMissing('watch_targets', 'priority', 'INTEGER NOT NULL DEFAULT 1');
// Droit de couper une capture de rang inférieur. Refusé par défaut : un
// enregistrement en cours ne s'interrompt pas sans un geste explicite.
addColumnIfMissing('watch_targets', 'preempt', 'INTEGER NOT NULL DEFAULT 0');
// Vignette du flux, rafraîchie à chaque sonde — voir StripchatStatus.previewUrl.
addColumnIfMissing('watch_targets', 'preview_url', 'TEXT');
addColumnIfMissing('watch_targets', 'snapshot_at', 'INTEGER');
/**
* `idle` — le « revient bientôt » de Stripchat — relevait de la clôture et non de
@@ -481,6 +484,8 @@ interface TargetRow {
status_changed_at: number | null;
last_live_started_at: number | null;
last_live_ended_at: number | null;
preview_url: string | null;
snapshot_at: number | null;
}
const num = (value: number | null): number | null => (value === null ? null : Number(value));
@@ -508,6 +513,8 @@ function toTarget(row: TargetRow): WatchTarget {
statusChangedAt: num(row.status_changed_at),
lastLiveStartedAt: num(row.last_live_started_at),
lastLiveEndedAt: num(row.last_live_ended_at),
previewUrl: row.preview_url,
snapshotAt: num(row.snapshot_at),
};
}
@@ -529,7 +536,8 @@ const targetStmts = {
UPDATE watch_targets
SET state = ?, raw_status = ?, state_since = ?, last_checked_at = ?, last_error = ?,
avatar_url = ?, status_changed_at = ?,
last_live_started_at = ?, last_live_ended_at = ?
last_live_started_at = ?, last_live_ended_at = ?,
preview_url = ?, snapshot_at = ?
WHERE id = ?
`),
remove: db.prepare('DELETE FROM watch_targets WHERE id = ?'),
@@ -609,6 +617,8 @@ export const targetsRepo = {
statusChangedAt: number | null;
lastLiveStartedAt: number | null;
lastLiveEndedAt: number | null;
previewUrl: string | null;
snapshotAt: number | null;
},
): void {
targetStmts.updateState.run(
@@ -621,6 +631,8 @@ export const targetsRepo = {
state.statusChangedAt,
state.lastLiveStartedAt,
state.lastLiveEndedAt,
state.previewUrl,
state.snapshotAt,
id,
);
},

View File

@@ -80,6 +80,8 @@ class Watchlist {
let error: string | null = null;
let avatarUrl = target.avatarUrl;
let statusChangedAt = target.statusChangedAt;
let previewUrl = target.previewUrl;
let snapshotAt = target.snapshotAt;
try {
const result = await fetchStripchatStatus(
@@ -91,6 +93,8 @@ class Watchlist {
// On conserve la dernière valeur connue si la plateforme ne la renvoie pas.
avatarUrl = result.avatarUrl ?? target.avatarUrl;
statusChangedAt = result.statusChangedAt ?? target.statusChangedAt;
previewUrl = result.previewUrl ?? target.previewUrl;
snapshotAt = result.snapshotAt ?? target.snapshotAt;
} catch (err) {
// Une sonde en échec ne change pas l'état connu : on garde le dernier
// verdict fiable plutôt que d'annoncer un faux passage hors-ligne.
@@ -128,6 +132,8 @@ class Watchlist {
statusChangedAt,
lastLiveStartedAt,
lastLiveEndedAt,
previewUrl,
snapshotAt,
});
const updated = targetsRepo.get(target.id);