From 80dee403001aa4cd4004a27b4908626c80052420 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Sun, 17 Jul 2016 10:34:07 -0700 Subject: [PATCH] Audio now works --- anki_connect.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/anki_connect.py b/anki_connect.py index 153c98f..5d910ab 100644 --- a/anki_connect.py +++ b/anki_connect.py @@ -66,10 +66,10 @@ def audioIsPlaceholder(data): return m.hexdigest() == '7e2c2f954ef6051373ba916f000168dc' -def audioInject(note, kana, kanji, fields): +def audioInject(note, fields, filename): for field in fields: if field in note: - note[field] += u'[sound:{}]'.format(audioBuildFilename(kana, kanji)) + note[field] += u'[sound:{}]'.format(filename) # @@ -243,10 +243,11 @@ class AnkiBridge: return if audio is not None and len(audio['fields']) > 0: - data = audioDownload(**audio) + data = audioDownload(audio['kana'], audio['kanji']) if data is not None and not audioIsPlaceholder(data): - audioInject(note, **audio) - self.media().writeData(audioBuildFilename(**audio), data) + filename = audioBuildFilename(audio['kana'], audio['kanji']) + audioInject(note, audio['fields'], filename) + self.media().writeData(filename, data) self.startEditing() collection.addNote(note)