Some checks failed
build-images / web (push) Has been cancelled
vision2026-ci / Python SDK resource tests (push) Has been cancelled
build-images / api (push) Has been cancelled
build-images / worker-gpu (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (comfy-workflow-schema) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (effects-core) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (eventbus-types) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (growth-analytics) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (provider-adapter-kit) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (publishing-connectors) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (render-core) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (shot-template-schema) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (trends-schema) (push) Has been cancelled
vision2026-ci / Desktop engine crates (test + clippy + fmt) (push) Has been cancelled
codeql / Analyze (javascript-typescript) (push) Has been cancelled
codeql / Analyze (python) (push) Has been cancelled
perf / API hot-path micro-smoke (budgeted) (push) Has been cancelled
perf / Desktop engine crates (release build check) (push) Has been cancelled
vision2026-ci / API phase modules (ruff + pytest) (push) Has been cancelled
vision2026-ci / Alembic upgrade + drift check (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (caption-engine) (push) Has been cancelled
Paid, hosted product at menivor.com, now retired as a company project. Fresh squashed history of the cleaned working tree (secret-scanned, no .env, no customer data, no outreach logs). Built on MoneyPrinterTurbo (MIT, harry0703) — see NOTICE.
179 lines
6.1 KiB
TypeScript
179 lines
6.1 KiB
TypeScript
/**
|
|
* Reel Gallery feed: real reels Menivor's own team rendered through the real
|
|
* pipeline (no customer data — see the module doc comment on
|
|
* `apps/api/tools/ops/gallery/publish.py` for provenance). Published as JSON
|
|
* at media.menivor.com/gallery/manifest.json, same pattern as the
|
|
* Megaphone "Made with Menivor" feed (`lib/seo/megaphone/feed.ts`): this
|
|
* module fetches it, keeps only well-formed entries, and builds VideoObject
|
|
* JSON-LD + sitemap entries. Every failure degrades to an empty list, never a
|
|
* broken page.
|
|
*
|
|
* Each item is a demo reel made from a real, public App Store or Google Play
|
|
* listing (screenshots, description, rating already shown to every shopper
|
|
* on that store) — never a private customer job.
|
|
*/
|
|
|
|
export const MANIFEST_URL = "https://media.menivor.com/gallery/manifest.json";
|
|
export const SITE_URL = "https://menivor.com";
|
|
export const GALLERY_PATH = "/reel-gallery";
|
|
const MEDIA_ORIGIN = "https://media.menivor.com/";
|
|
const FETCH_TIMEOUT_MS = 3000;
|
|
const ID_PATTERN = /^[a-z0-9-]{2,60}$/;
|
|
const STORE_HOSTS = new Set(["apps.apple.com", "play.google.com"]);
|
|
|
|
export interface ReelGalleryItem {
|
|
readonly id: string;
|
|
readonly appName: string;
|
|
readonly developer: string;
|
|
readonly appUrl: string;
|
|
readonly hookLine: string;
|
|
readonly hookAngle: string;
|
|
readonly script: string;
|
|
readonly rating: number | null;
|
|
readonly ratingCount: number | null;
|
|
readonly genre: string;
|
|
readonly iconUrl: string;
|
|
readonly videoUrl: string;
|
|
readonly posterUrl: string;
|
|
readonly durationS: number;
|
|
readonly width: number;
|
|
readonly height: number;
|
|
readonly uploadDate: string;
|
|
}
|
|
|
|
function text(value: unknown, max: number): string {
|
|
return typeof value === "string" ? value.replace(/\s+/g, " ").trim().slice(0, max) : "";
|
|
}
|
|
|
|
function mediaUrl(value: unknown, ext: RegExp): string {
|
|
const url = text(value, 600);
|
|
if (!url.startsWith(MEDIA_ORIGIN) || !ext.test(url)) return "";
|
|
try {
|
|
return new URL(url).href;
|
|
} catch {
|
|
return "";
|
|
}
|
|
}
|
|
|
|
/** Only a real, public App Store / Google Play listing URL qualifies. */
|
|
function storeUrl(value: unknown): string {
|
|
try {
|
|
const url = new URL(text(value, 800));
|
|
return url.protocol === "https:" && STORE_HOSTS.has(url.hostname) ? url.href : "";
|
|
} catch {
|
|
return "";
|
|
}
|
|
}
|
|
|
|
function nonNegativeNumberOrNull(value: unknown): number | null {
|
|
const n = Number(value);
|
|
return Number.isFinite(n) && n >= 0 ? n : null;
|
|
}
|
|
|
|
/** One validated entry, or null when anything required is missing or unsafe. */
|
|
export function parseReelGalleryItem(raw: unknown): ReelGalleryItem | null {
|
|
if (!raw || typeof raw !== "object") return null;
|
|
const v = raw as Record<string, unknown>;
|
|
const id = text(v.id, 60);
|
|
const videoUrl = mediaUrl(v.video_url, /\.mp4$/);
|
|
const posterUrl = mediaUrl(v.poster_url, /\.(jpg|jpeg|png|webp)$/);
|
|
const appName = text(v.app_name, 140);
|
|
const appUrl = storeUrl(v.app_url);
|
|
const hookLine = text(v.hook_line, 300);
|
|
const uploadDate = text(v.upload_date, 40);
|
|
const durationS = Number(v.duration_s);
|
|
if (!ID_PATTERN.test(id) || !videoUrl || !posterUrl || !appName || !appUrl || !hookLine) return null;
|
|
if (!Number.isFinite(durationS) || durationS <= 0 || durationS > 600 || Number.isNaN(Date.parse(uploadDate))) {
|
|
return null;
|
|
}
|
|
return {
|
|
id,
|
|
appName,
|
|
developer: text(v.developer, 140),
|
|
appUrl,
|
|
hookLine,
|
|
hookAngle: text(v.hook_angle, 300),
|
|
script: text(v.script, 2000),
|
|
rating: nonNegativeNumberOrNull(v.rating),
|
|
ratingCount: nonNegativeNumberOrNull(v.rating_count),
|
|
genre: text(v.genre, 60),
|
|
iconUrl: mediaUrl(v.icon_url, /\.(jpg|jpeg|png|webp)$/) || text(v.icon_url, 600),
|
|
videoUrl,
|
|
posterUrl,
|
|
durationS,
|
|
width: Number(v.width) > 0 ? Math.round(Number(v.width)) : 1080,
|
|
height: Number(v.height) > 0 ? Math.round(Number(v.height)) : 1920,
|
|
uploadDate,
|
|
};
|
|
}
|
|
|
|
export function parseReelGalleryFeed(raw: unknown): ReelGalleryItem[] {
|
|
const videos = raw && typeof raw === "object" ? (raw as { videos?: unknown }).videos : undefined;
|
|
if (!Array.isArray(videos)) return [];
|
|
const seen = new Set<string>();
|
|
const out: ReelGalleryItem[] = [];
|
|
for (const item of videos.slice(0, 200)) {
|
|
const parsed = parseReelGalleryItem(item);
|
|
if (parsed && !seen.has(parsed.id)) {
|
|
seen.add(parsed.id);
|
|
out.push(parsed);
|
|
}
|
|
}
|
|
return out;
|
|
}
|
|
|
|
/** Fetch the live manifest (no caching layer on this deploy; the file is small). */
|
|
export async function loadReelGalleryFeed(fetchImpl: typeof fetch = fetch): Promise<ReelGalleryItem[]> {
|
|
const controller = new AbortController();
|
|
const timer = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);
|
|
try {
|
|
const res = await fetchImpl(MANIFEST_URL, { signal: controller.signal, cache: "no-store" });
|
|
if (!res.ok) return [];
|
|
return parseReelGalleryFeed(await res.json());
|
|
} catch {
|
|
return [];
|
|
} finally {
|
|
clearTimeout(timer);
|
|
}
|
|
}
|
|
|
|
export async function loadReelGalleryItem(
|
|
id: string,
|
|
fetchImpl: typeof fetch = fetch,
|
|
): Promise<ReelGalleryItem | null> {
|
|
const items = await loadReelGalleryFeed(fetchImpl);
|
|
return items.find((item) => item.id === id) ?? null;
|
|
}
|
|
|
|
/** ISO 8601 duration ("PT31S", "PT1M5S"). */
|
|
export function isoDuration(seconds: number): string {
|
|
const total = Math.max(1, Math.round(seconds));
|
|
const m = Math.floor(total / 60);
|
|
const s = total % 60;
|
|
return m ? `PT${m}M${s}S` : `PT${s}S`;
|
|
}
|
|
|
|
/** The free-preview tool path, prefilled with this reel's own app link. */
|
|
export function recreateHref(item: ReelGalleryItem): string {
|
|
return `/create?q=${encodeURIComponent(item.appUrl)}`;
|
|
}
|
|
|
|
export function reelGalleryItemPath(item: ReelGalleryItem): string {
|
|
return `${GALLERY_PATH}/${item.id}`;
|
|
}
|
|
|
|
export function reelVideoObjectLd(item: ReelGalleryItem, pageUrl: string): Record<string, unknown> {
|
|
return {
|
|
"@type": "VideoObject",
|
|
name: `${item.appName} — ${item.hookLine}`,
|
|
description: item.script || item.hookLine,
|
|
thumbnailUrl: [item.posterUrl],
|
|
uploadDate: item.uploadDate,
|
|
duration: isoDuration(item.durationS),
|
|
contentUrl: item.videoUrl,
|
|
embedUrl: pageUrl,
|
|
width: item.width,
|
|
height: item.height,
|
|
} as const;
|
|
}
|