youtube-dl返回<urlopen错误[Errno 101]网络无法访问>

时间:2019-11-27 12:50:51

标签: python linux google-compute-engine gcloud youtube-dl

我有一个要运行youtube-dl的Google计算引擎服务器。该服务器位于美国爱荷华州,正在运行debian 9.11

这是返回的调试输出:

youtube-dl -v https://youtu.be/tAfedFkfIiU

[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: [u'-v', u'https://youtu.be/tAfedFkfIiU']
[debug] Encodings: locale UTF-8, fs UTF-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2019.11.22
[debug] Python version 2.7.13 (CPython) - Linux-4.9.0-11-amd64-x86_64-with-debian-9.11
[debug] exe versions: none
[debug] Proxy map: {}
[youtube] tAfedFkfIiU: Downloading webpage
[youtube] tAfedFkfIiU: Downloading video info webpage
[debug] Default format spec: best/bestvideo+bestaudio
[debug] Invoking downloader on u'https://r6---sn-5uaeznkz.googlevideo.com/videoplayback?expire=1574879492&ei=pGzeXZCILYKGigTm34n4DQ&ip=35.209.8.202&id=o-AGcuKL5f7Y7Du-FaWbBZhMaLIsfRZox4FQAYtAj_ujri&itag=22&source=youtube&requiressl=yes&mm=31%2C26&mn=sn-5uaeznkz%2Csn-tt1eln7e&ms=au%2Conr&mv=u&mvi=5&pl=16&mime=video%2Fmp4&ratebypass=yes&dur=1008.047&lmt=1574810711552172&mt=1574857344&fvip=6&fexp=23842630&beids=9466585&c=WEB&txp=5535432&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cmime%2Cratebypass%2Cdur%2Clmt&sig=ALgxI2wwRAIgF6wvUZ9ogFyTSHe6BQib6D9Ib4x8Q4_FDuMP70zbnkgCID5CAhySBvgNYaeH9kwkP-vkecmrngFh7b8NYtnIs8RN&lsparams=mm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl&lsig=AHylml4wRQIhAMn1kcyvqttNBRifOFDTcOYcyGbSttZb4lyxiOq2j0JcAiAwnqjvkIAnBIDPOdjIxlDkZvVHhgqL_kLPj_NQEMyvoA%3D%3D'
ERROR: unable to download video data: <urlopen error [Errno 101] Network is unreachable>
Traceback (most recent call last):
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 1925, in process_info
    success = dl(filename, info_dict)
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 1864, in dl
    return fd.download(name, info)
  File "/usr/local/bin/youtube-dl/youtube_dl/downloader/common.py", line 366, in download
    return self.real_download(filename, info_dict)
  File "/usr/local/bin/youtube-dl/youtube_dl/downloader/http.py", line 341, in real_download
    establish_connection()
  File "/usr/local/bin/youtube-dl/youtube_dl/downloader/http.py", line 109, in establish_connection
    ctx.data = self.ydl.urlopen(request)
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 2237, in urlopen
    return self._opener.open(req, timeout=self._socket_timeout)
  File "/usr/lib/python2.7/urllib2.py", line 429, in open
    response = self._open(req, data)
  File "/usr/lib/python2.7/urllib2.py", line 447, in _open
    '_open', req)
  File "/usr/lib/python2.7/urllib2.py", line 407, in _call_chain
    result = func(*args)
  File "/usr/local/bin/youtube-dl/youtube_dl/utils.py", line 2724, in https_open
    req, **kwargs)
  File "/usr/lib/python2.7/urllib2.py", line 1198, in do_open
    raise URLError(err)
URLError: <urlopen error [Errno 101] Network is unreachable>

我尝试过的事情:

  • 允许通过Google云防火墙的所有网络流量,所有协议类型的入口和出口: firewall rules
  • 卸载了curl和youtube-dl,并使用wget重新安装了youtube-dl
  • Ping youtube.com和google.com会获得良好的响应。
  • 我可以从服务器访问我的私人网页,因此端口肯定可以正常工作,并且可以通过网络访问服务器外部的所有内容。
  • 除此之外,没有出现网络问题。
  • 详细输出中的直接链接会产生“访问被拒绝”错误,但是在本地尝试youtube-dl时,它会返回一个我可以访问的链接,而我的朋友使用另一个IP可以访问,因此youtube-dl是返回不可访问的链接?不确定access denied
  • 我没有发送太多请求进入黑名单,从一开始就没有作用。
  • IP是临时的,每次服务器启动时都会更改(未设置静态外部IP)。
  • 从头开始删除并重新创建服务器实例并不能解决问题。
  • 该库的作者坚持认为这是网络方面的问题,而不是他们在这方面的github问题:https://github.com/ytdl-org/youtube-dl/issues/23213
  • 我认为可能是urllib2.urlopen在gcloud中无法访问,但是我运行了一个小的python脚本来运行该方法,并正确ping google.com。
  • 我无法wget在详细日志输出中提供的直接链接。超时了。这是带有-v的wget和-v的curl的输出日志:

wget:

wget "https://r6---sn-5ualdn7y.googlevideo.com/videoplayback?expire=1575026099&ei=U6ngXd3cDImjtQfFkKHACA&ip=35.209.8.202&id=o-ALJhUmz-vDQxpGilTFwb8v02UpFXo3JFaLZVvTV7BcGV&itag=22&source=youtube&requiressl=yes&mm=31%2C29&mn=sn-5ualdn7y%2Csn-5uaeznrz&ms=au%2Crdu&mv=u&mvi=5&pl=16&mime=video%2Fmp4&ratebypass=yes&dur=634.090&lmt=1574939877997808&mt=1575004312&fvip=2&fexp=23842630&beids=9466587&c=WEB&txp=6531432&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cmime%2Cratebypass%2Cdur%2Clmt&sig=ALgxI2wwRAIgWkUIL8i20_R0aDMs-UQmZq-EbHExzRFoP2ql6wqq3hoCIHKcxV7eU5sfcYxLzzVgJ1LgSoebvlUXnObwqDmzy7ym&lsparams=mm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl&lsig=AHylml4wRgIhANYw5qlL2ITIfsqPs5fveDiJljYvLCb8m4HLtoZDzTWmAiEA59uqA-cPmDAIgKRTYMXbxoegXat81xaZppigC76m7pQ%3D" -v
The name is too long, 708 chars total.
Trying to shorten...
New name is videoplayback?expire=1575026099&ei=U6ngXd3cDImjtQfFkKHACA&ip=35.209.8.202&id=o-ALJhUmz-vDQxpGilTFwb8v02UpFXo3JFaLZVvTV7BcGV&itag=22&source=youtube&requiressl=yes&mm=31%2C29&mn=sn-5ualdn7y%2Csn-5uaeznrz&ms=au%2Crdu&mv=u&mvi=5&pl=16&mime=.
--2019-11-29 05:15:14--  https://r6---sn-5ualdn7y.googlevideo.com/videoplayback?expire=1575026099&ei=U6ngXd3cDImjtQfFkKHACA&ip=35.209.8.202&id=o-ALJhUmz-vDQxpGilTFwb8v02UpFXo3JFaLZVvTV7BcGV&itag=22&source=youtube&requiressl=yes&mm=31%2C29&mn=sn-5ualdn7y%2Csn-5uaeznrz&ms=au%2Crdu&mv=u&mvi=5&pl=16&mime=video%2Fmp4&ratebypass=yes&dur=634.090&lmt=1574939877997808&mt=1575004312&fvip=2&fexp=23842630&beids=9466587&c=WEB&txp=6531432&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cmime%2Cratebypass%2Cdur%2Clmt&sig=ALgxI2wwRAIgWkUIL8i20_R0aDMs-UQmZq-EbHExzRFoP2ql6wqq3hoCIHKcxV7eU5sfcYxLzzVgJ1LgSoebvlUXnObwqDmzy7ym&lsparams=mm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl&lsig=AHylml4wRgIhANYw5qlL2ITIfsqPs5fveDiJljYvLCb8m4HLtoZDzTWmAiEA59uqA-cPmDAIgKRTYMXbxoegXat81xaZppigC76m7pQ%3D
Resolving r6---sn-5ualdn7y.googlevideo.com (r6---sn-5ualdn7y.googlevideo.com)... 173.194.147.204, 2607:f8b0:4002:35::c
Connecting to r6---sn-5ualdn7y.googlevideo.com (r6---sn-5ualdn7y.googlevideo.com)|173.194.147.204|:443... failed: Connection timed out.
Connecting to r6---sn-5ualdn7y.googlevideo.com (r6---sn-5ualdn7y.googlevideo.com)|2607:f8b0:4002:35::c|:443... failed: Network is unreachable.

