Raise OSError

This commit is contained in:
Alok Saboo 2023-03-28 13:23:26 -04:00
parent 2fcdb8c2ca
commit 3b39a4fe66

View file

@ -15,6 +15,7 @@
"""Allows beets to embed album art into file metadata."""
import os.path
import traceback
from io import BytesIO
import requests
@ -84,7 +85,7 @@ class EmbedCoverArtPlugin(BeetsPlugin):
embed_cmd.parser.add_option("-y", "--yes", action="store_true",
help="skip confirmation")
embed_cmd.parser.add_option('-u', '--url', action="store_true",
embed_cmd.parser.add_option('-u', '--url', metavar='URL',
help='the URL of the image file to embed')
maxwidth = self.config['maxwidth'].get(int)
@ -125,8 +126,10 @@ class EmbedCoverArtPlugin(BeetsPlugin):
try:
with open('temp.jpg', 'wb') as f:
f.write(response.content)
except util.FilesystemError as exc:
self._log.error('Error writing file: {}', exc)
except OSError as exc:
raise util.FilesystemError(exc, 'write',
bytestring_path('temp.jpg'),
traceback.format_exc())
opts.file = 'temp.jpg'
items = lib.items(decargs(args))
# Confirm with user.