ytdl-org / youtube-dl

Command-line program to download videos from YouTube.com and other video sites
http://ytdl-org.github.io/youtube-dl/
The Unlicense
132.36k stars 10.04k forks source link

Youtube download error - <urlopen error [Errno 22] Invalid argument> #14916

Open keefetang opened 6 years ago

keefetang commented 6 years ago

Please follow the guide below


Make sure you are using the latest version: run youtube-dl --version and ensure your version is 2017.12.02. If it's not, read this FAQ entry and update. Issues with outdated version will be rejected.

Before submitting an issue make sure you have:

What is the purpose of your issue?


[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: [u'https://www.youtube.com/watch?v=ejPe2eYhjR4', u'-v']
[debug] Encodings: locale UTF-8, fs utf-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2017.12.02
[debug] Python version 2.7.14 - Darwin-17.2.0-x86_64-i386-64bit
[debug] exe versions: ffmpeg 3.4, ffprobe 3.4
[debug] Proxy map: {}
[youtube] ejPe2eYhjR4: Downloading webpage
[youtube] ejPe2eYhjR4: Downloading video info webpage
[youtube] ejPe2eYhjR4: Extracting video information
[youtube] ejPe2eYhjR4: Downloading MPD manifest
[debug] Default format spec: bestvideo+bestaudio/best
[debug] Invoking downloader on u'https://r1---sn-nu5gi0c-npok.googlevideo.com/videoplayback?id=7a33ded9e6218d1e&itag=137&source=youtube&requiressl=yes&ei=V0knWt3fBIbsowOg1IfgCg&mn=sn-nu5gi0c-npok&mm=31&ms=au&mv=u&pl=43&ratebypass=yes&mime=video/mp4&gir=yes&clen=92139427&lmt=1512416704858018&dur=195.153&signature=32
9F0B18B27DB4AA9F6F9C8BF58835F8984356C8.FBE391BCB4F0C2A7BEDF79D7635AAD71E92886&mt=1512523703&key=dg_yt0&ip=2406:3000:11:1022:9d80:1845:6e37:751d&ipbits=0&expire=1512545719&sparams=ip,ipbits,expire,id,itag,source,requiressl,ei,mn,mm,ms,mv,pl,ratebypass,mime,gir,clen,lmt,dur'
ERROR: unable to download video data: <urlopen error [Errno 22] Invalid argument>
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/youtube_dl/YoutubeDL.py", line 1887, in process_info
    partial_success = dl(fname, new_info)
  File "/usr/local/lib/python2.7/site-packages/youtube_dl/YoutubeDL.py", line 1832, in dl
    return fd.download(name, info)
  File "/usr/local/lib/python2.7/site-packages/youtube_dl/downloader/common.py", line 361, in download
    return self.real_download(filename, info_dict)
  File "/usr/local/lib/python2.7/site-packages/youtube_dl/downloader/http.py", line 286, in real_download
    establish_connection()
  File "/usr/local/lib/python2.7/site-packages/youtube_dl/downloader/http.py", line 74, in establish_connection
    ctx.data = self.ydl.urlopen(request)
  File "/usr/local/lib/python2.7/site-packages/youtube_dl/YoutubeDL.py", line 2196, in urlopen
    return self._opener.open(req, timeout=self._socket_timeout)
  File "/usr/local/Cellar/python/2.7.14/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 429, in open
    response = self._open(req, data)
  File "/usr/local/Cellar/python/2.7.14/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 447, in _open
    '_open', req)
  File "/usr/local/Cellar/python/2.7.14/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 407, in _call_chain
    result = func(*args)
  File "/usr/local/lib/python2.7/site-packages/youtube_dl/utils.py", line 1086, in https_open
    req, **kwargs)
  File "/usr/local/Cellar/python/2.7.14/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 1198, in do_open
    raise URLError(err)
URLError: <urlopen error [Errno 22] Invalid argument>

For completeness, I tested the URL with curl

$ curl -svo v "https://r1---sn-nu5gi0c-npok.googlevideo.com/videoplayback?id=7a33ded9e6218d1e&itag=137&source=youtube&requiressl=yes&ei=V0knWt3fBIbsowOg1IfgCg&mn=sn-nu5gi0c-npok&mm=31&ms=au&mv=u&pl=43&ratebypass=yes&mime=video/mp4&gir=yes&clen=92139427&lmt=1512416704858018&dur=195.153&signature=329F0B18B27DB4AA9F6F9C8BF58835F8984356C8.FBE391BCB4F0C2A7BEDF79D7635AAD71E92886&mt=1512523703&key=dg_yt0&ip=2406:3000:11:1022:9d80:1845:6e37:751d&ipbits=0&expire=1512545719&sparams=ip,ipbits,expire,id,itag,source,requiressl,ei,mn,mm,ms,mv,pl,ratebypass,mime,gir,clen,lmt,dur"
*   Trying 2406:3001:22:1::c...
* TCP_NODELAY set
*   Trying 203.116.189.12...
* TCP_NODELAY set
* Connected to r1---sn-nu5gi0c-npok.googlevideo.com (203.116.189.12) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
*   CAfile: /usr/local/etc/openssl/cert.pem
  CApath: /usr/local/etc/openssl/certs
