jacky-motion2-0
VerifiedJacky Motion 2.2 Hybrid:把中文口播稿变成可录屏的信息动画单文件 HTML。可选纯 HTML 手动推进(16:9 或 3:4)或配合 SRT 自动播放(16:9,含 B-roll 录屏画框)。流程为审稿、分镜、锁风格、装配与视觉验收;七种重点风格共享同一套版式、动效与质量门禁。
scripts/parse-srt.mjs
View on GitHub#!/usr/bin/env node
import fs from "node:fs";
import path from "node:path";
process.on("uncaughtException", (error) => {
console.error(`FAIL ${error.message}`);
process.exit(1);
});
const file = process.argv[2];
if (!file) {
console.error("Usage: node parse-srt.mjs path/to/voiceover.srt");
process.exit(2);
}
function parseTime(raw) {
const match = raw.trim().match(/^(\d{1,2}):(\d{2}):(\d{2})[,.](\d{3})$/);
if (!match) throw new Error(`Invalid SRT time: ${raw}`);
const [, hh, mm, ss, ms] = match;
if (Number(mm) > 59 || Number(ss) > 59) throw new Error(`Invalid SRT time: ${raw}`);
return (((Number(hh) * 60 + Number(mm)) * 60 + Number(ss)) * 1000) + Number(ms);
}
const source = fs.readFileSync(file, "utf8").replace(/^\uFEFF/, "");
const blocks = source.replace(/\r\n?/g, "\n").trim().split(/\n{2,}/).filter(Boolean);
const cues = [];
for (const block of blocks) {
const lines = block.split("\n").map((line) => line.trim());
const timeLineIndex = lines.findIndex((line) => line.includes("-->"));
if (timeLineIndex < 0) throw new Error(`Missing time range in block: ${block.slice(0, 80)}`);
const range = lines[timeLineIndex].match(/^(.+?)\s*-->\s*(\S+)/);
if (!range) throw new Error(`Invalid time range: ${lines[timeLineIndex]}`);
const startMs = parseTime(range[1]);
const endMs = parseTime(range[2]);
if (endMs <= startMs) throw new Error(`Cue end must be after start: ${lines[timeLineIndex]}`);
const text = lines.slice(timeLineIndex + 1)
.join(" ")
.replace(/<[^>]*>/g, "")
.replace(/\{\\[^}]+\}/g, "")
.replace(/\s+/g, " ")
.trim();
if (!text) throw new Error(`Cue at ${range[1]} has no text.`);
const declaredIndex = Number(lines[0]);
cues.push({
index: Number.isInteger(declaredIndex) && timeLineIndex > 0 ? declaredIndex : cues.length + 1,
startMs,
endMs,
text
});
}
if (!cues.length) throw new Error("SRT contains no cues.");
cues.sort((a, b) => a.startMs - b.startMs || a.endMs - b.endMs);
for (let i = 1; i < cues.length; i += 1) {
if (cues[i].startMs < cues[i - 1].endMs) {
throw new Error(`Overlapping cues: ${cues[i - 1].index} and ${cues[i].index}.`);
}
}
console.log(JSON.stringify({
source: path.basename(file),
durationMs: cues.at(-1).endMs,
cues
}, null, 2));
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |