[Generic] Also try GET instead of HEAD request if server returns 404
This commit is contained in:
parent
9888db649a
commit
d9f203835e
@ -300,7 +300,7 @@ class GenericIE(InfoExtractor):
|
|||||||
|
|
||||||
class HTTPMethodFallback(compat_urllib_request.BaseHandler):
|
class HTTPMethodFallback(compat_urllib_request.BaseHandler):
|
||||||
"""
|
"""
|
||||||
Fallback to GET if HEAD is not allowed (405 HTTP error)
|
Fallback to GET if HEAD is not allowed (405 or 404 (youtube.com) HTTP error)
|
||||||
"""
|
"""
|
||||||
def http_error_405(self, req, fp, code, msg, headers):
|
def http_error_405(self, req, fp, code, msg, headers):
|
||||||
fp.read()
|
fp.read()
|
||||||
@ -318,6 +318,11 @@ class GenericIE(InfoExtractor):
|
|||||||
origin_req_host=origin_req_host,
|
origin_req_host=origin_req_host,
|
||||||
unverifiable=True))
|
unverifiable=True))
|
||||||
|
|
||||||
|
def http_error_404(self, req, fp, code, msg, headers):
|
||||||
|
# prevent infinite loop
|
||||||
|
if req.get_method() == "HEAD":
|
||||||
|
return self.http_error_405(req, fp, code, msg, headers)
|
||||||
|
|
||||||
# Build our opener
|
# Build our opener
|
||||||
opener = compat_urllib_request.OpenerDirector()
|
opener = compat_urllib_request.OpenerDirector()
|
||||||
for handler in [compat_urllib_request.HTTPHandler, compat_urllib_request.HTTPDefaultErrorHandler,
|
for handler in [compat_urllib_request.HTTPHandler, compat_urllib_request.HTTPDefaultErrorHandler,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user