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:
Andy
2026-03-24 17:44:23 -06:00
parent 99be88dc08
commit c930abc6fd
2 changed files with 19 additions and 1 deletions
-1
View File
@@ -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]: