Skip to content

Commit

Permalink
lyrics: Handle requests exceptions (#1136)
Browse files Browse the repository at this point in the history
  • Loading branch information
sampsyo committed Dec 12, 2014
1 parent 7ff956d commit 165ee80
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions beetsplug/lyrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 165ee80

Please sign in to comment.