fix failing to create notes when audio could not be downloaded

This commit is contained in:
Alex Yatskov 2018-06-03 15:09:13 -07:00
parent 0ca55353fa
commit 795709b9ac

View File

@ -647,8 +647,8 @@ class AnkiConnect:
audio = note.get('audio') audio = note.get('audio')
if audio is not None and len(audio['fields']) > 0: if audio is not None and len(audio['fields']) > 0:
try:
data = download(audio['url']) data = download(audio['url'])
if data is not None:
if audio['skipHash'] is None: if audio['skipHash'] is None:
skip = False skip = False
else: else:
@ -662,6 +662,8 @@ class AnkiConnect:
ankiNote[field] += u'[sound:{}]'.format(audio['filename']) ankiNote[field] += u'[sound:{}]'.format(audio['filename'])
self.media().writeData(audio['filename'], data) self.media().writeData(audio['filename'], data)
except:
pass
collection = self.collection() collection = self.collection()
self.startEditing() self.startEditing()