mirror of
https://github.com/l1ving/youtube-dl
synced 2025-03-14 07:37:25 +08:00
[Generic] Also try GET instead of HEAD request if server returns 404
This commit is contained in:
parent
5e011e1505
commit
6dde141a47
@ -300,7 +300,7 @@ class GenericIE(InfoExtractor):
|
||||
|
||||
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):
|
||||
fp.read()
|
||||
@ -318,6 +318,11 @@ class GenericIE(InfoExtractor):
|
||||
origin_req_host=origin_req_host,
|
||||
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
|
||||
opener = compat_urllib_request.OpenerDirector()
|
||||
for handler in [compat_urllib_request.HTTPHandler, compat_urllib_request.HTTPDefaultErrorHandler,
|
||||
|
Loading…
x
Reference in New Issue
Block a user