Skip to content

Commit 1a9e40e

Browse files
committed
Update documentation and readme
1 parent ace1c19 commit 1a9e40e

12 files changed

+150
-125
lines changed

README.md

+45-29
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
# Immersive
22

33
Immersive is an mpv script for improving language immersion, with a special
4-
focus on sentence mining. It can automatically generate Anki cards including a
5-
dictionary definition of the target word, an audio clip of the sentence(s), a
6-
screenshot of the video, and pronunciation audio from
7-
[Forvo](https://forvo.com/). The script is highly configurable and supports
8-
many possible workflows.
4+
focus on sentence mining. It can automatically generate Anki cards with
5+
dictionary definitions of the target word, sentence audio clips, screenshots
6+
from the video, and pronunciation audio taken from [Forvo](https://forvo.com/).
7+
The script is highly configurable and supports many possible workflows.
98

109
This is a short video walking through the full process of creating a card with
1110
Immersive: https://youtu.be/FrTcu4ZO92w. It's possible to skip parts of the
@@ -38,13 +37,19 @@ Immersive supports all major desktop operating systems:
3837
</tr>
3938
<tr>
4039
<td colspan="3">curl</td>
41-
<td>web requests (Forvo, AnkiConnect). Already present by default on most systems.<br>Included in Windows 10 since April 2018</td>
40+
<td>
41+
web requests (Forvo, AnkiConnect). Already present by default on most systems.
42+
Part of Windows 10 since April 2018
43+
</td>
4244
</tr>
4345
<tr>
4446
<td>socat</td>
4547
<td>-</td>
4648
<td>netcat (<code>nc</code>)</td>
47-
<td>background playback (audio preview and Forvo). <code>nc</code> is included in macOS 10.13 and later.</td>
49+
<td>
50+
background playback (sentence and Forvo audio preview).
51+
<code>nc</code> is included with macOS 10.13 and later.
52+
</td>
4853
</tr>
4954
<tr>
5055
<td>xclip</td>
@@ -63,30 +68,39 @@ The basic process for creating cards is as follows:
6368

6469
1. Bring up the subtitle selection menu (`a`)
6570
2. Select the subtitles that should be on the card using `a` or the autoselect
66-
(toggle with `A`). If there are no subtitles or if they are badly timed, set
67-
the start/end time for the audio export manually using `Q` and `E`. If you
68-
wish to take a screenshot at a specific time instead of the current frame, set
69-
it using `s`.
71+
(toggle with `A`). If there are no subtitles or if they are badly timed, set
72+
the start/end time for the audio export manually using `Q` and `E`. If you
73+
wish to take a screenshot at a specific time instead of the current frame,
74+
set it using `s`.
7075
3. Enter target word selection mode using `d`. Select the target word with
71-
(`Ctrl`+)``+``/`` and confirm it using (``+)``. It's possible to search
72-
for an external word from the clipboard using `v` if there are no text
73-
subtitles or if a word can't be found.
74-
4. Optionally add Forvo audio by pressing `a` after adding a target word.
75-
5. Export to Anki using `f`.
76+
(`Ctrl`+)``+``/`` and confirm it using (``+)``. It's possible
77+
to search for an external word from the clipboard using `v` if there are no
78+
text subtitles or if a word can't be found.
79+
4. Choose a definition from the dictionary entries with ``/`` and ``. Switch
80+
between dictionaries with ``/`` if you have more than one configured.
81+
5. Optionally add Forvo audio by pressing `a` after adding a target word.
82+
6. Export to Anki using `f`.
7683

7784
The card creation process is highly customizable. For further information read
7885
[this](/doc/card-export.md).
7986

8087
### Dictionary Lookup in mpv
8188

82-
You can look up words in your configured dictionaries. Bring up the word
89+
You can look up words in your configured dictionaries at any time. Open the word
8390
selection menu by pressing `k` and search for the selection using (``+)``.
8491

92+
### Automatic Deinflection
93+
94+
Immersive supports automatic deinflection (deconjugation) based on the same
95+
tables that the Migaku Dictionary addon for Anki uses in addition to a
96+
simpler Japanese-specific deinflector.
97+
Read [this page](/doc/lookup-transformations.md) for details.
98+
8599
### Subtitle Copying
86100

87101
Immersive can copy subtitles to the clipboard. Use `c` to manually copy the
88102
active line at any time, or toggle automatic copying with `C`. You can
89-
partially copy a line in the menu for selecting text from the active line.
103+
partially copy lines from the active line menu (`k`).
90104

91105

92106
## Installation & Setup
@@ -102,19 +116,21 @@ config files to match it as well.
102116
All necessary files can be downloaded as a ZIP file from the latest
103117
[release](https://github.com/Ben-Kerman/immersive/releases). When installing
104118
Immersive from a release archive, it only needs to be extracted into the mpv
105-
config directory for the full release, or `scripts` directory for the
106-
script-only release. The above directory is already contained in the archive.
119+
config directory for the full release, or `scripts` directory for the script-only
120+
release. The `immersive` directory is already contained in the archive.
107121

108122
If you want the most up-to-date version possible, use the "Code" button at the
109123
top of the repo's start page. Simply extract the contents of the file into
110124
your mpv scripts folder and remove the branch name (most likely `-master`)
111125
from the name of the extracted directory.
112126

127+
---
128+
113129
The script is configured in several different files. These need to be placed
114130
in a directory called `script-opts` that is located next to your `mpv.conf`
115131
and `scripts` folder. For a description of the general config syntax, see [this
116132
document](/doc/config.md). Except for `immersive-dictionaries.conf` all config
117-
files can be reloaded from the global menu (`Ctrl+a`) at runtime.
133+
files can be reloaded from the global menu (`Ctrl`+`a`) at runtime.
118134

119135
In order to use the main feature of generating Anki cards with included
120136
definitions, these config files need to be present:
@@ -123,9 +139,9 @@ definitions, these config files need to be present:
123139

124140
The following config files are optional:
125141
- [`immersive.conf`](/doc/script-config.md): general configuration of the script
126-
- [`immersive-keys.conf`](/doc/keys.md): reassign menu key bindings
127-
- [`immersive-series.conf`](/doc/series.md): use custom series IDs and titles
128-
- [`immersive-style.conf`](/doc/style.md): change the appearance of the interface
142+
- [`immersive-keys.conf`](/doc/keys.md): reassign key bindings
143+
- [`immersive-series.conf`](/doc/series.md): custom series IDs and titles
144+
- [`immersive-style.conf`](/doc/style.md): appearance of the interface
129145

130146
Documentation that is not about specific config files:
131147
- [Config Syntax](/doc/config.md)
@@ -135,7 +151,7 @@ Documentation that is not about specific config files:
135151

136152
### Updating
137153

138-
To update Immersive, delete the script's folder in your mpv config directory
154+
To update Immersive, delete the script's folder in your `scripts` directory
139155
and replace it with the one from the latest release's script-only ZIP file.
140156
Also check if there were any changes to config entries that you have used in
141157
the [change log](/CHANGELOG.md).
@@ -152,8 +168,8 @@ the [change log](/CHANGELOG.md).
152168
`profile`, `deck`, `note_type`, and the `field:` values so that they match
153169
your Anki setup.
154170
5. Open `immersive-dictionaries.conf` and set up your dictionaries as
155-
explained [here](/doc/dictionaries.md). If you are learning Japanese and using
156-
the Yomichan version of JMdict, you will most likely only have to change
171+
explained [here](/doc/dictionaries.md). If you are learning Japanese and are
172+
using the Yomichan version of JMdict, you will most likely only have to change
157173
`location` so it is set to the path of a directory containing the unzipped
158174
contents of `jmdict_english.zip` from the Yomichan website.
159175

@@ -176,7 +192,7 @@ script-opts/
176192
immersive.conf
177193
```
178194

179-
You can now start mpv and open the main menu of Immersive using `Ctrl+a` or
195+
You can now start mpv and open the main menu of Immersive using `Ctrl`+`a` or
180196
begin creating a card with `a`.
181197

182198

@@ -185,7 +201,7 @@ begin creating a card with `a`.
185201
If Immersive crashes at any point (when this happens, the interface suddenly
186202
disappears and all keybindings stop working), open the console using `ˋ`/`~`,
187203
take a screenshot of it and report the issue to me. If you started mpv from
188-
the command line the output there is preferable.
204+
the command line the output there is preferred.
189205

190206

191207
## Suggestions & Reporting Issues

doc/card-export.md

+35-32
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,22 @@ of the screen. Information on timing is at the bottom left, and a help menu
99
listing all available key bindings is at the top left.
1010

1111
Pressing `a` again adds the current subtitle to the selection. By default all
12-
subtitles are automatically added to the selection. This can be toggled with
13-
`A`, or disabled by default in the script config.
12+
subtitles are added automatically. This behavior can be toggled with `A`, or
13+
disabled in the script config.
1414

1515
`q` and `e` can be used to set the timing of the exported audio clip manually
16-
to the start or end of the currently visible subtitle. `Q` and `E` do the same
16+
to the start or end of the currently active subtitle. `Q` and `E` do the same
1717
but using the current playback time instead. `s` sets the screenshot time to
1818
the current frame. Pressing the timing keys again while a time is set resets
1919
the corresponding time if the keypress would have set it to the same value.
2020
For example, if the screenshot time is set to `15:00.000` and the current
2121
timestamp in the video is also `15:00.000`, pressing `s` will unset the
2222
screenshot time.
2323

24-
If no times are set, the clip will begin at the start of the first subtitle
25-
and end at the end of the last subtitle. The screenshot will be the frame
26-
that's visible when the export happens. Screenshots can be toggled with `s` in
27-
the global menu.
24+
If no times are set, the clip will begin at the start of the first selected
25+
subtitle and end at the end of the last one. The screenshot will be the frame
26+
that's visible when the export happens. Screenshots can be toggled with `s`
27+
in the global menu.
2828

2929
`y` resets the selection and times. `p` plays the audio that would be exported
3030
with the current selection/times. `d` ends the subtitle selection and begins
@@ -36,9 +36,9 @@ first.
3636
## Single Subtitle Export
3737

3838
By pressing `K`, line selection is skipped and the target word selection is
39-
started immediately with the current subtitle. `Ctrl+k` skips the entirety of
39+
started immediately with the current subtitle. `Ctrl`+`k` skips the entirety of
4040
the card creation process and instantly exports a card of the active subtitle
41-
including an audio clip and screenshot. `Ctrl+K` opens the export menu first.
41+
including an audio clip and screenshot. `Ctrl`+`K` opens the export menu first.
4242

4343

4444
## Target Word Selection
@@ -52,24 +52,27 @@ Unneeded parts of the text are deletable using the bindings described in
5252
[keys.md](/doc/keys.md#text_select).
5353

5454
The word can be selected with the usual key combinations for selecting text:
55-
(`Ctrl+`)(`⇧+`)``/``. `` and `` switch between subtitles and `DEL` removes
56-
the current one from the selection. Once you have chosen some text, you can
57-
look up any dictionary entries that match it exactly using `` and any entries
58-
starting with it using `⇧+⏎`. Any whitespace characters (according to Unicode
59-
properties, including zero width spaces (U+200B)) before or after the word are
60-
automatically removed before searching.
55+
(`Ctrl`+)(``+)``/``. `` and `` switch between subtitles and `Alt`+`DEL`
56+
removes the current one from the selection.
57+
58+
Once you have chosen some text, you can look up any dictionary entries that
59+
match it exactly using `` and any entries starting with it using ``+``. If
60+
you have lookup transformations configured you can use those with `Ctrl`+``.
61+
Any whitespace characters (according to Unicode properties, including zero
62+
width spaces (U+200B)) before or after the word are automatically removed
63+
before searching.
6164

6265
If the search has any results, a new menu will open that allows you to choose
63-
one of them with ``/`` and ``, or `Ctrl+` to add multiple definitions
66+
one of them with ``/`` and ``, or `Ctrl`+`` to add multiple definitions
6467
without returning to the previous menu. ``/`` can be used to switch between
6568
dictionaries (in the current group, if more than one is configured).
6669

6770
After selecting a definition, the word will be shown at the bottom right of
68-
the screen. If you want, you can then add pronunciation audio from Forvo using
69-
`a` (see below).
71+
the screen. If you want, you can now add
72+
pronunciation audio from Forvo using `a` (see below).
7073

7174
Like during subtitle selection, you can preview the selection audio with `p`.
72-
`` removes the last selected word.
75+
`Alt`+`` removes the newest selected word.
7376

7477
When you are ready to export the card, you can do so using `f`, or `F` if you
7578
want to open the export menu first.
@@ -86,7 +89,7 @@ playing. If you want to load all audio files automatically set
8689
Once you have selected a pronunciation that you are happy with, confirm it
8790
using ``.
8891

89-
If your target language is not Japanese you will have to change `forvo_language`
92+
If your target language is not Japanese you have to change `forvo_language`
9093
in the script config. The language code can be found on the Forvo website, for
9194
example on [this page](https://forvo.com/word/%E6%97%A5%E6%9C%AC/) at the right of:
9295

@@ -95,15 +98,15 @@ example on [this page](https://forvo.com/word/%E6%97%A5%E6%9C%AC/) at the right
9598

9699
## Export Menu
97100

98-
The export menu allows exporting a card using Anki's 'Add' GUI (`g`) and
101+
The export menu allows exporting a card using Anki's 'Add' GUI (`g`), and
99102
adding the export to an existing note.
100103

101104
The candidates for adding are found using the following query: `"deck:<target
102105
deck>" "note:<target note type>" is:new`, so all new cards of the target note
103106
type from the target deck.
104107

105108
`s` exports by adding to the most recently added candidate. `a` allows
106-
selecting a note from the list of candidates first. You can pick a note with
109+
selecting a note from a list of candidates first. You can pick a note with
107110
``/`` and ``. If you want to change how notes are displayed, you can use
108111
the target config entry `note_template`:
109112

@@ -148,8 +151,8 @@ configured to be.
148151

149152
Then the following template is applied to each field of the target note type,
150153
as configured by the `field:...` entries of the target config, as well as to
151-
all tags in the target's `tags` entry (additionally, spaces are replaced by
152-
underscores in tags):
154+
all tags in the target's `tags` entry (any spaces in variable values are
155+
replaced by underscores in tags):
153156

154157
<table>
155158
<tr>
@@ -158,7 +161,7 @@ underscores in tags):
158161
<th>Description</th>
159162
</tr>
160163
<tr>
161-
<th colspan="3"><code>field:&lt;field name&gt;</code></th>
164+
<th colspan="3"><code>field:&lt;field name&gt;</code>/<code>tags</code></th>
162165
</tr>
163166
<tr>
164167
<td><code>word</code></td>
@@ -283,14 +286,14 @@ The card is exported with the resulting fields and tags.
283286
### Substitutions
284287

