@senseihq/emaki-cli 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +1 -1
- package/package.json +4 -4
- package/plugin/.claude-plugin/plugin.json +2 -2
- package/src/commands/posting.js +1 -1
- package/src/media.js +2 -2
- package/src/publish.js +1 -1
- package/src/render.js +11 -5
- package/src/tts-io.js +1 -1
- package/src/upload/youtube.js +3 -1
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -67,4 +67,4 @@ Needs Node 20.10+, ffmpeg, and Playwright with Chromium for `sheet`, `render` an
|
|
|
67
67
|
functions from `@senseihq/emaki-cli` (`project`, `validate`, `voice`, `voiceWeb`, `fit`, `render`, `build`, `stage`, `publish`,
|
|
68
68
|
`youtube`, `instagram`, `carousel`, `campaignStatus`, …); every network call takes an injectable `fetch`.
|
|
69
69
|
|
|
70
|
-
MIT ©
|
|
70
|
+
MIT © sensei-hq
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@senseihq/emaki-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "The motion stories command line: set a project up, install the Claude plugin (skills, agents, playbook), run the production steps (validate, sheet, voice, fit, render, build) per film and locale, then stage, publish and run a campaign.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
|
-
"author": "
|
|
7
|
+
"author": "sensei-hq",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
10
|
"url": "git+https://github.com/sensei-hq/emaki.git",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"postpublish": "rm -f LICENSE"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@senseihq/emaki": "0.
|
|
32
|
-
"@senseihq/emaki-posting": "0.
|
|
31
|
+
"@senseihq/emaki": "0.2.0",
|
|
32
|
+
"@senseihq/emaki-posting": "0.2.0",
|
|
33
33
|
"sade": "^1.8.1"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "emaki",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Build a multilingual site of motion stories (articles, story player and narrated videos from one set of JSON scenes) through a guided, gated program: interview, outline, item cards, pilot, automated batches, review loop.",
|
|
5
5
|
"author": {
|
|
6
|
-
"name": "
|
|
6
|
+
"name": "sensei-hq"
|
|
7
7
|
},
|
|
8
8
|
"keywords": [
|
|
9
9
|
"learning",
|
package/src/commands/posting.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { MotionError } from '../util.js'
|
|
5
5
|
import { act, P } from './run.js'
|
|
6
6
|
|
|
7
|
-
const list = (v) => [v
|
|
7
|
+
const list = (v) => [v].flat().flatMap((x) => String(x).split(',')).map((x) => x.trim()).filter(Boolean)
|
|
8
8
|
|
|
9
9
|
/** Staging on the desk, publishing, and the carousel. */
|
|
10
10
|
export function postingCommands(prog) {
|
package/src/media.js
CHANGED
|
@@ -63,14 +63,14 @@ export function muxArgs(video, audio, t0, dur, dst) {
|
|
|
63
63
|
/** Runs `fn`; when it fails (the dev server reloaded the page under it), awaits `recover` (the show coming back)
|
|
64
64
|
* and runs it again, up to `attempts` times in all, then lets the last error through. */
|
|
65
65
|
export async function retrying(fn, recover, attempts = 8) {
|
|
66
|
-
for (let i = 1; ; i++) {
|
|
66
|
+
for (let i = 1; i < attempts; i++) {
|
|
67
67
|
try {
|
|
68
68
|
return await fn()
|
|
69
69
|
} catch (e) {
|
|
70
|
-
if (i >= attempts) throw e
|
|
71
70
|
await recover(e)
|
|
72
71
|
}
|
|
73
72
|
}
|
|
73
|
+
return fn()
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
/** A warning when an existing render no longer runs as long as the film (after a retiming): its frames are stale. */
|
package/src/publish.js
CHANGED
|
@@ -102,7 +102,7 @@ async function reelUrls(p, slug, f, { videoUrl, coverUrl, env, fetch, now }) {
|
|
|
102
102
|
const desk = deskClient(p, { env, fetch }), urls = []
|
|
103
103
|
for (const [key, file, type] of [[`${slug}/${basename(f.tall)}`, f.tall, 'video/mp4'], [`${slug}/instagram-${basename(f.coverTall)}`, f.coverTall, 'image/jpeg']]) {
|
|
104
104
|
await desk.putMedia(key.toLowerCase(), readFileSync(file), type)
|
|
105
|
-
urls.push(await signMedia(key.toLowerCase(), env.MEDIA_URL_SECRET, desk.origin,
|
|
105
|
+
urls.push(await signMedia(key.toLowerCase(), env.MEDIA_URL_SECRET, { origin: desk.origin, now: now(), path: env.MEDIA_PATH || '/m' }))
|
|
106
106
|
}
|
|
107
107
|
return urls
|
|
108
108
|
}
|
package/src/render.js
CHANGED
|
@@ -20,13 +20,15 @@ async function scoreFor(job, call) {
|
|
|
20
20
|
return audio
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
/** Seeks the page to each frame of the range and writes its JPEG to ffmpeg's stdin, waiting when the pipe is full.
|
|
23
|
+
/** Seeks the page to each frame of the range and writes its JPEG to ffmpeg's stdin, waiting when the pipe is full.
|
|
24
|
+
* Stops when ffmpeg has quit (its stdin closed); its exit code says why. */
|
|
24
25
|
async function pipeFrames(job, page, call, ff, { layout, t0, end, frames }) {
|
|
25
26
|
const { fps, log } = job
|
|
26
|
-
for (let i = 0; i < frames; i++) {
|
|
27
|
+
for (let i = 0; i < frames && !ff.stdin.destroyed; i++) {
|
|
27
28
|
await call((t) => window.__show.seek(t), t0 + i / fps)
|
|
28
29
|
const jpg = await page.screenshot({ type: 'jpeg', quality: 94 })
|
|
29
|
-
if (!ff.stdin.write(jpg)
|
|
30
|
+
if (!ff.stdin.write(jpg) && !ff.stdin.destroyed)
|
|
31
|
+
await new Promise((r) => { ff.stdin.once('drain', r); ff.stdin.once('close', r) })
|
|
30
32
|
if (i % (fps * 10) === 0) log(` ${layout} ${(t0 + i / fps).toFixed(1).padStart(6)}s / ${end.toFixed(1)}s`)
|
|
31
33
|
}
|
|
32
34
|
}
|
|
@@ -39,11 +41,15 @@ async function captureFrames(job, { page, meta, errors }, call, layout, dst) {
|
|
|
39
41
|
const tmp = dst.replace(/\.mp4$/i, '.part.mp4')
|
|
40
42
|
mkdirSync(dirname(dst), { recursive: true })
|
|
41
43
|
const ff = spawn('ffmpeg', encodeArgs({ fps, seconds, dst: tmp, audio, t0 }), { stdio: ['pipe', 'inherit', 'inherit'] })
|
|
42
|
-
|
|
44
|
+
// Settles with the failure (or null) rather than rejecting, so an ffmpeg that quits mid-capture is reported once the
|
|
45
|
+
// frames stop, not as an unhandled rejection; a write to its closed stdin (EPIPE) is the same failure.
|
|
46
|
+
const done = new Promise((ok) => { ff.on('close', (c) => ok(c ? new Error('ffmpeg failed') : null)); ff.on('error', ok) })
|
|
47
|
+
ff.stdin.on('error', () => {})
|
|
43
48
|
const began = Date.now()
|
|
44
49
|
await pipeFrames(job, page, call, ff, { layout, ...range })
|
|
45
50
|
ff.stdin.end()
|
|
46
|
-
await done
|
|
51
|
+
const failed = await done
|
|
52
|
+
if (failed) die(failed.message)
|
|
47
53
|
if (errors.length) die('the page reported errors: ' + errors.slice(0, 3).join('; '))
|
|
48
54
|
renameSync(tmp, dst)
|
|
49
55
|
log(` wrote ${p.rel(dst)} (${frames} frames, ${Math.round((Date.now() - began) / 1000)}s)`)
|
package/src/tts-io.js
CHANGED
|
@@ -12,7 +12,7 @@ export const lang = (locale) => locale.split('-')[0]
|
|
|
12
12
|
export function sh(cmd, args, input) {
|
|
13
13
|
const r = spawnSync(cmd, args, { input, encoding: input == null ? 'utf-8' : undefined, maxBuffer: 256 * 1024 * 1024 })
|
|
14
14
|
if (r.error) fail(`${cmd}: ${r.error.code === 'ENOENT' ? 'not installed' : r.error.message}`)
|
|
15
|
-
if (r.status) fail(`${cmd}: ${String(r.stderr
|
|
15
|
+
if (r.status) fail(`${cmd}: ${String(r.stderr).slice(-400)}`)
|
|
16
16
|
return r.stdout
|
|
17
17
|
}
|
|
18
18
|
|
package/src/upload/youtube.js
CHANGED
|
@@ -13,9 +13,11 @@ function multipart(parts) {
|
|
|
13
13
|
return { body: Buffer.concat([...chunks, Buffer.from(`--${boundary}--\r\n`)]), type: `multipart/related; boundary=${boundary}` }
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
// The language's English name. of() answers an unknown but well-formed code with the code itself (its default
|
|
17
|
+
// fallback); a malformed one throws.
|
|
16
18
|
const languageName = (code) => {
|
|
17
19
|
try {
|
|
18
|
-
return new Intl.DisplayNames(['en'], { type: 'language' }).of(code)
|
|
20
|
+
return new Intl.DisplayNames(['en'], { type: 'language' }).of(code)
|
|
19
21
|
} catch {
|
|
20
22
|
return code
|
|
21
23
|
}
|