FlowerWrong / tun2socks

Redirect tun flow to socks 5 in golang, support tcp and udp.
420 stars 108 forks source link

you-get not work #23

Closed FlowerWrong closed 6 years ago

FlowerWrong commented 6 years ago

you-get -d -i 'https://www.youtube.com/watch?v=LvqGEOOlUf8&list=PLYcon0_LG98DbMQPHN1ii_wUSJgpG1mOw'

will be blocked, surge worked well.

FlowerWrong commented 6 years ago
you-get -d -i 'https://www.youtube.com/watch?v=LvqGEOOlUf8&list=PLYcon0_LG98DbMQPHN1ii_wUSJgpG1mOw'
[DEBUG] get_content: https://www.youtube.com/get_video_info?video_id=LvqGEOOlUf8
you-get: version 0.4.1040, a tiny downloader that scrapes the web.
you-get: Namespace(URL=['https://www.youtube.com/watch?v=LvqGEOOlUf8&list=PLYcon0_LG98DbMQPHN1ii_wUSJgpG1mOw'], auto_rename=False, cookies=None, debug=True, extractor_proxy=None, force=False, format=None, help=False, http_proxy=None, info=True, input_file=None, itag=None, json=False, no_caption=False, no_merge=False, no_proxy=False, output_dir='.', output_filename=None, password=None, player=None, playlist=False, socks_proxy=None, stream=None, timeout=600, url=False, version=False)
Traceback (most recent call last):
  File "/usr/local/bin/you-get", line 11, in <module>
    load_entry_point('you-get==0.4.1040', 'console_scripts', 'you-get')()
  File "/usr/local/Cellar/you-get/0.4.1040_1/libexec/lib/python3.6/site-packages/you_get/__main__.py", line 92, in main
    main(**kwargs)
  File "/usr/local/Cellar/you-get/0.4.1040_1/libexec/lib/python3.6/site-packages/you_get/common.py", line 1617, in main
    script_main(any_download, any_download_playlist, **kwargs)
  File "/usr/local/Cellar/you-get/0.4.1040_1/libexec/lib/python3.6/site-packages/you_get/common.py", line 1506, in script_main
    **extra
  File "/usr/local/Cellar/you-get/0.4.1040_1/libexec/lib/python3.6/site-packages/you_get/common.py", line 1241, in download_main
    download(url, **kwargs)
  File "/usr/local/Cellar/you-get/0.4.1040_1/libexec/lib/python3.6/site-packages/you_get/common.py", line 1608, in any_download
    m.download(url, **kwargs)
  File "/usr/local/Cellar/you-get/0.4.1040_1/libexec/lib/python3.6/site-packages/you_get/extractor.py", line 46, in download_by_url
    self.prepare(**kwargs)
  File "/usr/local/Cellar/you-get/0.4.1040_1/libexec/lib/python3.6/site-packages/you_get/extractors/youtube.py", line 143, in prepare
    video_info = parse.parse_qs(get_content('https://www.youtube.com/get_video_info?video_id={}'.format(self.vid)))
  File "/usr/local/Cellar/you-get/0.4.1040_1/libexec/lib/python3.6/site-packages/you_get/common.py", line 416, in get_content
    data = response.read()
  File "/usr/local/opt/python/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 459, in read
    s = self.fp.read()
  File "/usr/local/opt/python/Frameworks/Python.framework/Versions/3.6/lib/python3.6/socket.py", line 586, in readinto
    return self._sock.recv_into(b)
  File "/usr/local/opt/python/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 1009, in recv_into
    return self.read(nbytes, buffer)
  File "/usr/local/opt/python/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 871, in read
    return self._sslobj.read(len, buffer)
  File "/usr/local/opt/python/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 631, in read
    v = self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out
FlowerWrong commented 6 years ago

pip3 install PySocks

#!/usr/bin/env python

import socks
import socket
import urllib.request

socks.set_default_proxy(socks.SOCKS5, "localhost", 6153)
socket.socket = socks.socksocket

response=urllib.request.urlopen('https://www.youtube.com/watch?v=jNQXAC9IVRw', timeout=10)
html=response.read()
print(html)
FlowerWrong commented 6 years ago
    logging.debug('get_content: %s' % url)

    # add default header to fix socket.timeout: The read operation timed out
    if len(headers) == 0:
        headers = fake_headers

    req = request.Request(url, headers=headers)

https://github.com/soimort/you-get/blob/develop/src/you_get/common.py#L409