themoeway / yomitan

Pop-up dictionary browser extension. Successor to Yomichan.
https://yomitan.wiki
GNU General Public License v3.0
1.2k stars 94 forks source link

Fails to download audio source with valid JSON request #242

Closed bryonye closed 5 months ago

bryonye commented 1 year ago

Description Using with Yomitan and custom URL (JSON) http://localhost:8770/?expression={term}&term={term} to get Chinese audio via the Yomichan Forvo Server addon. I inspected the network traffic and the Forvo addon is generating a valid JSON with working links (validated against this schema), so the issue does not lie with the Forvo addon.

When adding a card, the Yomitan addon fails to add any audio; no file is created and the audio field is blank. When using the hover dictionary, there is an X by the speaker icon, and only a clicking sound plays, indicating no content. I think that perhaps the links are not being parsed properly here. On Yomichan there is a similar issue where the actual JSON request is written to file instead of audio content, generating an invalid file. This may be related.

Browser version FireFox 117 on Linux

Yomichan version Extension version: Yomitan 23.8.19.0 Platform: Linux Browser: Firefox Language: en-US User agent: Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/117.0 AnkiConnect version: 6 Installed dictionaries: CEDICT

Exported settings file

jbukl commented 11 months ago

Tried replicating with different settings but it seemed to work fine. I had the same issue with the speaker button simply playing a click, but it was just because I had the permissions set incorrectly - for some reason it was defaulting to japaneseaudiopod101 until I enabled "all url access" as a permission, although I had already removed that audio source.

Browser version Firefox Nightly 120.0a1 on Windows

Yomichan version Extension version: Yomitan 23.10.1.0 Platform: Windows Browser: Firefox Language: en-US User agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:120.0) Gecko/20100101 Firefox/120.0 AnkiConnect version: 6 Installed dictionaries: CEDICT

praschke commented 11 months ago

i experienced this on a fresh install, the reason was 'all url access' was not enabled. this is not a bug.

bryonye commented 11 months ago

This appears to be my bad then! It may be worth adding this issue to the FAQs, as the file permissions issue is only mentioned regarding Chrome. I went into permissions.html and found the 'Allow access to file URLs' setting and it (alongside every other option except for clipboardRead) is not toggle-able for me. I tried toggling Enable recommended permissions in options.html, and either way it's toggled I can't switch anything in the permissions page. Is there a way around this like manually editing a perms file?

jbukl commented 11 months ago

This appears to be my bad then! It may be worth adding this issue to the FAQs, as the file permissions issue is only mentioned regarding Chrome. I went into permissions.html and found the 'Allow access to file URLs' setting and it (alongside every other option except for clipboardRead) is not toggle-able for me. I tried toggling Enable recommended permissions in options.html, and either way it's toggled I can't switch anything in the permissions page. Is there a way around this like manually editing a perms file?

Is this greyed out as well? The permission is actually not immediately on the permissions page, rather enabled on a popup from clicking this and then "Allow access to all urls" image

might make sense to have some sort of visual cue/note when you have audio sources enabled that aren't reachable because of permissions.

bryonye commented 11 months ago

I can click the 'Configure allowed origins...' section, where it appears I already have 'Allow access to all URLs' enabled. 'Allow access to file URLs' is not toggleable. I thought it might be worth manually adding the localhost address to the 'Additional origins' list, but it appears that I am not able to actually add any URLs (or if it does add them, they are not listed anywhere). (Also, the URL parsing regex seems a bit odd, and could do with stripping whitespace at the start/end and perhaps not forcing trailing /. I am unsure if this kind of discussion warrants its own issue as it is still in pre-release.)

image

image

praschke commented 11 months ago

@bryonye on firefox those permissions can be enabled in the permissions tab of the extension in firefox's "manage extension" page, which can be accessed according to this help page.

if you find the permission is enabled on that page and the audio still fails to download then that would be a bug. a screenshot of the firefox extension page, your exported settings, and an example json response would be helpful in that case.

praschke commented 11 months ago

permissions discoverability was addressed by #214, so it is likely that access to all urls is enabled and the allowed origins modal is not lying.

173 also expressed this behavior with all urls enabled. when i looked into that there was a flakey bug where declarativeNetRequest would stop working, but only after the browser had restarted. i thought that flakiness explained the inconsistent behavior.

the version you're running, 23.8.19.0, includes that workaround for declarativeNetRequest by using the old webRequest path. this is probably a new bug.

djahandarie commented 10 months ago

@bryonye Could you confirm that you're still having an issue on the latest release?