Skip to content
This repository has been archived by the owner on Feb 25, 2023. It is now read-only.

[Feature Request] Add audio to existing anki card #2197

Open
Mar2ck opened this issue Jul 6, 2022 · 1 comment
Open

[Feature Request] Add audio to existing anki card #2197

Mar2ck opened this issue Jul 6, 2022 · 1 comment

Comments

@Mar2ck
Copy link

Mar2ck commented Jul 6, 2022

When Yomichan detects that a card already exists for a word, it would be useful to have a feature where it could then amend word audio to that card if the field for it is blank.

I often make Anki cards on my phone using Akebi but that app doesn't support any word audio features/exporting so it would very helpful if i could use Yomichan to easily fill that in when I'm at my PC. Right now the solution is to remake the card with Yomichan which is far from convenient, or use the browser dev tools to grab the URL for the word audio after Yomichan has played it.

@kuroahna
Copy link

kuroahna commented Jul 6, 2022

Or you can just write a script that does this for you. Seems weird to have this in yomichan IMO, and you'd want to fill this in for all of your cards in 1 shot, not just the ones you happen to come across.

Just use anki's search feature using anki-connect's findNotes API, find all the cards with empty audio field, then use anki-connect to update the audio field for the given note ids. You probably want to use updateNoteFields

Modify the fields of an exist note. You can also include audio, video, or picture files which will be added to the note with an optional audio, video, or picture property. Please see the documentation for addNote for an explanation of objects in the audio, video, or picture array.

Sample request:

{
    "action": "updateNoteFields",
    "version": 6,
    "params": {
        "note": {
            "id": 1514547547030,
            "fields": {
                "Front": "new front content",
                "Back": "new back content"
            },
            "audio": [{
                "url": "https://assets.languagepod101.com/dictionary/japanese/audiomp3.php?kanji=猫&kana=ねこ",
                "filename": "yomichan_ねこ_猫.mp3",
                "skipHash": "7e2c2f954ef6051373ba916f000168dc",
                "fields": [
                    "Front"
                ]
            }]
        }
    }
}

You can use your existing card fields to fill out the kanji and kana query parameters for jpod101

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants