mirror of
https://github.com/spotipy-dev/spotipy.git
synced 2026-04-26 16:15:51 +03:00
[GH-ISSUE #633] Broken Pipe Error while uploading playlist cover #378
Labels
No labels
api-bug
bug
dependencies
documentation
duplicate
enhancement
external-ide
headless-mode
implicit-grant-flow
invalid
missing-endpoint
pr-welcome
private-api
pull-request
question
spotipy3
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/spotipy#378
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @CaseusNL on GitHub (Jan 14, 2021).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/633
Whenever I want to upload a new playlist cover I am confronted with a broken pipe error.
`
with open(readConfig("mainImg"), "rb") as image_file:
encoded_string = base64.b64encode(image_file.read())
`
Which returns:
`
Traceback (most recent call last):
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/urllib3/connectionpool.py", line 677, in urlopen
chunked=chunked,
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/urllib3/connectionpool.py", line 392, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/http/client.py", line 1083, in request
self._send_request(method, url, body, headers)
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/http/client.py", line 1128, in _send_request
self.endheaders(body)
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/http/client.py", line 1079, in endheaders
self._send_output(message_body)
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/http/client.py", line 913, in _send_output
self.send(message_body)
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/http/client.py", line 885, in send
self.sock.sendall(data)
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/ssl.py", line 886, in sendall
v = self.send(data[count:])
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/ssl.py", line 856, in send
return self._sslobj.write(data)
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/ssl.py", line 581, in write
return self._sslobj.write(data)
BrokenPipeError: [Errno 32] Broken pipe
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/requests/adapters.py", line 449, in send
timeout=timeout
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/urllib3/connectionpool.py", line 727, in urlopen
method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/urllib3/util/retry.py", line 410, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/urllib3/packages/six.py", line 734, in reraise
raise value.with_traceback(tb)
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/urllib3/connectionpool.py", line 677, in urlopen
chunked=chunked,
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/urllib3/connectionpool.py", line 392, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/http/client.py", line 1083, in request
self._send_request(method, url, body, headers)
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/http/client.py", line 1128, in _send_request
self.endheaders(body)
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/http/client.py", line 1079, in endheaders
self._send_output(message_body)
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/http/client.py", line 913, in _send_output
self.send(message_body)
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/http/client.py", line 885, in send
self.sock.sendall(data)
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/ssl.py", line 886, in sendall
v = self.send(data[count:])
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/ssl.py", line 856, in send
return self._sslobj.write(data)
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/ssl.py", line 581, in write
return self._sslobj.write(data)
urllib3.exceptions.ProtocolError: ('Connection aborted.', BrokenPipeError(32, 'Broken pipe'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "SpotipyTest.py", line 219, in
sp.playlist_upload_cover_image(mainPlaylistID, encoded_string)
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/spotipy/client.py", line 694, in playlist_upload_cover_image
content_type="image/jpeg",
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/spotipy/client.py", line 306, in _put
return self._internal_call("PUT", url, payload, kwargs)
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/spotipy/client.py", line 242, in _internal_call
timeout=self.requests_timeout, **args
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/requests/sessions.py", line 530, in request
resp = self.send(prep, **send_kwargs)
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/requests/sessions.py", line 643, in send
r = adapter.send(request, **kwargs)
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/requests/adapters.py", line 498, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', BrokenPipeError(32, 'Broken pipe'))
`
@stephanebruckert commented on GitHub (Jan 23, 2021):
I think this is because you are uploading an image that's more than 256KB
We could definitely catch that exception and display a proper error message. A PR that does that is welcome!
@gustavokrieger commented on GitHub (Apr 18, 2021):
I'll start working on this. Should I fix it on the "v3" branch only?
@stephanebruckert commented on GitHub (Apr 18, 2021):
Awesome. Nope, that's a fix for v2, so please use the main branch
@gustavokrieger commented on GitHub (Apr 21, 2021):
(Running Windows 10, Python 3.7.9)
I couldn't reproduce this exact error. The "closest" I got was:
requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionAbortedError(10053, 'An established connection was aborted by the software in your host machine', None, 10053, None))That happened when I uploaded the image generated by:
Which generated a 1.49 MB image.
@gustavokrieger commented on GitHub (Apr 21, 2021):
I ran some other tests.
I uploaded the image generated by:
image = Image.new('RGB', size=(10_000, 1_232))Which generated a 188 KB image. It uploaded correctly. But when I generated one by running:
image = Image.new('RGB', size=(10_000, 1_233))Which generated a 191 KB image, it failed with the following error:
Which occurred while handling the following:
requests.exceptions.HTTPError: 413 Client Error: Request Entity Too Large for url: https://api.spotify.com/v1/playlists/1fYfHp88zjW0kVZItm20gu/imagesSo, apparently it failed to upload an image that was smaller than 256 KB. It's because the maximum payload size is 256 KB, not only just the image, right? Am I testing it correctly?
@stephanebruckert commented on GitHub (Apr 21, 2021):
I wonder if the size (width x height) matters too? In your case 10000px looks too high.
For example, I think the image must be minimum 300x300px to be uploaded manually. Maybe there is also a maximum limit
To get random images in code, I like to use the dog API https://dog.ceo/dog-api/ 🐶
@gustavokrieger commented on GitHub (Apr 21, 2021):
@stephanebruckert Were you able to reproduce the error?