Skip to content
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

ERROR: 'ascii' codec can't encode character u'\xf1' in position 47: ordinal not in range(128) #669

Closed
jherazob opened this issue Feb 5, 2013 · 6 comments

Comments

@jherazob
Copy link

@jherazob jherazob commented Feb 5, 2013

The video URL was this one, which has a title of:

[ESP] "Infinity the Game" Video Tutorial Reglas 1/3 - Órdenes

youtube-dl doesn't like this title at all, and just bails out when told to download it.

I have no idea why this particular one breaks it when yesterday it could easily handle one with the title in japanese, but there it is.

@phihag
Copy link
Contributor

@phihag phihag commented Feb 5, 2013

Thank you for reporting. As a stopgap measure, you can pass in --restrict-filenames, but that will mangle the filename. Can you post the output of

youtube-dl -t fMqk0rlM2Nc -v

on your system? And what operating system are you using?

@jherazob
Copy link
Author

@jherazob jherazob commented Feb 5, 2013

Ah, sorry, should have done this in the first place :)

It's stock Ubuntu 12.04 LTS. Here's the verbose output:

[debug] youtube-dl version 2013.02.02
[debug] Python version 2.7.3 - Linux-3.2.0-37-generic-pae-i686-with-Ubuntu-12.04-precise
[debug] Proxy map: {}
[youtube] Setting language
[youtube] fMqk0rlM2Nc: Downloading video webpage
[youtube] fMqk0rlM2Nc: Downloading video info webpage
[youtube] fMqk0rlM2Nc: Extracting video information
[youtube] fMqk0rlM2Nc: Downloading video subtitles
ERROR: 'ascii' codec can't encode character u'\xf1' in position 47: ordinal not in range(128)
Traceback (most recent call last):
  File "/home/jherazob/bin/youtube-dl/youtube_dl/FileDownloader.py", line 505, in download
    videos = ie.extract(url)
  File "/home/jherazob/bin/youtube-dl/youtube_dl/InfoExtractors.py", line 93, in extract
    return self._real_extract(url)
  File "/home/jherazob/bin/youtube-dl/youtube_dl/InfoExtractors.py", line 463, in _real_extract
    (srt_error, video_subtitles) = self._extract_subtitles(video_id)
  File "/home/jherazob/bin/youtube-dl/youtube_dl/InfoExtractors.py", line 269, in _extract_subtitles
    srt_xml = compat_urllib_request.urlopen(request).read().decode('utf-8')
  File "/usr/lib/python2.7/urllib2.py", line 126, in urlopen
    return _opener.open(url, data, timeout)
  File "/usr/lib/python2.7/urllib2.py", line 400, in open
    response = self._open(req, data)
  File "/usr/lib/python2.7/urllib2.py", line 418, in _open
    '_open', req)
  File "/usr/lib/python2.7/urllib2.py", line 378, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.7/urllib2.py", line 1207, in http_open
    return self.do_open(httplib.HTTPConnection, req)
  File "/usr/lib/python2.7/urllib2.py", line 1174, in do_open
    h.request(req.get_method(), req.get_selector(), req.data, headers)
  File "/usr/lib/python2.7/httplib.py", line 958, in request
    self._send_request(method, url, body, headers)
  File "/usr/lib/python2.7/httplib.py", line 992, in _send_request
    self.endheaders(body)
  File "/usr/lib/python2.7/httplib.py", line 954, in endheaders
    self._send_output(message_body)
  File "/usr/lib/python2.7/httplib.py", line 814, in _send_output
    self.send(msg)
  File "/usr/lib/python2.7/httplib.py", line 790, in send
    self.sock.sendall(data)
  File "/usr/lib/python2.7/socket.py", line 224, in meth
    return getattr(self._sock,name)(*args)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xf1' in position 47: ordinal not in range(128)

@phihag phihag closed this in fb778e6 Feb 5, 2013
@phihag
Copy link
Contributor

@phihag phihag commented Feb 5, 2013

