This is a Python script to help add words from Kindle to Anki.
- It can directly add words to Anki decks or creates a anki-ready tsv file.
- Adds words from the Vocabulary Builder.
- Highlight the word in the sentence. You can add special color/font style for the word.
- Last timestamp of the imported word is written to
~/.kindle
. During next import only new lookups are exported. One can manipulate value written to~/.kindle
to get only needed words from Kindle. - Retrieve translations from Hujiang Online Dictionary (https://dict.hjenglish.com/jp/) for Japanese to Chinese.
- Option to convert Simplified Chinese to Traditional Chinese in the translation.
- Exensible and configurable dictionary setting.
There are three ways to pass arguments to the script:
- Pass by command line arguments;
- Write the arguments in a config file in YAML format and specify the file using
--config=CONFIG_FILE
or-c CONFIG_FILE
option; - Provide default config files with the name
config.default.yml
andconfig.YOUR_COMPUTER_NAME.yml
(optional) under theconfig
directory of the project.
Note that: if a value is specified in more than one way then: command line > config file > default config files.
The following is an example of running the script using the aforementioned ways.
$ ./kindle2anki.py --kindle ./vocab.db --anki-profile frank --deck test \
--card-type BlueCard --lang-dict ja:hjdict.quick.HJDict_Quick
100%|██████████| 2/2 [00:00<00:00, 2.00it/s]
INFO:root:Start importing words into Anki...
INFO:root:2 note(s) imported!
Put the arguments into config files (e.g., config.default.yml
):
kindle: ./vocab.db
deck: test
card-type: BlueCard
# tags: [kindle]
lang-dict: [ja:hjdict.quick.HJDict_Quick]
And then run the script without any command line arguments:
$ ./kindle2anki.py
100%|██████████| 2/2 [00:00<00:00, 2.00it/s]
INFO:root:Start importing words into Anki...
INFO:root:2 note(s) imported!
- Install Python 3
- Clone this repo and init the submodules.
- Install requirements (
pip install -r requirements.txt
)
$ ./kindle2anki.py --help
usage: kindle2anki.py [-h] [-c CONFIG] [--kindle KINDLE]
[--anki-profile ANKI_PROFILE] [--collection COLLECTION]
[--deck DECK] [--card-type CARD_TYPE] [-o OUT]
[--update-timestamp] [--verbose] [--clipboard]
[--lang-dict LANG_DICT] [--tags TAGS]
[--traditional-chinese]
optional arguments:
-h, --help show this help message and exit
-c CONFIG, --config CONFIG
Config file path.
--kindle KINDLE Path to kindle db file (usually vocab.db)
--anki-profile ANKI_PROFILE
Profile name of Anki. Will be ignored if --collection
is provided.
--collection COLLECTION
Path to anki collection file (.anki file). The script
will look for the default path if this parameter is
not provided,
--deck DECK Anki deck name.
--card-type CARD_TYPE
Anki card type to use.
-o OUT, --out OUT CSV output filename to import into anki.
--update-timestamp Update local timestamp to now and exit
--verbose Show debug messages
--clipboard Copy each word to clipboard
--lang-dict LANG_DICT
Specify dictionary for a language in the form of
LANG:DICT_MODULE.DICT_CLASSe.g.,
ja:hjdict.quick.HJDict_Quick
--tags TAGS A list of tags to add to notes.
--traditional-chinese
Convert simplified Chinese to traditional Chinese.
One can use udev rules to run this script automatically on Kindle connect. See https://github.com/seletskiy/runki#kindle–udev