Skip to content

shot-scraper video command, with storyboard.yml files - #194

Merged
simonw merged 24 commits into
mainfrom
codex/storyboard-video-docs-first
Jun 30, 2026
Merged

simonw merged 24 commits into
mainfrom
codex/storyboard-video-docs-first

Conversation

@simonw

@simonw simonw commented Jun 16, 2026 •

Copy link
Copy Markdown
Owner

@simonw

simonw commented Jun 16, 2026

Copy link
Copy Markdown
Owner Author

It's mostly working, but there's one very annoying bug:

output: datasette-example.webm
url: https://latest.datasette.io/
cursor: true

viewport:
  width: 1024
  height: 768

scenes:
- name: Datasette homepage
  wait_for: h1
  hold: 1

- name: Open the fixtures database
  do:
  - click: "h2 a[href='/fixtures']"
  - wait_for: "text=Custom SQL query"
  hold: 1

- name: Enter a SQL query
  do:
  - click: ".cm-content[contenteditable='true']"
  - press:
      selector: ".cm-content[contenteditable='true']"
      key: ControlOrMeta+A
  - type:
      into: ".cm-content[contenteditable='true']"
      text: |
        select _neighborhood, state
        from facetable
        where state = "MI"
        order by _neighborhood
      delay: 35
  hold: 1

- name: Run the query
  do:
  - click: "input[type='submit'][value='Run SQL']"
  - wait_for: "text=Custom SQL query returning 4 rows"
  hold: 2

That storyboard file is run like this:

uv run shot-scraper video datasette-example.yml

And produces this video - which starts with a white frame!

datasette-example.webm

@simonw

simonw commented Jun 16, 2026

Copy link
Copy Markdown
Owner Author

The problem is Playwright starts recording at the start of the session and captures a moment of about:blank before our code navigates to the starting URL.

@simonw

simonw commented Jun 16, 2026

Copy link
Copy Markdown
Owner Author

We were on Playwright 1.58 but it turns out Playwright 1.59 adds a new "screencast" API which may be a better fit for this: https://playwright.dev/python/docs/api/class-page#page-screencast

@simonw

simonw commented Jun 16, 2026

Copy link
Copy Markdown
Owner Author

It looks like the screencast() API is currently limited to fixed size videos at 800px

But Playwright has fixed that already, and it's fixed in Playwright Python main but not yet in a release:

This limits video to 800px width though, see:
#194 (comment)
@simonw

simonw commented Jun 16, 2026

Copy link
Copy Markdown
Owner Author

I'm going to pause working on this until that Playwright Python release comes out.

@simonw
simonw force-pushed the codex/storyboard-video-docs-first branch from b852c93 to 0d17627 Compare June 23, 2026 01:12
@simonw

simonw commented Jun 30, 2026

Copy link
Copy Markdown
Owner Author

https://github.com/microsoft/playwright-python/releases/tag/v1.61.0 is out! That should unblock this work.

@simonw
simonw marked this pull request as ready for review June 30, 2026 05:51
@simonw

simonw commented Jun 30, 2026

Copy link
Copy Markdown
Owner Author

I'm going to make the --help a bit more interesting than this:

shot-scraper/docs/video.md

Lines 518 to 551 in 41e1593

Usage: shot-scraper video [OPTIONS] STORYBOARD_FILE
Record a WebM video from a YAML storyboard.
Usage:
shot-scraper video storyboard.yml
The storyboard file should define output, url and scenes. Use -o to override
the output filename from the YAML file.
For full YAML syntax documentation, see:
https://shot-scraper.datasette.io/en/stable/video.html
Options:
-o, --output FILE Output video filename (.webm), overriding
output: in the storyboard
-a, --auth FILENAME Path to JSON authentication context file
--timeout INTEGER Wait this many milliseconds before failing
-b, --browser [chromium|firefox|webkit|chrome|chrome-beta]
Which browser to use
--browser-arg TEXT Additional arguments to pass to the browser
--user-agent TEXT User-Agent header to use
--reduced-motion Emulate 'prefers-reduced-motion' media feature
--log-console Write console.log() to stderr
--fail Fail with an error code if a page returns an
HTTP error
--skip Skip pages that return HTTP errors
--bypass-csp Bypass Content-Security-Policy
--silent Do not output any messages
--auth-password TEXT Password for HTTP Basic authentication
--auth-username TEXT Username for HTTP Basic authentication
--leave-server Leave servers running when script finishes
--help Show this message and exit.

@simonw

simonw commented Jun 30, 2026

Copy link
Copy Markdown
Owner Author

New example for the docs:

output: demo.webm
url: https://shot-scraper.datasette.io/en/stable/
viewport:
  width: 1280
  height: 720
cursor: true
wait_for: "text=Quick start"
scenes:
- name: Documentation home
  hold: 1
- name: Open installation docs
  do:
  - click: ".sidebar-tree a[href='installation.html']"
  - wait_for: 'h1:has-text("Installation")'
  - screenshot: installation.png
  hold: 1
- name: Search the docs
  do:
  - click: "input.sidebar-search"
  - type:
      into: "input.sidebar-search"
      text: "authentication"
      delay: 25
  - press:
      selector: "input.sidebar-search"
      key: Enter
  - wait_for: "text=Search Results"
  hold: 2

Running this:

uv run shot-scraper video example.yml --mp4

Outputs:

Recording video to 'demo.webm'
Scene 1: Documentation home
Scene 2: Open installation docs
Scene 3: Search the docs
Video written to 'demo.webm'
MP4 written to 'demo.mp4'

And here's that demo.mp4:

demo.mp4

@simonw

simonw commented Jun 30, 2026

