|
|||||||
![]() |
|
|
Thread Tools | Search this Thread |
|
|
#16 | |
|
Groupie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 168
Karma: 1162312
Join Date: Nov 2023
Location: Belgium / Vlaanderen
Device: Kobo Libra 2 + Vivlio Light HD + (ancient) iPad Pro
|
Quote:
Exporting highlights and dictionary lookups is trivial as well, I can share my script that exports my dictionary lookups to anki if you are interested, you should be able to export it to .md as well. |
|
|
|
|
|
|
#17 |
|
Junior Member
![]() Posts: 8
Karma: 10
Join Date: Jul 2026
Device: kein
|
Hi Dschungelwald,
Thanks a lot for the feedback! That sounds great—especially that KOReader integrates so seamlessly into PocketBook OS. I'd actually be really interested in your script! If it can be used for exporting to .md files, that would be perfect for my workflow. How does the script work exactly, or where can I check it out? Best regards, Nils |
|
|
|
| Advert | |
|
|
|
|
#18 |
|
Groupie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 168
Karma: 1162312
Join Date: Nov 2023
Location: Belgium / Vlaanderen
Device: Kobo Libra 2 + Vivlio Light HD + (ancient) iPad Pro
|
Python is not my main language so it’s probably a very ugly solution but it works for me
![]() Code:
import sqlite3
import requests
from pystardict import Dictionary
DATABASE_PATH = 'vocabulary_builder.sqlite3'
STARDICT_PATH = 'your_dictionary_file_here’
ANKI_CONNECT_URL = 'http://localhost:8765'
NOT_FOUND_FILE = 'not_found.txt'
def get_translation(word):
my_dict = Dictionary(STARDICT_PATH)
for key in my_dict.idx.keys():
if key == word:
return my_dict.dict[key]
return None
def add_note_to_anki(word, translation, prev_context, next_context):
note = {
"deckName": "your_deck_name",
"modelName": "Basic",
"fields": {
"Front": word,
"Back": f"{prev_context}[{word}]{next_context}<br><br>{translation}"
},
"tags": []
}
payload = {
"action": "addNote",
"version": 6,
"params": {
"note": note
}
}
response = requests.post(ANKI_CONNECT_URL, json=payload)
return response.json()
conn = sqlite3.connect(DATABASE_PATH)
cursor = conn.cursor()
cursor.execute("SELECT word, prev_context, next_context FROM vocabulary")
rows = cursor.fetchall()
not_found = []
for row in rows:
word, prev_context, next_context = row
translation = get_translation(word)
print("TRANSLATION")
print(translation)
if translation:
result = add_note_to_anki(word, translation, prev_context, next_context)
else:
print("not found")
print(word)
not_found.append(word)
with open(NOT_FOUND_FILE, 'w') as file:
for word in not_found:
file.write(f"{word}\n")
conn.close()
You need to have Anki Desktop app running, otherwise it wouldn’t work. Or you can throw the anki part away and export it to .md instead |
|
|
|
|
|
#19 |
|
Junior Member
![]() Posts: 8
Karma: 10
Join Date: Jul 2026
Device: kein
|
Thanks for sharing this, much appreciated!
|
|
|
|
![]() |
| Thread Tools | Search this Thread |
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Searching for "& # 9 ; " | oston | Sigil | 5 | 03-11-2026 03:30 PM |
| Libra 2 "Unable to import annotations as the annotations column has not been configured..." | Liudprand | Kobo Reader | 2 | 07-29-2023 10:56 PM |
| eReader with an 11" or 12"" screen and physical buttons | apastuszak | Which one should I buy? | 7 | 06-13-2023 06:03 AM |
| Pressing "Restore Defaults" under "Book Details" wipes all "Look & Feel" settings. | MarjaE | Library Management | 1 | 03-30-2021 11:46 AM |
| Swap "Prev Page" & "Next Buttons" ???? | kilofox | Amazon Kindle | 6 | 04-02-2008 11:39 PM |