From 21d194d14510abb149d22c8cbd56570cd6b62266 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sat, 7 Mar 2020 14:25:25 -0500 Subject: Make _audioInject internal to Backend --- ext/bg/js/audio.js | 44 -------------------------------------------- 1 file changed, 44 deletions(-) (limited to 'ext/bg/js/audio.js') diff --git a/ext/bg/js/audio.js b/ext/bg/js/audio.js index c94121ae..361a19cc 100644 --- a/ext/bg/js/audio.js +++ b/ext/bg/js/audio.js @@ -138,47 +138,3 @@ function audioUrlNormalize(url, baseUrl, basePath) { } return url; } - -function audioBuildFilename(definition) { - if (definition.reading || definition.expression) { - let filename = 'yomichan'; - if (definition.reading) { - filename += `_${definition.reading}`; - } - if (definition.expression) { - filename += `_${definition.expression}`; - } - - return filename += '.mp3'; - } - return null; -} - -async function audioInject(definition, fields, sources, optionsContext, audioSystem) { - let usesAudio = false; - for (const fieldValue of Object.values(fields)) { - if (fieldValue.includes('{audio}')) { - usesAudio = true; - break; - } - } - - if (!usesAudio) { - return true; - } - - try { - const expressions = definition.expressions; - const audioSourceDefinition = Array.isArray(expressions) ? expressions[0] : definition; - - const {uri} = await audioSystem.getDefinitionAudio(audioSourceDefinition, sources, {tts: false, optionsContext}); - const filename = audioBuildFilename(audioSourceDefinition); - if (filename !== null) { - definition.audio = {url: uri, filename}; - } - - return true; - } catch (e) { - return false; - } -} -- cgit v1.2.3