Add videos by python Geanki

Good evening, does anyone have any suggestions or know how I could add videos via the geanki library in Python? I tried to create using the code below but the video does not appear. I’ve already tried using just {{PathVideo}}, the video loads with the MPV but the video has to be in the indicated path, I wanted the video to be already inside this file when exporting the .apkg file to send to other people.

 # Crie um modelo de carta
    modelo_carta = genanki.Model(
        1607392319,
        'Modelo de Carta Simples',
        fields=[
            {'name': 'Frente'},
            {'name': 'Verso'},
            {'name': 'video'}
        ],
        templates=[
            {
                'name': 'Carta Padrão',
                'qfmt': '<video controls><source src="{{video}}" type="video/mp4"></video><br>{{Frente}}<br>',
                'afmt': '<div style="text-align: center;">{{FrontSide}}<hr id="answer">{{Verso}}</div>',
            },
        ])

    # Crie um deck
    deck = genanki.Deck(
        2059400110,
        'A meu Deck Anki')

    # Crie uma carta
    carta = genanki.Note(
        model=modelo_carta,
        fields=['The book is on the table', 'O livro está na mesa', "videos/cut_10_17.87_to_22.559.mp4"])

    # Adicione a carta ao deck
    deck.add_note(carta)

    # Exporte o deck para um arquivo .apkg
    genanki.Package(deck).write_to_file('meu_deck_anki2.apkg')
1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.