mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-27 06:10:12 +01:00
parent
1be0a96a4d
commit
59e92b1f18
|
@ -1,7 +1,6 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import functools
|
import functools
|
||||||
import gzip
|
|
||||||
import http.client
|
import http.client
|
||||||
import io
|
import io
|
||||||
import socket
|
import socket
|
||||||
|
@ -155,20 +154,9 @@ def brotli(data):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def gz(data):
|
def gz(data):
|
||||||
gz = gzip.GzipFile(fileobj=io.BytesIO(data), mode='rb')
|
# There may be junk added the end of the file
|
||||||
try:
|
# We ignore it by only ever decoding a single gzip payload
|
||||||
return gz.read()
|
return zlib.decompress(data, wbits=zlib.MAX_WBITS | 16)
|
||||||
except OSError as original_oserror:
|
|
||||||
# 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(data[:-i]), mode='rb')
|
|
||||||
return gz.read()
|
|
||||||
except OSError:
|
|
||||||
continue
|
|
||||||
else:
|
|
||||||
raise original_oserror
|
|
||||||
|
|
||||||
def http_request(self, req):
|
def http_request(self, req):
|
||||||
# According to RFC 3986, URLs can not contain non-ASCII characters, however this is not
|
# According to RFC 3986, URLs can not contain non-ASCII characters, however this is not
|
||||||
|
|
Loading…
Reference in New Issue
Block a user