Homer0815
Homer0815

Reputation: 57

How do fix urlopen error in Python? Use youtube-dl

What to do with this Error:

I can't solve this Problem on MacOs ! Nobody can help me ? On Windows it works nice !

@phihag

youtube-dl -U :

Updating to version 2017.11.15 ... 

openssl version -a:

OpenSSL 1.0.2m  2 Nov 2017
built on: reproducible build, date unspecified
platform: darwin64-x86_64-cc
options:  bn(64,64) rc4(ptr,int) des(idx,cisc,16,int) idea(int) blowfish(idx)
compiler: clang -I. -I.. -I../include  -fPIC -fno-common -DOPENSSL_PIC -DZLIB_SHARED -DZLIB -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -arch x86_64 -O3 -DL_ENDIAN -Wall -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM -DECP_NISTZ256_ASM
OPENSSLDIR: "/usr/local/etc/openssl"



python --version:

Python 2.7.14

python3 --version:

Python 3.6.3 

youtube-dl Command:

youtube-dl -v -u [email protected] -p myPassword -o '~/Development/tutorials/new/%(playlist)s/%(chapter_number)s - %(chapter)s/%(title)s.%(ext)s'  https://www.udemy.com/react-the-complete-guide-incl-redux/learn/v4/content 

Terminal Output:

[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: [u'-v', u'-u', u'PRIVATE', u'-p', u'PRIVATE', u'-o', u'~/Development/tutorials/new/%(playlist)s/%(chapter_number)s - %(chapter)s/%(title)s.%(ext)s', u'https://www.udemy.com/react-the-complete-guide-incl-redux/learn/v4/content']
[debug] Encodings: locale UTF-8, fs utf-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2017.11.15
[debug] Python version 2.7.14 - Darwin-16.7.0-x86_64-i386-64bit
[debug] exe versions: none
[debug] Proxy map: {}
[udemy:course] Downloading login popup



ERROR:

ERROR: Unable to download webpage: <urlopen error [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:661)> (caused by URLError(SSLError(1, u'[SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:661)'),))
  File "/usr/local/bin/youtube-dl/youtube_dl/extractor/common.py", line 506, in _request_webpage
    return self._downloader.urlopen(url_or_request)
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 2196, in urlopen
    return self._opener.open(req, timeout=self._socket_timeout)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 429, in open
    response = self._open(req, data)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 447, in _open
    '_open', req)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 407, in _call_chain
    result = func(*args)
  File "/usr/local/bin/youtube-dl/youtube_dl/utils.py", line 1086, in https_open
    req, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 1198, in do_open
    raise URLError(err)

Upvotes: 1

Views: 3651

Answers (1)

Nathan
Nathan

Reputation: 143

Per phihag's hint, your SSL's version is too old.

If you haven't upgraded python, that's a simple solution. However, since your question is tagged python3 and your debug output is talking about python2, it's possible you're not using the latest SSL cert on your system.

I suspect if you use:

python3 `which youtube-dl` yoururl

then it will work.

Upvotes: 3

Related Questions