Skip to content

Commit

Permalink
yt_dlp: 59e92b1f1833440bb2190f847eb735cf0f90bc85
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Aug 26, 2023
1 parent 49cff56 commit d394db0
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions lib/yt_dlp/networking/_urllib.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import annotations

import functools
import gzip
import http.client
import io
import socket
Expand Down Expand Up @@ -155,20 +154,9 @@ def brotli(data):

@staticmethod
def gz(data):
gz = gzip.GzipFile(fileobj=io.BytesIO(data), mode='rb')
try:
return gz.read()
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
# There may be junk added the end of the file
# We ignore it by only ever decoding a single gzip payload
return zlib.decompress(data, wbits=zlib.MAX_WBITS | 16)

def http_request(self, req):
# According to RFC 3986, URLs can not contain non-ASCII characters, however this is not
Expand Down

0 comments on commit d394db0

Please sign in to comment.