From 795709b9ace3206430db4c303aa2d57fddfb1e86 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Sun, 3 Jun 2018 15:09:13 -0700 Subject: [PATCH] fix failing to create notes when audio could not be downloaded --- AnkiConnect.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/AnkiConnect.py b/AnkiConnect.py index 7c52825..51db638 100644 --- a/AnkiConnect.py +++ b/AnkiConnect.py @@ -647,8 +647,8 @@ class AnkiConnect: audio = note.get('audio') if audio is not None and len(audio['fields']) > 0: - data = download(audio['url']) - if data is not None: + try: + data = download(audio['url']) if audio['skipHash'] is None: skip = False else: @@ -662,6 +662,8 @@ class AnkiConnect: ankiNote[field] += u'[sound:{}]'.format(audio['filename']) self.media().writeData(audio['filename'], data) + except: + pass collection = self.collection() self.startEditing()