forked from kenzuya/unshackle
fix(subtitle): decompress gzip/zlib responses for subtitle downloads
The requests downloader used decode_content=False on raw socket reads, which skipped HTTP content-encoding decompression. Subtitle files served with Content-Encoding: gzip were saved as raw compressed bytes, then mangled by try_ensure_utf8 falling back to CP1252 decoding. Remove decode_content=False from the raw read path — the speed gain comes from raw.read() itself, not from skipping decompression. Also add gzip/zlib magic byte detection in try_ensure_utf8 as a safety net for any edge cases where compressed data reaches encoding detection.
This commit is contained in:
@@ -138,7 +138,6 @@ def download(
|
||||
chunks = stream.stream()
|
||||
elif use_raw:
|
||||
# requests.Session: raw socket read — 30-35% faster than iter_content
|
||||
stream.raw.decode_content = False
|
||||
_read = stream.raw.read
|
||||
|
||||
def _chunks() -> Generator[bytes, None, None]:
|
||||
|
||||
Reference in New Issue
Block a user