285288
The variables `definitions` and `sentences` can be filtered through
286-
substitutions before being exported. These are defined in the entries
287-
`definition_substitutions` and `sentence_substitutions` of the target config.
289+
substitutions before being exported. These are defined in the target config
290+
entries `definition_substitutions` and `sentence_substitutions`.
288291

289292
`sentence_substitutions` are applied when selecting a subtitle line,
290-
`definition_substitutions` before the definition is added to the note
293+
`definition_substitutions` as the definition is added to the note
291294
immediately before it is sent to Anki.
292295

293-
Both those entries expect a multiline value, with each line representing a
296+
Both entries expect a multiline value, with each line representing a
294297
substitution, e.g. this is what the default value of `sentence_substitutions`
295298
would look like in a config file:
296299

@@ -304,19 +307,19 @@ sentence_substitutions=[[
304307
Each line is split at the first `<`. Everything to the left of it becomes the
305308
replacement and everything to the right becomes the pattern. If you want to
306309
use a `<` in the replacement string, you can escape it as `\<`. Other common
307-
escapes like `\n` or `\t` work as well, both in the replacement and pattern.
310+
escapes like `\n` or `\t` work as well, in both the replacement and pattern.
308311

309312
The pattern is a [Lua pattern](https://www.lua.org/manual/5.1/manual.html#5.4.1),
310313
which means that the following characters need to be escaped by placing a `%`
311314
before them if you want to use them literally: `^$()%.[]*+-?`.
312315

313316
All occurrences of the pattern are replaced by the replacement string, or
314-
deleted if the string is empty (i.e. the `<` is the first character of the
317+
deleted if the string is empty (i.e. `<` is the first character of the
315318
substitution definition). The patterns are applied one after the other in the
316319
order they are defined in.
317320

318321
The default value of `sentence_substitutions` contains the patterns `(.-)` and
319-
`%(.-%)`, both with an empty replacement. They delete character names and
322+
`%(.-%)` (both with an empty replacement), which delete character names and
320323
kanji readings from Japanese subtitles. If you want to disable them, simply
321324
put this line in the global section of `immersive-targets.conf`:
322325

doc/config.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ bar
3939
]]
4040
```
4141

42-
If there should be a line containing `]]`, a string can be added between the
42+
If there needs to be a line containing `]]`, a string can be added between the
4343
`[` of the opening token, which then has to be present in the closing token as
4444
well, like this:
4545

0 commit comments

Comments
 (0)