mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-12-14 15:22:35 +00:00
Add support for IronPython
This commit is contained in:
parent
c989bdbef8
commit
65220c3bd6
3 changed files with 32 additions and 14 deletions
|
@ -2897,9 +2897,24 @@ except TypeError:
|
||||||
if isinstance(spec, compat_str):
|
if isinstance(spec, compat_str):
|
||||||
spec = spec.encode('ascii')
|
spec = spec.encode('ascii')
|
||||||
return struct.unpack(spec, *args)
|
return struct.unpack(spec, *args)
|
||||||
|
|
||||||
|
class compat_Struct(struct.Struct):
|
||||||
|
def __init__(self, fmt):
|
||||||
|
if isinstance(fmt, compat_str):
|
||||||
|
fmt = fmt.encode('ascii')
|
||||||
|
super(compat_Struct, self).__init__(fmt)
|
||||||
else:
|
else:
|
||||||
compat_struct_pack = struct.pack
|
compat_struct_pack = struct.pack
|
||||||
compat_struct_unpack = struct.unpack
|
compat_struct_unpack = struct.unpack
|
||||||
|
if platform.python_implementation() == 'IronPython' and sys.version_info < (2, 7, 8):
|
||||||
|
class compat_Struct(struct.Struct):
|
||||||
|
def unpack(self, string):
|
||||||
|
if not isinstance(string, buffer):
|
||||||
|
string = buffer(string)
|
||||||
|
return super(compat_Struct, self).unpack(string)
|
||||||
|
else:
|
||||||
|
compat_Struct = struct.Struct
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from future_builtins import zip as compat_zip
|
from future_builtins import zip as compat_zip
|
||||||
|
@ -2941,6 +2956,7 @@ __all__ = [
|
||||||
'compat_HTMLParseError',
|
'compat_HTMLParseError',
|
||||||
'compat_HTMLParser',
|
'compat_HTMLParser',
|
||||||
'compat_HTTPError',
|
'compat_HTTPError',
|
||||||
|
'compat_Struct',
|
||||||
'compat_b64decode',
|
'compat_b64decode',
|
||||||
'compat_basestring',
|
'compat_basestring',
|
||||||
'compat_chr',
|
'compat_chr',
|
||||||
|
|
|
@ -1,25 +1,27 @@
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import time
|
import time
|
||||||
import struct
|
|
||||||
import binascii
|
import binascii
|
||||||
import io
|
import io
|
||||||
|
|
||||||
from .fragment import FragmentFD
|
from .fragment import FragmentFD
|
||||||
from ..compat import compat_urllib_error
|
from ..compat import (
|
||||||
|
compat_Struct,
|
||||||
|
compat_urllib_error,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
u8 = struct.Struct(b'>B')
|
u8 = compat_Struct('>B')
|
||||||
u88 = struct.Struct(b'>Bx')
|
u88 = compat_Struct('>Bx')
|
||||||
u16 = struct.Struct(b'>H')
|
u16 = compat_Struct('>H')
|
||||||
u1616 = struct.Struct(b'>Hxx')
|
u1616 = compat_Struct('>Hxx')
|
||||||
u32 = struct.Struct(b'>I')
|
u32 = compat_Struct('>I')
|
||||||
u64 = struct.Struct(b'>Q')
|
u64 = compat_Struct('>Q')
|
||||||
|
|
||||||
s88 = struct.Struct(b'>bx')
|
s88 = compat_Struct('>bx')
|
||||||
s16 = struct.Struct(b'>h')
|
s16 = compat_Struct('>h')
|
||||||
s1616 = struct.Struct(b'>hxx')
|
s1616 = compat_Struct('>hxx')
|
||||||
s32 = struct.Struct(b'>i')
|
s32 = compat_Struct('>i')
|
||||||
|
|
||||||
unity_matrix = (s32.pack(0x10000) + s32.pack(0) * 3) * 2 + s32.pack(0x40000000)
|
unity_matrix = (s32.pack(0x10000) + s32.pack(0) * 3) * 2 + s32.pack(0x40000000)
|
||||||
|
|
||||||
|
|
|
@ -866,8 +866,8 @@ def _create_http_connection(ydl_handler, http_class, is_https, *args, **kwargs):
|
||||||
# expected HTTP responses to meet HTTP/1.0 or later (see also
|
# expected HTTP responses to meet HTTP/1.0 or later (see also
|
||||||
# https://github.com/rg3/youtube-dl/issues/6727)
|
# https://github.com/rg3/youtube-dl/issues/6727)
|
||||||
if sys.version_info < (3, 0):
|
if sys.version_info < (3, 0):
|
||||||
kwargs[b'strict'] = True
|
kwargs['strict'] = True
|
||||||
hc = http_class(*args, **kwargs)
|
hc = http_class(*args, **compat_kwargs(kwargs))
|
||||||
source_address = ydl_handler._params.get('source_address')
|
source_address = ydl_handler._params.get('source_address')
|
||||||
if source_address is not None:
|
if source_address is not None:
|
||||||
sa = (source_address, 0)
|
sa = (source_address, 0)
|
||||||
|
|
Loading…
Reference in a new issue