卷曲:

curl -O -v https://r2---sn-hgn7rn7r.googlevideo.com/videoplayback?expire=1575026099&ei=U6ngXd3cDImjtQfFkKHACA&ip=35.209.8.202&id=o-ALJhUmz-vDQxpGilTFwb8v02UpFXo3JFaLZVvTV7BcGV&itag=22&source=youtube&requiressl=yes&mime=video/mp4&ratebypass=yes&dur=634.090&lmt=1574939877997808&fvip=2&fexp=9466587,23842630&beids=9466587&c=WEB&txp=6531432&sparams=expire,ei,ip,id,itag,source,requiressl,mime,ratebypass,dur,lmt&sig=ALgxI2wwRAIgWkUIL8i20_R0aDMs-UQmZq-EbHExzRFoP2ql6wqq3hoCIHKcxV7eU5sfcYxLzzVgJ1LgSoebvlUXnObwqDmzy7ym&rm=sn-5uakd7d&req_id=db99eec2ba1fa3ee&ipbypass=yes&redirect_counter=2&cm2rm=sn-uxgg5oxu-cxte7l&cms_redirect=yes&mip=213.204.90.117&mm=29&mn=sn-hgn7rn7r&ms=rdu&mt=1575004548&mv=m&mvi=1&pl=24&lsparams=ipbypass,mip,mm,mn,ms,mv,mvi,pl&lsig=AHylml4wRQIgK50gSfkEix6Q7q9n2GTk7GQOn6YEZ1NqiX4l8UwDHhQCIQDT4Q4KoFB6Dck1vQj0FO27LvNA8PMVyNJOaFMcU9yutg==
[1] 3670
[2] 3671
[3] 3672
[4] 3673
[5] 3674
[6] 3675
[7] 3676
[8] 3677
[9] 3678
[10] 3679
[11] 3680
[12] 3681
[13] 3682
[14] 3683
[15] 3684
[16] 3685
[17] 3686
[18] 3687
[19] 3688
[20] 3689
[21] 3690
[22] 3691
[23] 3692
[24] 3693
[25] 3694
[26] 3695
[27] 3696
[28] 3697
[29] 3698
[30] 3699
[31] 3700
[32] 3701
[33] 3702
[2]   Done                    ei=U6ngXd3cDImjtQfFkKHACA
[3]   Done                    ip=35.209.8.202
[4]   Done                    id=o-ALJhUmz-vDQxpGilTFwb8v02UpFXo3JFaLZVvTV7BcGV
[5]   Done                    itag=22
[6]   Done                    source=youtube
[7]   Done                    requiressl=yes
[8]   Done                    mime=video/mp4
[9]   Done                    ratebypass=yes
[10]   Done                    dur=634.090
[11]   Done                    lmt=1574939877997808
[12]   Done                    fvip=2
[13]   Done                    fexp=9466587,23842630
[14]   Done                    beids=9466587
[15]   Done                    c=WEB
[16]   Done                    txp=6531432
[17]   Done                    sparams=expire,ei,ip,id,itag,source,requiressl,mime,ratebypass,dur,lmt
[18]   Done                    sig=ALgxI2wwRAIgWkUIL8i20_R0aDMs-UQmZq-EbHExzRFoP2ql6wqq3hoCIHKcxV7eU5sfcYxLzzVgJ1LgSoebvlUXnObwqDmzy7ym
[19]   Done                    rm=sn-5uakd7d
[20]   Done                    req_id=db99eec2ba1fa3ee
[21]   Done                    ipbypass=yes
[22]   Done                    redirect_counter=2
   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0*   Trying 172.217.130.231...
