Skip to content

Commit

Permalink
fix no anki audio
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanVukovic99 committed Jun 30, 2024
1 parent fe4533b commit 6af13f1
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion ext/js/media/audio-downloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ export class AudioDownloader {
*/
async downloadTermAudio(sources, preferredAudioIndex, term, reading, idleTimeout, languageSummary) {
const errors = [];
for (const source of sources) {
const requiredAudioSources = this._getRequiredAudioSources(languageSummary.iso, sources);
for (const source of [...sources, ...requiredAudioSources]) {
let infoList = await this.getTermAudioInfoList(source, term, reading, languageSummary);
if (typeof preferredAudioIndex === 'number') {
infoList = (preferredAudioIndex >= 0 && preferredAudioIndex < infoList.length ? [infoList[preferredAudioIndex]] : []);
Expand All @@ -115,6 +116,31 @@ export class AudioDownloader {

// Private

/**
* @param {string} language
* @param {import('audio').AudioSourceInfo[]} sources
* @returns {import('audio').AudioSourceInfo[]}
*/
_getRequiredAudioSources(language, sources) {
/** @type {Set<import('settings').AudioSourceType>} */
const requiredSources = language === 'ja' ?
new Set([
'jpod101',
'jpod101-alternate',
'jisho',
]) :
new Set([
'lingua-libre',
'wiktionary',
]);

for (const {type} of sources) {
requiredSources.delete(type);
}

return [...requiredSources].map((type) => ({type, url: '', voice: ''}));
}

/**
* @param {string} url
* @param {string} base
Expand Down

0 comments on commit 6af13f1

Please sign in to comment.