diff options
author | James Taylor <28744867+user234683@users.noreply.github.com> | 2020-09-19 11:39:29 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-19 11:39:29 -0700 |
commit | 09e988818240ad552397a868d9ed8e444877a5cb (patch) | |
tree | d4fd5105ce4daf92f1accc1fdc8b074686e1cc59 /youtube | |
parent | 753f6c5389be82f4a17dafb1698e2f65388d35b6 (diff) | |
parent | 3ffe5d0120e0dcf712256d43b470712484a6e04c (diff) | |
download | yt-local-09e988818240ad552397a868d9ed8e444877a5cb.tar.lz yt-local-09e988818240ad552397a868d9ed8e444877a5cb.tar.xz yt-local-09e988818240ad552397a868d9ed8e444877a5cb.zip |
Merge pull request #18 from user938120/tor_port_setting
Add setting to change tor's port
Diffstat (limited to 'youtube')
-rw-r--r-- | youtube/util.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/youtube/util.py b/youtube/util.py index 77c4fb1..89c0669 100644 --- a/youtube/util.py +++ b/youtube/util.py @@ -54,7 +54,7 @@ URL_ORIGIN = "/https://www.youtube.com" connection_pool = urllib3.PoolManager(cert_reqs = 'CERT_REQUIRED') old_tor_connection_pool = None -tor_connection_pool = urllib3.contrib.socks.SOCKSProxyManager('socks5://127.0.0.1:9150/', cert_reqs = 'CERT_REQUIRED') +tor_connection_pool = urllib3.contrib.socks.SOCKSProxyManager('socks5://127.0.0.1:' + str(settings.tor_port) + '/', cert_reqs = 'CERT_REQUIRED') tor_pool_refresh_time = time.monotonic() # prevent problems due to clock changes @@ -74,7 +74,7 @@ def get_pool(use_tor): # Keep a reference for 5 min to avoid it getting garbage collected while sockets still in use old_tor_connection_pool = tor_connection_pool - tor_connection_pool = urllib3.contrib.socks.SOCKSProxyManager('socks5://127.0.0.1:9150/', cert_reqs = 'CERT_REQUIRED') + tor_connection_pool = urllib3.contrib.socks.SOCKSProxyManager('socks5://127.0.0.1:' + str(settings.tor_port) + '/', cert_reqs = 'CERT_REQUIRED') tor_pool_refresh_time = current_time return tor_connection_pool @@ -156,7 +156,7 @@ def fetch_url_response(url, headers=(), timeout=15, data=None, cookie_processor = HTTPAsymmetricCookieProcessor(cookiejar_send=cookiejar_send, cookiejar_receive=cookiejar_receive) if use_tor and settings.route_tor: - opener = urllib.request.build_opener(sockshandler.SocksiPyHandler(socks.PROXY_TYPE_SOCKS5, "127.0.0.1", 9150), cookie_processor) + opener = urllib.request.build_opener(sockshandler.SocksiPyHandler(socks.PROXY_TYPE_SOCKS5, "127.0.0.1", settings.tor_port), cookie_processor) else: opener = urllib.request.build_opener(cookie_processor) |