aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/utils.py
diff options
context:
space:
mode:
authorPhilipp Hagemeister <phihag@phihag.de>2015-03-03 00:03:06 +0100
committerPhilipp Hagemeister <phihag@phihag.de>2015-03-03 00:03:06 +0100
commit91410c9bfa9fd8f01fb817474bcc7b0db5cabf95 (patch)
treef945f83ed897b9546e3a82dca31195684781b03d /youtube_dl/utils.py
parenta7440261c52d6518a429210aaae598095112c61b (diff)
[letv] Add --cn-verification-proxy (Closes #5077)
Diffstat (limited to 'youtube_dl/utils.py')
-rw-r--r--youtube_dl/utils.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py
index 1d3401bc2..b568288fa 100644
--- a/youtube_dl/utils.py
+++ b/youtube_dl/utils.py
@@ -1768,3 +1768,13 @@ def match_filter_func(filter_str):
video_title = info_dict.get('title', info_dict.get('id', 'video'))
return '%s does not pass filter %s, skipping ..' % (video_title, filter_str)
return _match_func
+
+
+class PerRequestProxyHandler(compat_urllib_request.ProxyHandler):
+ def proxy_open(self, req, proxy, type):
+ req_proxy = req.headers.get('Ytdl-Request-Proxy')
+ if req_proxy is not None:
+ proxy = req_proxy
+ del req.headers['Ytdl-Request-Proxy']
+ return compat_urllib_request.ProxyHandler.proxy_open(
+ self, req, proxy, type)