* TLSv1.2 (OUT), TLS header, Certificate Status (22):
} [5 bytes data]
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
} [512 bytes data]
* TLSv1.2 (IN), TLS handshake, Server hello (2):
{ [87 bytes data]
* TLSv1.2 (IN), TLS handshake, Certificate (11):
{ [3297 bytes data]
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
{ [333 bytes data]
* TLSv1.2 (IN), TLS handshake, Server finished (14):
{ [4 bytes data]
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
} [70 bytes data]
* TLSv1.2 (OUT), TLS change cipher, Client hello (1):
} [1 bytes data]
* TLSv1.2 (OUT), TLS handshake, Finished (20):
} [16 bytes data]
* TLSv1.2 (IN), TLS change cipher, Client hello (1):
{ [1 bytes data]
* TLSv1.2 (IN), TLS handshake, Finished (20):
{ [16 bytes data]
* SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
* ALPN, server did not agree to a protocol
* Server certificate:
*  subject: C=US; ST=California; L=Mountain View; O=Google Inc; CN=*.googlevideo.com
*  start date: Nov 16 20:14:00 2017 GMT
*  expire date: Feb  8 20:14:00 2018 GMT
*  subjectAltName: host "r1---sn-nu5gi0c-npok.googlevideo.com" matched cert's "*.googlevideo.com"
*  issuer: C=US; O=Google Inc; CN=Google Internet Authority G2
*  SSL certificate verify ok.
} [5 bytes data]
> GET /videoplayback?id=7a33ded9e6218d1e&itag=137&source=youtube&requiressl=yes&ei=V0knWt3fBIbsowOg1IfgCg&mn=sn-nu5gi0c-npok&mm=31&ms=au&mv=u&pl=43&ratebypass=yes&mime=video/mp4&gir=yes&clen=92139427&lmt=1512416704858018&dur=195.153&signature=329F0B18B27DB4AA9F6F9C8BF58835F8984356C8.FBE391BCB4F0C2A7BEDF79D7635AAD71E92886&mt=1512523703&key=dg_yt0&ip=2406:3000:11:1022:9d80:1845:6e37:751d&ipbits=0&expire=1512545719&sparams=ip,ipbits,expire,id,itag,source,requiressl,ei,mn,mm,ms,mv,pl,ratebypass,mime,gir,clen,lmt,dur HTTP/1.1
> Host: r1---sn-nu5gi0c-npok.googlevideo.com
> User-Agent: curl/7.57.0
> Accept: */*
>
{ [5 bytes data]
< HTTP/1.1 200 OK
< Last-Modified: Mon, 04 Dec 2017 19:45:04 GMT
< Content-Type: video/mp4
< Date: Wed, 06 Dec 2017 01:36:30 GMT
< Expires: Wed, 06 Dec 2017 01:36:30 GMT
< Cache-Control: private, max-age=21229
< Accept-Ranges: bytes
< Content-Length: 92139427
< Connection: close
< Alt-Svc: hq=":443"; ma=2592000; quic=51303431; quic=51303339; quic=51303338; quic=51303337; quic=51303335,quic=":443"; ma=2592000; v="41,39,38,37,35"
< X-Content-Type-Options: nosniff
< Server: gvs 1.0
<
{ [5 bytes data]
* Closing connection 0
} [5 bytes data]
* TLSv1.2 (OUT), TLS alert, Client hello (1):
} [2 bytes data]

I might be wrong, but I can't see any illegal characters that might cause the URL parsing to fail.

$ printf %s "https://r1---sn-nu5gi0c-npok.googlevideo.com/videoplayback?id=7a33ded9e6218d1e&itag=137&source=youtube&requiressl=yes&ei=V0knWt3fBIbsowOg1IfgCg&mn=sn-nu5gi0c-npok&mm=31&ms=au&mv=u&pl=43&ratebypass=yes&mime=video/mp4&gir=yes&clen=92139427&lmt=1512416704858018&dur=195.153&signature=329F0B18B27DB4AA9F6F9C8BF58835F8984356C8.FBE391BCB4F0C2A7BEDF79D7635AAD71E92886&mt=1512523703&key=dg_yt0&ip=2406:3000:11:1022:9d80:1845:6e37:751d&ipbits=0&expire=1512545719&sparams=ip,ipbits,expire,id,itag,source,requiressl,ei,mn,mm,ms,mv,pl,ratebypass,mime,gir,clen,lmt,dur" | xxd
00000000: 6874 7470 733a 2f2f 7231 2d2d 2d73 6e2d  https://r1---sn-
00000010: 6e75 3567 6930 632d 6e70 6f6b 2e67 6f6f  nu5gi0c-npok.goo
00000020: 676c 6576 6964 656f 2e63 6f6d 2f76 6964  glevideo.com/vid
00000030: 656f 706c 6179 6261 636b 3f69 643d 3761  eoplayback?id=7a
00000040: 3333 6465 6439 6536 3231 3864 3165 2669  33ded9e6218d1e&i
00000050: 7461 673d 3133 3726 736f 7572 6365 3d79  tag=137&source=y
00000060: 6f75 7475 6265 2672 6571 7569 7265 7373  outube&requiress
00000070: 6c3d 7965 7326 6569 3d56 306b 6e57 7433  l=yes&ei=V0knWt3
00000080: 6642 4962 736f 774f 6731 4966 6743 6726  fBIbsowOg1IfgCg&
00000090: 6d6e 3d73 6e2d 6e75 3567 6930 632d 6e70  mn=sn-nu5gi0c-np
000000a0: 6f6b 266d 6d3d 3331 266d 733d 6175 266d  ok&mm=31&ms=au&m
000000b0: 763d 7526 706c 3d34 3326 7261 7465 6279  v=u&pl=43&rateby
000000c0: 7061 7373 3d79 6573 266d 696d 653d 7669  pass=yes&mime=vi
000000d0: 6465 6f2f 6d70 3426 6769 723d 7965 7326  deo/mp4&gir=yes&
000000e0: 636c 656e 3d39 3231 3339 3432 3726 6c6d  clen=92139427&lm
000000f0: 743d 3135 3132 3431 3637 3034 3835 3830  t=15124167048580
00000100: 3138 2664 7572 3d31 3935 2e31 3533 2673  18&dur=195.153&s
00000110: 6967 6e61 7475 7265 3d33 3239 4630 4231  ignature=329F0B1
00000120: 3842 3237 4442 3441 4139 4636 4639 4338  8B27DB4AA9F6F9C8
00000130: 4246 3538 3833 3546 3839 3834 3335 3643  BF58835F8984356C
00000140: 382e 4642 4533 3931 4243 4234 4630 4332  8.FBE391BCB4F0C2
00000150: 4137 4245 4446 3739 4437 3633 3541 4144  A7BEDF79D7635AAD
00000160: 3731 4539 3238 3836 266d 743d 3135 3132  71E92886&mt=1512
00000170: 3532 3337 3033 266b 6579 3d64 675f 7974  523703&key=dg_yt
00000180: 3026 6970 3d32 3430 363a 3330 3030 3a31  0&ip=2406:3000:1
00000190: 313a 3130 3232 3a39 6438 303a 3138 3435  1:1022:9d80:1845
000001a0: 3a36 6533 373a 3735 3164 2669 7062 6974  :6e37:751d&ipbit
000001b0: 733d 3026 6578 7069 7265 3d31 3531 3235  s=0&expire=15125
000001c0: 3435 3731 3926 7370 6172 616d 733d 6970  45719&sparams=ip
000001d0: 2c69 7062 6974 732c 6578 7069 7265 2c69  ,ipbits,expire,i
000001e0: 642c 6974 6167 2c73 6f75 7263 652c 7265  d,itag,source,re
000001f0: 7175 6972 6573 736c 2c65 692c 6d6e 2c6d  quiressl,ei,mn,m
00000200: 6d2c 6d73 2c6d 762c 706c 2c72 6174 6562  m,ms,mv,pl,rateb
00000210: 7970 6173 732c 6d69 6d65 2c67 6972 2c63  ypass,mime,gir,c
00000220: 6c65 6e2c 6c6d 742c 6475 72              len,lmt,dur
keefetang commented 6 years ago

Tested on Python 3 with the same result. Are you still unable to reproduce @dstftw?

$ youtube-dl https://www.youtube.com/watch?v=ejPe2eYhjR4 -vvvv
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['https://www.youtube.com/watch?v=ejPe2eYhjR4', '-vvvv']
[debug] Encodings: locale UTF-8, fs utf-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2018.03.26.1
[debug] Python version 3.6.5 (CPython) - Darwin-17.5.0-x86_64-i386-64bit
[debug] exe versions: ffmpeg 3.4.2, ffprobe 3.4.2
[debug] Proxy map: {}
[youtube] ejPe2eYhjR4: Downloading webpage
[youtube] ejPe2eYhjR4: Downloading video info webpage
[youtube] ejPe2eYhjR4: Extracting video information
[debug] Default format spec: bestvideo+bestaudio/best
WARNING: Requested formats are incompatible for merge and will be merged into mkv.
[debug] Invoking downloader on 'https://r1---sn-nu5gi0c-npok.googlevideo.com/videoplayback?pl=24&mv=m&ipbits=0&ms=au%2Crdu&ei=8HXBWpvJComuoQPkh5rYBQ&ip=203.116.199.193&mt=1522627956&keepalive=yes&expire=1522649680&mm=31%2C29&id=o-ANZVTMu57syoEdsOSXtXBFO3K4OaXDMWdhMMLbz42zLx&itag=137&signature=7569BDC0283A55E908F137772B43224A5AB5C10B.A9AA44E6CD05218BC3EE1E2ED493EA53B6277F5B&sparams=aitags%2Cclen%2Cdur%2Cei%2Cgir%2Cid%2Cinitcwndbps%2Cip%2Cipbits%2Citag%2Ckeepalive%2Clmt%2Cmime%2Cmm%2Cmn%2Cms%2Cmv%2Cpcm2cms%2Cpl%2Crequiressl%2Csource%2Cexpire&initcwndbps=615000&source=youtube&mn=sn-nu5gi0c-npok%2Csn-npoeen7k&requiressl=yes&key=yt6&mime=video%2Fmp4&gir=yes&clen=45071774&pcm2cms=yes&c=WEB&fvip=3&lmt=1512626407581155&dur=195.153&aitags=133%2C134%2C135%2C136%2C137%2C160%2C242%2C243%2C244%2C247%2C248%2C278&ratebypass=yes'
ERROR: unable to download video data: <urlopen error [Errno 22] Invalid argument>
Traceback (most recent call last):
  File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 1318, in do_open
    encode_chunked=req.has_header('Transfer-encoding'))
  File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1239, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1285, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1234, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1026, in _send_output
    self.send(msg)
  File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 964, in send
    self.connect()
  File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1392, in connect
    super().connect()
  File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 937, in connect
    self.sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
OSError: [Errno 22] Invalid argument

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/youtube_dl/YoutubeDL.py", line 1890, in process_info
    partial_success = dl(fname, new_info)
  File "/usr/local/lib/python3.6/site-packages/youtube_dl/YoutubeDL.py", line 1835, in dl
    return fd.download(name, info)
  File "/usr/local/lib/python3.6/site-packages/youtube_dl/downloader/common.py", line 365, in download
    return self.real_download(filename, info_dict)
  File "/usr/local/lib/python3.6/site-packages/youtube_dl/downloader/http.py", line 340, in real_download
    establish_connection()
  File "/usr/local/lib/python3.6/site-packages/youtube_dl/downloader/http.py", line 109, in establish_connection
    ctx.data = self.ydl.urlopen(request)
  File "/usr/local/lib/python3.6/site-packages/youtube_dl/YoutubeDL.py", line 2199, in urlopen
    return self._opener.open(req, timeout=self._socket_timeout)
  File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 526, in open
    response = self._open(req, data)
  File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 544, in _open
    '_open', req)
  File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 504, in _call_chain
    result = func(*args)
  File "/usr/local/lib/python3.6/site-packages/youtube_dl/utils.py", line 1101, in https_open
    req, **kwargs)
  File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 1320, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [Errno 22] Invalid argument>