From 322984be06535cafc9e1735480c054426a6aae75 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Mon, 18 Jan 2021 20:18:57 -0800 Subject: [PATCH] Cleanup --- plugin/util.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/plugin/util.py b/plugin/util.py index 8109446..8023849 100644 --- a/plugin/util.py +++ b/plugin/util.py @@ -33,12 +33,13 @@ class MediaType(enum.Enum): def download(url): client = anki.sync.AnkiRequestsClient() client.timeout = setting('webTimeout') / 1000 + resp = client.get(url) - if resp.status_code == 200: - return client.streamContent(resp) - else: + if resp.status_code != 200: raise Exception('{} download failed with return code {}'.format(url, resp.status_code)) + client.streamContent(resp) + def api(*versions): def decorator(func):