-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upload script failing with UnicodeDecodeError #9
Comments
Hi! what kind of string are you passing as the title of the video ? It's Thanks |
I’m not trying to set a title. I run the script like: vimeo-uploadv2.py -k e***_6 -s a**_7 -t 7a -y 7*3 -f z:\edits\videos\000.wmv As a sanity check I did upload the same video through the website successfully. From: Marc Poulhiès [mailto:notifications@github.com]
Hi! what kind of string are you passing as the title of the video ? It's Thanks — |
So here's my analysis and (hackish) solution: The error is coming from this part of httplib.py:
At this point msg is unicode, and our message_body is a str, so it tries to convert message_body to unicode and raises the exception. I tried to fix it by converting the message_body to a bytearray before sending, thereby skipping the offending line in httplib, but I would just end up with a 708 error from Vimeo and gave up. My solution - switch to streaming uploads. Two changes -
This seems a lot simpler to me, but maybe I'm missing a good reason this is a bad idea.. |
On 2012-09-13 00:15, silvermike wrote:
Thanks for looking into this issue even if I did not answer (I'm a bit
Have you tried on something else than windows if you fix/workaround Marc |
I ran into this problem with the api while trying to upload videos and can reproduce it with vimeo-uploadv2.py
Every video I try to upload fails with a UnicodeDecodeError like:
File "c:\foobar\tools\vimeo\convenience.py", line 111, in upload self._post_to_endpoint(open(file_path)) File "c:\foobar\tools\vimeo\convenience.py", line 94, in _post_to_endpoint headers=headers) File "c:\foobar\tools\vimeo\httplib2wrap\__init__.py", line 34, in request_with_files headers, *args, **kwargs) File "c:\foobar\tools\httplib2\__init__.py", line 1584, in request (response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey) File "c:\foobar\tools\httplib2\__init__.py", line 1332, in _request (response, content) = self._conn_request(conn, request_uri, method, body, headers) File "c:\foobar\tools\httplib2\__init__.py", line 1269, in _conn_request conn.request(method, request_uri, body, headers) File "C:\Python27\lib\httplib.py", line 958, in request self._send_request(method, url, body, headers) File "C:\Python27\lib\httplib.py", line 992, in _send_request self.endheaders(body) File "C:\Python27\lib\httplib.py", line 954, in endheaders self._send_output(message_body) File "C:\Python27\lib\httplib.py", line 812, in _send_output msg += message_body UnicodeDecodeError: 'ascii' codec can't decode byte 0xb2 in position 1280: ordinal not in range(128)
Environment:
*python 2.7.3 64 bit
*Windows 7 64 bit
*httplib2 v0.7.5
I dug up this http://bugs.python.org/issue11898 but the conclusion on there is that it is supposed to work.
Any ideas? I tried a couple hacks in the httplib2 wrapper, but couldn't come up with anything that worked.
The text was updated successfully, but these errors were encountered: