mirror of
https://github.com/beetbox/beets.git
synced 2026-01-10 18:07:00 +01:00
Add additional error handling
This commit is contained in:
parent
2060e047d2
commit
2e2a3bf223
1 changed files with 9 additions and 2 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue