iKlotho / youtube-upload

Automatically exported from code.google.com/p/youtube-upload
1 stars 0 forks source link

Uploading no longer possible #151

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
= Versions

youtube-upload: 0.7.3
python: 2.7-9.40.1
python-gdata: 2.0.18-1.2

= Describe the steps

At first I got the error as reported in Issue 130 
(https://code.google.com/p/youtube-upload/issues/detail?id=130#c2), so did  
what "timo" said. Then I tried logging in with this "fake email" and uploaded a 
video. That's all working fine.

BUT when I try to upload a vid via this script, this is what I get:

Login to Youtube API: email='ytdlder-0861@pages.plusgoogle.com', 
password='************'
Install pycurl to upload the video using HTTP
Start upload using basic gdata API: test.mp4
Traceback (most recent call last):
  File "./youtube_upload.py", line 519, in <module>
    sys.exit(catch_exceptions(EXIT_CODES, main, sys.argv[1:]))
  File "./youtube_upload.py", line 111, in catch_exceptions
    fun(*args, **kwargs)
  File "./youtube_upload.py", line 516, in main
    run_main(parser, options, args)
  File "./youtube_upload.py", line 449, in run_main
    url = upload_video(youtube, options, video_path, len(args), index)
  File "./youtube_upload.py", line 360, in upload_video
    entry = youtube.upload_video(*args, **kwargs)
  File "./youtube_upload.py", line 203, in upload_video
    return self.service.InsertVideoEntry(video_entry, path)
  File "/usr/lib/python2.7/site-packages/gdata/youtube/service.py", line 659, in InsertVideoEntry
    converter=gdata.youtube.YouTubeVideoEntryFromString)
  File "/usr/lib/python2.7/site-packages/gdata/service.py", line 1236, in Post
    media_source=media_source, converter=converter)
  File "/usr/lib/python2.7/site-packages/gdata/service.py", line 1303, in PostOrPut
    multipart[2]], headers=extra_headers, url_params=url_params)
  File "/usr/lib/python2.7/site-packages/atom/__init__.py", line 93, in optional_warn_function
    return f(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/atom/service.py", line 186, in request
    data=data, headers=all_headers)
  File "/usr/lib/python2.7/site-packages/gdata/auth.py", line 731, in perform_request
    return http_client.request(operation, url, data=data, headers=headers)
  File "/usr/lib/python2.7/site-packages/atom/http.py", line 162, in request
    connection.putheader(header_name, all_headers[header_name])
  File "/usr/lib64/python2.7/httplib.py", line 924, in putheader
    str = '%s: %s' % (header, '\r\n\t'.join(values))
TypeError: sequence item 0: expected string, int found

What's causing this?

Thanks in advance!

Original issue reported on code.google.com by ytdlder-...@pages.plusgoogle.com on 5 Jun 2014 at 3:02

GoogleCodeExporter commented 9 years ago
I have no idea why is this. In my Python 2.7.5 I don't see that line in 
httplib.py, it seems they have refactored it. If you know some python you can 
try to debug it to see what values contains?

Original comment by tokland on 6 Jun 2014 at 1:50

GoogleCodeExporter commented 9 years ago
Ok, so this is the function:

def putheader(self, header, *values):
    if self.__state != _CS_REQ_STARTED:
        raise CannotSendHeader()
    str = '%s: %s' % (header, '\r\n\t'.join(values))
    self._output(str)

I then printed out the "values":
('identity',)
('www.google.com',)
('140',)
('application/x-www-form-urlencoded',)
Install pycurl to upload the video using HTTP
Start upload using basic gdata API: test.mp4
('gdata.youtube.com',)
('Python-urllib/1.17',)
('identity',)
('uploads.gdata.youtube.com',)
(1,)

So yeah, the last entry is in fact an INT. So I added the following for a 
quick'n'dirty fix:
values = tuple(str(v) for v in values)

This seems to work as it starts to upload. But... it never seems to finish. 
I'll try it a view more times; could be my internet (Fr. afternoon).

So, as I don't really wanna keep my code in the original Python code itself^^: 
is there anything you/I can add in your script?

Thanks!

Original comment by ytdl...@gmail.com on 6 Jun 2014 at 6:24

GoogleCodeExporter commented 9 years ago
This integer in "(1,)" is causing the problem. Total hack, try: 

str = '%s: %s' % (header, '\r\n\t'.join(map(str, values)))

Original comment by tokland on 6 Jun 2014 at 6:34

GoogleCodeExporter commented 9 years ago
This alone doesn't work, because "they" are using the function name for the 
variable "str":
UnboundLocalError: local variable 'str' referenced before assignment

But if I change it to this, it works:
str1 = '%s: %s' % (header, '\r\n\t'.join(map(str, values)))
self._output(str1)

Thanks, I can now upload again!

I have to say, great support and fast response time :-)

Original comment by ytdl...@gmail.com on 6 Jun 2014 at 6:49

GoogleCodeExporter commented 9 years ago
Oh, overshadowing a builtin with a variable name in a core module, naughty 
python devs  :)

Glad it worked! this should help people having the same problems. 

Original comment by tokland on 6 Jun 2014 at 7:22