Skip to content

Anki

anki

Defines stateless helpers for exporting a profile's saved clips as an Anki deck using genanki

Attributes:

Name Type Description
VIDEO_CSS str

Pre-defined CSS of the cards

CARD_TEMPLATE list

Pre-defined template of the cards for genanki

MODEL_FIELDS list

Pre-defined card model fields

MODEL_NAME str

Pre-defined standard model name

DECK_NAME str

Pre-defined standard deck name

VIDEO_TAG str

HTML <video> tag template embedding a bundled clip

AnkiCard dataclass

Data for a single Anki card built from a saved clip

Attributes:

Name Type Description
clip_path str

Absolute path to the clip file, bundled as card media

word str

The focus word shown on the card front

meanings str

The word's meanings as a single string

sentence str

The sentence the word came from

explanation str

The LLM explanation of the sentence

tags list[str]

Optional card tags

build_model()

Builds the shared genanki.Model used for every Mirumoji card

Returns:

Type Description
Model

The configured genanki.Model

export_deck(cards, output_path)

Builds a deck from cards and writes it (with bundled clip media) to disk

Each card's clip_path is bundled into the package as media and embedded in the card via an HTML <video> tag referencing the file's base name

Parameters:

Name Type Description Default
cards list[AnkiCard]

The cards to add to the deck

required
output_path str

Path to write the resulting .apkg file to

required

id_from_string(s)

Creates a stable, unique genanki model/deck id from a string

Parameters:

Name Type Description Default
s str

String to derive the id from

required

Returns:

Type Description
int

An integer id derived from the string's SHA-1 digest