-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
34 lines (27 loc) · 1.08 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from KindleToAnki import KindleToAnki
from DeckCreator import DeckCreator
API_KEY = "your-key-here" #create a unique API key
def initialize(API_KEY):
vocab = KindleToAnki(API_KEY)
print(vocab.getTitle())
while True:
try:
ID = input("\nSelect a valid Title ID, or q to quit: ")
if ID == "q":
exit()
ID = int(ID)
if ID < vocab.df['id'].min() or ID > vocab.df['id'].max():
raise ValueError(f"ID must be between {vocab.df['id'].min()} and {vocab.df['id'].max()}")
break
except ValueError as error:
print(error)
print(vocab.setTitleById(ID))
#print(vocab.df.head())
#Alternativaly, you can set title by name, e.g: vocab.setTitleByName("The Power of Habit")
vocab.createDefinitionColumn()
deck = DeckCreator(vocab.getSelectedTitle())
# Create cards for each row in the dataframe
deck.addCard(vocab.df['stem'], vocab.df['definition'], vocab.df['usage'])
print(deck.saveDeck())
if __name__ == "__main__":
initialize(API_KEY)