diff --git a/beetsplug/embedart.py b/beetsplug/embedart.py index 3ac1a1e25..5df9f2e5a 100644 --- a/beetsplug/embedart.py +++ b/beetsplug/embedart.py @@ -112,8 +112,15 @@ class EmbedCoverArtPlugin(BeetsPlugin): quality=quality) elif opts.url: from PIL import Image - response = requests.get(opts.url) - img = Image.open(BytesIO(response.content)) + try: + response = requests.get(opts.url, timeout=5) + response.raise_for_status() + except requests.exceptions.RequestException as e: + self._log.error("Error: {}".format(e)) + try: + img = Image.open(BytesIO(response.content)) + except OSError as e: + self._log.error("Error: {}".format(e)) if img.format: with open('temp.jpg', 'wb') as f: f.write(response.content)