mirror of https://github.com/yt-dlp/yt-dlp.git
Use io.BytesIO instead of StringIO
This commit is contained in:
parent
a8156c1d2e
commit
03f9daab34
|
@ -2,7 +2,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import datetime
|
||||
import HTMLParser
|
||||
import httplib
|
||||
import netrc
|
||||
import os
|
||||
|
@ -15,11 +14,6 @@ import random
|
|||
import math
|
||||
from urlparse import parse_qs
|
||||
|
||||
try:
|
||||
import cStringIO as StringIO
|
||||
except ImportError:
|
||||
import StringIO
|
||||
|
||||
from utils import *
|
||||
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import gzip
|
||||
import io
|
||||
import locale
|
||||
import os
|
||||
import re
|
||||
|
@ -10,11 +11,6 @@ import zlib
|
|||
import email.utils
|
||||
import json
|
||||
|
||||
try:
|
||||
import cStringIO as StringIO
|
||||
except ImportError:
|
||||
import StringIO
|
||||
|
||||
try:
|
||||
import urllib.request as compat_urllib_request
|
||||
except ImportError: # Python 2
|
||||
|
@ -400,12 +396,12 @@ class YoutubeDLHandler(compat_urllib_request.HTTPHandler):
|
|||
old_resp = resp
|
||||
# gzip
|
||||
if resp.headers.get('Content-encoding', '') == 'gzip':
|
||||
gz = gzip.GzipFile(fileobj=StringIO.StringIO(resp.read()), mode='r')
|
||||
gz = gzip.GzipFile(fileobj=io.BytesIO(resp.read()), mode='r')
|
||||
resp = self.addinfourl_wrapper(gz, old_resp.headers, old_resp.url, old_resp.code)
|
||||
resp.msg = old_resp.msg
|
||||
# deflate
|
||||
if resp.headers.get('Content-encoding', '') == 'deflate':
|
||||
gz = StringIO.StringIO(self.deflate(resp.read()))
|
||||
gz = io.BytesIO(self.deflate(resp.read()))
|
||||
resp = self.addinfourl_wrapper(gz, old_resp.headers, old_resp.url, old_resp.code)
|
||||
resp.msg = old_resp.msg
|
||||
return resp
|
||||
|
|
Loading…
Reference in New Issue