* TCP_NODELAY set
*   Trying 2a00:1450:4006:9::7...
* TCP_NODELAY set
* Immediate connect fail for 2a00:1450:4006:9::7: Network is unreachable
*   Trying 2a00:1450:4006:9::7...
* TCP_NODELAY set
* Immediate connect fail for 2a00:1450:4006:9::7: Network is unreachable
  0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0*   Trying 2a00:1450:4006:9::7...
* TCP_NODELAY set
* Immediate connect fail for 2a00:1450:4006:9::7: Network is unreachable
  0     0    0     0    0     0      0      0 --:--:--  0:00:02 --:--:--     0*   Trying 2a00:1450:4006:9::7...
* TCP_NODELAY set
* Immediate connect fail for 2a00:1450:4006:9::7: Network is unreachable
  0     0    0     0    0     0      0      0 --:--:--  0:00:03 --:--:--     0*   Trying 2a00:1450:4006:9::7...
* TCP_NODELAY set
* Immediate connect fail for 2a00:1450:4006:9::7: Network is unreachable
  0     0    0     0    0     0      0      0 --:--:--  0:00:04 --:--:--     0*   Trying 2a00:1450:4006:9::7...
* TCP_NODELAY set
* Immediate connect fail for 2a00:1450:4006:9::7: Network is unreachable
  0     0    0     0    0     0      0      0 --:--:--  0:00:05 --:--:--     0*   Trying 2a00:1450:4006:9::7...
* TCP_NODELAY set
* Immediate connect fail for 2a00:1450:4006:9::7: Network is unreachable
  0     0    0     0    0     0      0      0 --:--:--  0:00:06 --:--:--     0*   Trying 2a00:1450:4006:9::7...
* TCP_NODELAY set
* Immediate connect fail for 2a00:1450:4006:9::7: Network is unreachable
  0     0    0     0    0     0      0      0 --:--:--  0:00:07 --:--:--     0*   Trying 2a00:1450:4006:9::7...
(continues)
* Immediate connect fail for 2a00:1450:4006:9::7: Network is unreachable
  0     0    0     0    0     0      0      0 --:--:--  0:02:09 --:--:--     0* connect to 172.217.130.231 port 443 failed: Connection timed out
*   Trying 2a00:1450:4006:9::7...
* TCP_NODELAY set
* Immediate connect fail for 2a00:1450:4006:9::7: Network is unreachable
*   Trying 2a00:1450:4006:9::7...
* TCP_NODELAY set
* Immediate connect fail for 2a00:1450:4006:9::7: Network is unreachable
* Failed to connect to r2---sn-hgn7rn7r.googlevideo.com port 443: Connection timed out
* Closing connection 0
curl: (7) Failed to connect to r2---sn-hgn7rn7r.googlevideo.com port 443: Connection timed out
  • 我尝试了多个youtube网址。几种不同的视频,具有不同的URL格式。
  • 这不是地理障碍问题,该服务器托管在美国爱荷华州。
  • 我尝试将python更新到最新版本(3.5 / 6),结果相同。

老实说,我没有足够的想法来进一步调试它。

编辑:偶尔发生了一些变化,我现在可以从本地浏览器中的详细输出日志访问直接链接,而以前我可能不会这样做。自从这个问题以来,我没有做任何改变。服务器的IP地址是否被阻止?我从未向youtube发送过几条要求将其列入黑名单的速度如此之快。也许它没有被列入黑名单,但我仍然无法确定这是否是防火墙问题。如果是黑名单问题,则curl和wget的详细输出将返回“访问被拒绝”错误。那么这是怎么回事?

0 个答案:

没有答案