aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/extractor
diff options
context:
space:
mode:
authorJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>2014-03-17 21:59:21 +0100
committerJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>2014-03-17 21:59:21 +0100
commitecbe1ad2073ffa4b084a69854e000f6e03cba09c (patch)
treeb3b8acc37320e5c0f22c9f233fe9fef0e43487fe /youtube_dl/extractor
parent9d840c43b535be0e70f7f9a35bf5787ffdb7ecf6 (diff)
[generic] Fix access to removed function in python 3.4
The `Request.get_origin_req_host` method was deprecated in 3.3, use the `origin_req_host` property if it's not available, see http://docs.python.org/3.3/library/urllib.request.html#urllib.request.Request.get_origin_req_host.
Diffstat (limited to 'youtube_dl/extractor')
-rw-r--r--youtube_dl/extractor/generic.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/youtube_dl/extractor/generic.py b/youtube_dl/extractor/generic.py
index 71b9c541e..5a4933146 100644
--- a/youtube_dl/extractor/generic.py
+++ b/youtube_dl/extractor/generic.py
@@ -185,9 +185,14 @@ class GenericIE(InfoExtractor):
newurl = newurl.replace(' ', '%20')
newheaders = dict((k,v) for k,v in req.headers.items()
if k.lower() not in ("content-length", "content-type"))
+ try:
+ # This function was deprecated in python 3.3 and removed in 3.4
+ origin_req_host = req.get_origin_req_host()
+ except AttributeError:
+ origin_req_host = req.origin_req_host
return HEADRequest(newurl,
headers=newheaders,
- origin_req_host=req.get_origin_req_host(),
+ origin_req_host=origin_req_host,
unverifiable=True)
else:
raise compat_urllib_error.HTTPError(req.get_full_url(), code, msg, headers, fp)