3

I have an Anki Deck here, is there a way that I could programmatically insert a card on my current sample deck right here? See the image provided

Anki Deck image sample

Is there a way to do that with python? Since it is known that Anki is written in Python I have the feeling that is could be possible.

Also I have found this python package that you can actually create a deck and a card but I was thinking how can I insert the card object or Note as they would call it on the documentation... How can it be inserted to a current deck in Anki? Here is the code

import genanki

my_model = genanki.Model(1607392319,'Simple Model',
  fields=[
    {'name': 'Question'},
    {'name': 'Answer'},
  ],
  templates=[
    {
      'name': 'Card 1',
      'qfmt': '{{Question}}',
      'afmt': '{{FrontSide}}<hr id="answer">{{Answer}}',
    },
  ])




my_note = genanki.Note(
  model=my_model,
  fields=['Capital of Argentina', 'Buenos Aires'])



my_deck = genanki.Deck(
  2059400110,
  'Country Capitals')

my_deck.add_note(my_note)

genanki.Package(my_deck).write_to_file('output.apkg')

Link to the github -> genanki

E_net4
  • 27,810
  • 13
  • 101
  • 139
  • Can't you simply generate the file then import it with Anki? What's the point of adding it automatically? – user202729 Sep 21 '20 at 14:15
  • Yes I know that I can do that... but I was just wondering if there could be a way that I can programmatically insert some thing on the anki software –  Sep 25 '20 at 08:53

0 Answers0