From 165ee80f81c50ad5fa59364c519c7be2f25ef843 Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Thu, 11 Dec 2014 16:03:49 -0800 Subject: [PATCH] lyrics: Handle requests exceptions (#1136) --- beetsplug/lyrics.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/beetsplug/lyrics.py b/beetsplug/lyrics.py index 9d9809054..73821ee22 100644 --- a/beetsplug/lyrics.py +++ b/beetsplug/lyrics.py @@ -61,12 +61,15 @@ def fetch_url(url): """Retrieve the content at a given URL, or return None if the source is unreachable. """ - r = requests.get(url) + try: + r = requests.get(url) + except requests.RequestException as exc: + log.debug(u'lyrics request failed: {0}'.format(exc)) + return if r.status_code == requests.codes.ok: return r.text else: log.debug(u'failed to fetch: {0} ({1})'.format(url, r.status_code)) - return None def unescape(text):