Skip to content

Commit fb2ddfc

Browse files
committed
📝 Add shot-scraper video
1 parent dcf0028 commit fb2ddfc

2 files changed

Lines changed: 84 additions & 23 deletions

File tree

docs/document/shot-scraper.rst

Lines changed: 50 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
shot-scraper
22
============
33

4-
`shot-scraper <https://simonwillison.net/2022/Mar/10/shot-scraper/>`_ is a tool
5-
to automate the process of updating screenshots.
4+
`shot-scraper <https://shot-scraper.datasette.io/en/stable/>`_ is a tool to
5+
automate the process of updating screenshots.
66

77
Installation
88
------------
@@ -15,50 +15,77 @@ Installation
1515
.. note::
1616
The second line installs the required browser.
1717

18+
.. seealso::
19+
`shot-scraper Installation
20+
<https://shot-scraper.datasette.io/en/stable/installation.html>`_
21+
1822
Use
1923
---
2024

21-
shot-scraper can be used in two ways
25+
shot-scraper can be used in several ways
2226

2327
#. …for single screenshots on the command line:
2428

2529
.. code-block:: console
2630
27-
$ shot-scraper https://jupyter-tutorial.readthedocs.io/de/latest/clean-prep/index.html -o ~/Downloads/clean-prep.png
31+
$ uv run shot-scraper https://jupyter-tutorial.readthedocs.io/de/latest/clean-prep/index.html -o ~/Downloads/clean-prep.png
2832
29-
…or with additional options, e.g. for JavaScript and CSS selectors:
33+
…or with additional options, for example for JavaScript and CSS selectors:
3034

31-
.. code-block::
35+
.. code-block:: console
3236
33-
$ shot-scraper https://jupyter-tutorial.readthedocs.io/de/latest/clean-prep/index.html -s '#overview' -o ~/Downloads/clean-prep.png
37+
$ uv run shot-scraper https://jupyter-tutorial.readthedocs.io/de/latest/clean-prep/index.html -s '#overview' -o ~/Downloads/clean-prep.png
3438
3539
#. …for a set of screenshots configured in a YAML file:
3640

3741
.. code-block:: yaml
3842
39-
- url: https://jupyter-tutorial.readthedocs.io/de/latest/clean-prep/index.html
40-
output: ~/Downloads/clean-prep.png
41-
- url: https://www.example.org/
42-
width: 736
43-
quality: 40
44-
output: example.jpg
43+
- url: https://jupyter-tutorial.readthedocs.io/de/latest/clean-prep/index.html
44+
output: ~/Downloads/clean-prep.png
45+
- url: https://www.example.org/
46+
width: 736
47+
quality: 40
48+
output: example.jpg
4549
4650
Afterwards ``shot-scraper multi`` can be used, for example:
4751

4852
.. code-block:: console
4953
50-
$ shot-scraper multi shots.yaml
51-
Screenshot of 'https://jupyter-tutorial.readthedocs.io/de/latest/clean-prep/index.html' written to '~(Downloads/clean-prep.png'
52-
Screenshot of 'https://www.example.org/' written to 'example.jpg'
54+
$ shot-scraper multi shots.yaml
55+
Screenshot of 'https://jupyter-tutorial.readthedocs.io/de/latest/clean-prep/index.html' written to '~(Downloads/clean-prep.png'
56+
Screenshot of 'https://www.example.org/' written to 'example.jpg'
57+
58+
.. seealso::
59+
* `Taking multiple screenshots
60+
<https://shot-scraper.datasette.io/en/stable/multi.html>`_
61+
62+
#. …for videos:
63+
64+
The ``shot-scraper video`` command captures a WebM video based on a
65+
:doc:`Python4DataScience:data-processing/serialisation-formats/yaml/index`
66+
storyboard. Storyboards describe the video as a sequence of scenes. Each
67+
scene can open a page, wait for content, perform actions and pause between
68+
steps, for example:
69+
70+
.. literalinclude:: storyboard.yml
71+
:caption: storyboard.yml
72+
:language: yaml
73+
74+
Then run the following command:
75+
76+
.. code-block:: console
77+
78+
$ uv run shot-scraper video storyboard.yml
79+
80+
This opens ``url``, records the scenes and saves the video as
81+
:file:`demo.webm`.
82+
83+
As long as `FFmpeg <https://www.ffmpeg.org/>`_ is installed, you can use the
84+
``--mp4`` option to convert the recorded WebM video to MP4 as well.
5385

5486
.. seealso::
55-
* In the `README.md
56-
<https://github.com/simonw/shot-scraper/blob/main/README.md>`_ file you
57-
will find a complete overview of the possible options.
58-
* In the shot-scraper-demo repository you will find a much more
59-
comprehensive `shots.yaml
60-
<https://github.com/simonw/shot-scraper-demo/blob/main/.github/workflows/shots.yml>`_
61-
file.
87+
* `Recording videos
88+
<https://shot-scraper.datasette.io/en/stable/video.html>`_
6289

6390
GitHub Actions
6491
--------------

docs/document/storyboard.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
output: demo.webm
2+
url: https://python-basics-tutorial.readthedocs.io/en/latest/
3+
4+
viewport:
5+
width: 1280
6+
height: 720
7+
8+
cursor: true
9+
wait_for: "text=Python für Data Science"
10+
11+
scenes:
12+
- name: Home
13+
do:
14+
- pause: 1
15+
16+
- name: Introduction
17+
do:
18+
- click: ".sidebar-tree a[href='intro.html']"
19+
- wait_for: 'h1:has-text("Introduction")'
20+
- screenshot: intro.png
21+
- pause: 1
22+
23+
- name: Search
24+
do:
25+
- click: "input.sidebar-search"
26+
- type:
27+
into: "input.sidebar-search"
28+
text: "shot-scraper"
29+
delay_ms: 25
30+
- press:
31+
selector: "input.sidebar-search"
32+
key: Enter
33+
- wait_for: "text=Search Results"
34+
- pause: 2

0 commit comments

Comments
 (0)