From ec433a04862bff6f00ef40c07c5854a5acd7ee42 Mon Sep 17 00:00:00 2001 From: vardecab <6877391+vardecab@users.noreply.github.com> Date: Wed, 17 Mar 2021 14:31:08 +0100 Subject: [PATCH] 1.1.2 --- README.md | 7 ++++--- script.py | 14 ++++++++------ 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 90ecb7e..f7aab62 100644 --- a/README.md +++ b/README.md @@ -10,12 +10,12 @@ ### Windows 1. Connect your Kindle via USB cable to your computer. -2. Download `script.exe` from [Releases](https://github.com/vardecab/kindle-words/releases). -3. Run it. +2. Download `script.zip` from [Releases](https://github.com/vardecab/kindle-words/releases). +3. Run `script.exe`. 4. Write source & target languages or wait if defaults (`en` & `pl`) are ok. 5. Write drive letter associated with Kindle or wait if default (`D`) is ok. 6. Wait a few minutes - words are being translated. -7. Go to `output/kindle-words_export.txt` to check exported file. +7. Go to `script\output\kindle-words_export.txt` to check exported file. 8. (optional) Add it to [Quizlet](https://quizlet.com/). 9. Voilà ✨ @@ -31,6 +31,7 @@ ## Release History +- 1.1.2: Added `try/except` to fix a `FileNotFoundError` error. - 1.1.1: Fixed `io.open` bug; added some `try/except` to catch more errors; re-enabled `timeout_time`; added `last_word` export so it's easy to see which words are new and which are old. Published in [Releases](https://github.com/vardecab/kindle-words/releases). - 1.1: Quite a big re-write: it now works properly with `My Clippings.txt` file from Kindle - all bugs are fixed. Initial run takes ~ 10 minutes to complete (depending on the size of your file) but afterwards it's usually < 1 minute because data from previous run is stored locally for comparison - only new words are being translated to save time and improve speed. - 1.0.0: Using new API - [deep-translator](https://github.com/nidhaloff/deep-translator). diff --git a/script.py b/script.py index 3dc16a6..763060d 100644 --- a/script.py +++ b/script.py @@ -75,12 +75,14 @@ os.makedirs('data') ### show the last word that was added on the previous run -with open('output/output-original_words.txt', 'r') as file: - lines = file.read().splitlines() - last_word = lines[-1] - # print(last_word) # debug -with open('output/last_word.txt', 'w') as file: - file.write(last_word) +try: + with open('output/output-original_words.txt', 'r') as file: + lines = file.read().splitlines() + last_word = lines[-1] + with open('output/last_word.txt', 'w') as file: + file.write(last_word) +except FileNotFoundError: + print('First run - no file to load data.') ### list cleanup read_source_file = [x for x in read_source_file if not any(x1.isdigit() for x1 in x)] # remove numbers