Oh, that explains a lot .. you're passing in --write-srt, aren't you? Thanks again, fixed in git.

@jherazob
Copy link
Author

@jherazob jherazob commented Feb 5, 2013

Yes, i was, i aliased youtube-dl to have the default options i most use, like "-t" "-i", "-c" and so on, and included "--write-srt" since i discovered it. Should have tested it more :)

@AjayKumarBasuthkar
Copy link

@AjayKumarBasuthkar AjayKumarBasuthkar commented Mar 9, 2014

Here is preliminary info:
[debug] System config: []
[debug] User config: []
[debug] Command-line args: ['-v']
[debug] Encodings: locale 'UTF-8', fs 'UTF-8', out 'UTF-8', pref: 'UTF-8'
[debug] youtube-dl version 2014.03.07.1
[debug] Python version 2.7.3 - Linux-3.2.0-58-generic-pae-i686-with-Ubuntu-12.04-precise
[debug] Proxy map: {}

The command with options &/ arguments is:
sudo youtube-dl --restrict-filenames -t "​http://www.youtube.com/watch?v=k8NpaG0cAGo"

The error & log we see is:
WARNING: The url doesn't specify the protocol, trying with http
[generic] watch?v=k8NpaG0cAGo: Requesting header
Traceback (most recent call last):
File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
"main", fname, loader, pkg_name)
File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/usr/bin/youtube-dl/main.py", line 18, in
File "/usr/bin/youtube-dl/youtube_dl/init.py", line 810, in main

File "/usr/bin/youtube-dl/youtube_dl/init.py", line 800, in _real_main

File "/usr/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 992, in download
File "/usr/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 517, in extract_info
File "/usr/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 553, in process_ie_result
File "/usr/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 500, in extract_info
File "/usr/bin/youtube-dl/youtube_dl/extractor/common.py", line 162, in extract
File "/usr/bin/youtube-dl/youtube_dl/extractor/generic.py", line 236, in _real_extract
File "/usr/bin/youtube-dl/youtube_dl/extractor/generic.py", line 191, in _send_head
File "/usr/lib/python2.7/urllib2.py", line 400, in open
response = self._open(req, data)
File "/usr/lib/python2.7/urllib2.py", line 418, in _open
'_open', req)
File "/usr/lib/python2.7/urllib2.py", line 378, in _call_chain
result = func(*args)
File "/usr/lib/python2.7/urllib2.py", line 1207, in http_open
return self.do_open(httplib.HTTPConnection, req)
File "/usr/lib/python2.7/urllib2.py", line 1174, in do_open
h.request(req.get_method(), req.get_selector(), req.data, headers)
File "/usr/lib/python2.7/httplib.py", line 958, in request
self._send_request(method, url, body, headers)
File "/usr/lib/python2.7/httplib.py", line 991, in _send_request
self.putheader(hdr, value)
File "/usr/lib/python2.7/httplib.py", line 938, in putheader
hdr = '%s: %s' % (header, '\r\n\t'.join([str(v) for v in values]))
UnicodeEncodeError: 'ascii' codec can't encode character u'\u200b' in position 0: ordinal not in range(128)

This worked, I have downloaded the video, thanks a tone youtube-dl team 👍
sudo youtube-dl --restrict-filenames -t k8NpaG0cAGo -v

@jaimeMF
Copy link
Collaborator

@jaimeMF jaimeMF commented Mar 9, 2014

@AjayKumarBasuthkar you were passing an aditional character (invisible) in the url:

$ youtube-dl --restrict-filenames -t "http://www.youtube.com/watch?v=k8NpaG0cAGo"
[debug] System config: []
[debug] User config: ['--keep-video', '--write-info-json', '--write-thumbnail', '--verbose']
[debug] Command-line args: ['--restrict-filenames', '-t', '\u200bhttp://www.youtube.com/watch?v=k8NpaG0cAGo']

It's not the same problem.
And don't run youtube-dl as sudo!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.