Created
September 23, 2018 04:55
-
-
Save jlumbroso/60971ec65324603c0ab2efd02fd8098b to your computer and use it in GitHub Desktop.
Minimal example to build an Anki deck with an image, with genanki
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import genanki | |
my_model = genanki.Model( | |
1380120064, | |
'Example', | |
fields=[ | |
{'name': 'Object'}, | |
{'name': 'Image'}, | |
], | |
templates=[ | |
{ | |
'name': 'Card 1', | |
'qfmt': '{{Object}}', | |
'afmt': '{{FrontSide}}<hr id="answer"><img src="{{Image}}"/>', | |
}, | |
]) | |
my_note = genanki.Note( | |
model=my_model, | |
fields=['JPEG File', 'format.jpg']) | |
my_deck = genanki.Deck( | |
2059400191, | |
'Example') | |
my_deck.add_note(my_note) | |
my_package = genanki.Package(my_deck) | |
my_package.media_files = ['format.jpg'] | |
my_package.write_to_file('output.apkg') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I had the same issue as GlosuU, not everyone scrolls down a gist they find.
But thanks for making this.