FooSoft / yomichan

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

Error downloading audio for Anki card (request-builder.js exception) #2275

Closed ilcane87 closed 1 year ago

ilcane87 commented 1 year ago

Description It's been working fine for years, but I just noticed it suddenly stopped working between 04/18 and 04/23 this year. While the audio plays fine in the browser popup (source: JapanesePod101), the cards are added with the audio field empty.

EDIT: turns out the audio files were indeed downloaded in the Anki media folder, the problem is simply that the Audio fields of the cards aren't populated.

The extension has permission to work 'On all sites', and checking other similar past issues in here didn't help.

This is the relevant part of the Anki setup, which I'm pretty sure is correct:

{{#*inline "audio"}}
    {{~#if (hasMedia "audio")~}}
        [sound:{{#getMedia "audio"}}{{/getMedia}}]
    {{~/if~}}
{{/inline}}

And here is the error log:

request-builder.js:56 Uncaught (in promise) TypeError: Failed to execute 'fetch' on 'Window': The provided value is not of type 'RequestInit'.
    at RequestBuilder.fetchAnonymous (request-builder.js:56:9)
    at AudioDownloader._downloadAudioFromUrl (audio-downloader.js:262:53)
    at AudioDownloader.downloadTermAudio (audio-downloader.js:65:47)
    at async Backend._injectAnkiNoteAudio (backend.js:1838:36)
    at async Backend._injectAnkNoteMedia (backend.js:1795:33)
    at async Backend._onApiInjectAnkiNoteMedia (backend.js:516:16)
fetchAnonymous @ request-builder.js:56
_downloadAudioFromUrl @ audio-downloader.js:262
downloadTermAudio @ audio-downloader.js:65
await in downloadTermAudio (async)
_injectAnkiNoteAudio @ backend.js:1838
_injectAnkNoteMedia @ backend.js:1795
_onApiInjectAnkiNoteMedia @ backend.js:516
invokeMessageHandler @ core.js:366
_onMessage @ backend.js:330
_onMessageWrapper @ backend.js:301

Browser version Google Chrome Version 107.0.5304.122 (Official Build) (64-bit)

Yomichan version 22.10.23.0

Exported settings file yomichan-settings-2022-12-02-09-30-07.zip

ilcane87 commented 1 year ago

I was able to fix the issue by updating AnkiConnect, which I hadn't done since 2019. The problem probably started with the release of Chrome 101 towards the end of April, which supposedly introduced some incompatibility with the old version of AnkiConnect.

Btw I was able to fix the Audio fields of most of the cards created during the last months by following this advice: https://github.com/FooSoft/yomichan/issues/2197#issuecomment-1176794714

I'm closing the issue with this.