FooSoft / yomichan

Japanese pop-up dictionary extension for Chrome and Firefox.
https://foosoft.net/projects/yomichan
Other
1.06k stars 213 forks source link

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

Open Mar2ck opened 2 years ago

Mar2ck commented 2 years ago

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 commented 2 years ago

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