Copy link
Copy Markdown
Owner Author
output: demo.webm
url: https://shot-scraper.datasette.io/en/stable/
cursor: true

scenes:
- name: Click installation link
  do:
  - click: ".sidebar-tree a[href='installation.html']"
  - wait_for: 'h1:has-text("Installation")'
  hold: 1

I don't like how hold is a dictionary key there and not a list item. I'm going to drop it entirely in favor of this:

scenes:
- name: Click installation link
  do:
  - click: ".sidebar-tree a[href='installation.html']"
  - wait_for: 'h1:has-text("Installation")'
  - pause: 1

Ditched 'hold: 1' in favour of '- pause: 1'
Renamed delay to delay_ms since it's the only ms one
Removed duplicate width: and viewport.width:
LOTS of improvements to docs/video.md
@simonw

simonw commented Jun 30, 2026

Copy link
Copy Markdown
Owner Author

Testing this by having Codex use it to record a video of a new Datasette feature - in current checkout of the bulk-insert branch:

Review the changes on this branch.
cd to ~/dev/shot-scraper and run the command "uv run shot-scraper video --help"
Now use that new video command to record a video demo of the new features from this branch, including running a uv run datasette -p 6419 --root --secret 1 /tmp/demo.db development server so you can record the video against a demo DB that you first create.

It wrote this:

output: /tmp/datasette-bulk-insert-demo.webm
server:
  - uv
  - --directory
  - /Users/simon/Dropbox/dev/datasette
  - run
  - datasette
  - -p
  - 6419
  - --root
  - --secret
  - "1"
  - /tmp/demo.db
url: http://127.0.0.1:6419/demo/tasks
viewport:
  width: 1280
  height: 720
cursor: true
wait_for: 'button[data-table-action="insert-row"]'
javascript: |
  (() => {
    let clipboardText = "";
    Object.defineProperty(navigator, "clipboard", {
      configurable: true,
      get: () => ({
        writeText: async (text) => {
          clipboardText = String(text);
        },
        readText: async () => clipboardText,
      }),
    });
  })();
scenes:
  - name: Bulk insert existing table rows
    do:
      - pause: 0.8
      - click: 'button[data-table-action="insert-row"]'
      - wait_for: "#row-edit-dialog[open]"
      - pause: 0.5
      - click: ".row-edit-bulk-insert"
      - wait_for: ".row-edit-bulk-textarea"
      - pause: 0.5
      - click: ".row-edit-copy-template"
      - wait_for: "text=Copied"
      - pause: 0.8
      - fill:
          into: ".row-edit-bulk-textarea"
          text: |
            title,owner,status,priority,notes
            Prepare release video,Ana,doing,1,Recorded with shot-scraper
            Check pasted CSV import,Ben,review,3,Previewed before inserting
            Share the branch demo,Chen,queued,2,Bulk insert creates three rows
      - pause: 0.8
      - click: ".row-edit-save"
      - wait_for: "text=Previewing 3 rows."
      - pause: 1.2
      - click: ".row-edit-save"
      - wait_for: "text=3 rows inserted."
      - pause: 1.0
      - click: ".row-edit-cancel"
      - wait_for: "text=Prepare release video"
      - pause: 1.0
  - name: Create a table from pasted CSV
    open: http://127.0.0.1:6419/demo
    wait_for: 'details.actions-menu-links summary'
    do:
      - pause: 0.8
      - click: 'details.actions-menu-links summary'
      - click: 'button[data-database-action="create-table"]'
      - wait_for: "#table-create-dialog[open]"
      - pause: 0.5
      - fill:
          into: ".table-create-table-name"
          text: "launch_metrics"
      - click: ".table-create-from-data"
      - wait_for: ".table-create-data-textarea"
      - pause: 0.5
      - fill:
          into: ".table-create-data-textarea"
          text: |
            metric_id,name,score,recorded_on
            m001,Activation rate,87.5,2026-06-29
            m002,Retention check,72.25,2026-06-30
            m003,CSV import health,95,2026-07-01
      - pause: 0.8
      - click: ".table-create-save"
      - wait_for: "text=Previewing 3 rows."
      - pause: 1.2
      - click: ".table-create-save"
      - wait_for_url: "**/demo/launch_metrics"
      - wait_for: "text=Activation rate"
      - pause: 1.2

Resulting in:

datasette-bulk-insert-demo.mp4

@simonw

simonw commented Jun 30, 2026

Copy link
Copy Markdown
Owner Author

This example which GPT-5.5 suggested illustrates a feature gap:

output: demo.webm
server: mkdir -p /tmp/demo-root && python -m http.server 8000 --directory /tmp/demo-root

scenes:
- name: Home page
  sh: echo "<h1>Local demo</h1>" > /tmp/demo-root/index.html
  open: http://localhost:8000/
  wait_for: h1
  do:
  - pause: 1

The reason the server: block has to use a && is that there isn't currently a way to run other setup scripts before the server block fires - and in this case we are trying to create a local filesystem thing in a temporary directory.

@simonw

simonw commented Jun 30, 2026

Copy link
Copy Markdown
Owner Author

To fix that I'm going to add python: and sh: to the top level syntax.

@simonw simonw linked an issue Jun 30, 2026 that may be closed by this pull request
@simonw
simonw merged commit 80de3a4 into main Jun 30, 2026
11 checks passed
@simonw
simonw deleted the codex/storyboard-video-docs-first branch June 30, 2026 15:03
@simonw simonw added the enhancement New feature or request label Jun 30, 2026
simonw added a commit that referenced this pull request Jun 30, 2026
@simonw

simonw commented Jun 30, 2026

Copy link
Copy Markdown
Owner Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

shot-scraper video command

1 participant