mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-19 13:27:27 +01:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
b7f89fe692
@ -166,7 +166,12 @@ def _real_extract(self, url):
|
|||||||
if video_url.startswith('//'):
|
if video_url.startswith('//'):
|
||||||
video_url = compat_urllib_parse_urlparse(url).scheme + ':' + video_url
|
video_url = compat_urllib_parse_urlparse(url).scheme + ':' + video_url
|
||||||
if '://' not in video_url:
|
if '://' not in video_url:
|
||||||
video_url = url + ('' if url.endswith('/') else '/') + video_url
|
up = compat_urllib_parse_urlparse(url)
|
||||||
|
if video_url.startswith('/'):
|
||||||
|
video_url = up.scheme + '://' + up.netloc + video_url
|
||||||
|
else: # relative path
|
||||||
|
video_url = (up.scheme + '://' + up.netloc +
|
||||||
|
up.path.rpartition('/')[0] + '/' + video_url)
|
||||||
video_id = os.path.basename(video_url)
|
video_id = os.path.basename(video_url)
|
||||||
|
|
||||||
# here's a fun little line of code for you:
|
# here's a fun little line of code for you:
|
||||||
|
@ -628,8 +628,23 @@ def http_response(self, req, resp):
|
|||||||
old_resp = resp
|
old_resp = resp
|
||||||
# gzip
|
# gzip
|
||||||
if resp.headers.get('Content-encoding', '') == 'gzip':
|
if resp.headers.get('Content-encoding', '') == 'gzip':
|
||||||
gz = gzip.GzipFile(fileobj=io.BytesIO(resp.read()), mode='r')
|
content = resp.read()
|
||||||
resp = self.addinfourl_wrapper(gz, old_resp.headers, old_resp.url, old_resp.code)
|
gz = gzip.GzipFile(fileobj=io.BytesIO(content), mode='rb')
|
||||||
|
try:
|
||||||
|
uncompressed = io.BytesIO(gz.read())
|
||||||
|
except IOError as original_ioerror:
|
||||||
|
# There may be junk add the end of the file
|
||||||
|
# See http://stackoverflow.com/q/4928560/35070 for details
|
||||||
|
for i in range(1, 1024):
|
||||||
|
try:
|
||||||
|
gz = gzip.GzipFile(fileobj=io.BytesIO(content[:-i]), mode='rb')
|
||||||
|
uncompressed = io.BytesIO(gz.read())
|
||||||
|
except IOError:
|
||||||
|
continue
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
raise original_ioerror
|
||||||
|
resp = self.addinfourl_wrapper(uncompressed, old_resp.headers, old_resp.url, old_resp.code)
|
||||||
resp.msg = old_resp.msg
|
resp.msg = old_resp.msg
|
||||||
# deflate
|
# deflate
|
||||||
if resp.headers.get('Content-encoding', '') == 'deflate':
|
if resp.headers.get('Content-encoding', '') == 'deflate':
|
||||||
|
Loading…
Reference in New Issue
Block a user