mirror of
https://github.com/SickGear/SickGear.git
synced 2024-12-01 08:53:37 +00:00
d97bb7174d
Change improve provider title processing. Change improve handling erroneous JSON responses. Change improve find show with unicode characters. Change improve result for providers Omgwtf, SpeedCD, Transmithenet, Zoogle. Change validate .torrent files that contain optional header data. Fix case where an episode status was not restored on failure. Add raise log error if no wanted qualities are found. Change add un/pw to Config/Media providers/Options for BTN API graceful fallback (can remove Api key for security). Change only download torrent once when using blackhole. Add Cloudflare module 1.6.8 (be0a536) to mitigate CloudFlare (IUAM) access validator. Add Js2Py 0.43 (c1442f1) Cloudflare dependency. Add pyjsparser 2.4.5 (cd5b829) Js2Py dependency.
68 lines
2.9 KiB
Python
68 lines
2.9 KiB
Python
# this is based on jsarray.py
|
|
|
|
from ..base import *
|
|
try:
|
|
import numpy
|
|
except:
|
|
pass
|
|
|
|
@Js
|
|
def Uint16Array():
|
|
TypedArray = (PyJsInt8Array,PyJsUint8Array,PyJsUint8ClampedArray,PyJsInt16Array,PyJsUint16Array,PyJsInt32Array,PyJsUint32Array,PyJsFloat32Array,PyJsFloat64Array)
|
|
a = arguments[0]
|
|
if isinstance(a, PyJsNumber): # length
|
|
length = a.to_uint32()
|
|
if length!=a.value:
|
|
raise MakeError('RangeError', 'Invalid array length')
|
|
temp = Js(numpy.full(length, 0, dtype=numpy.uint16))
|
|
temp.put('length', a)
|
|
return temp
|
|
elif isinstance(a, PyJsString): # object (string)
|
|
temp = Js(numpy.array(list(a.value), dtype=numpy.uint16))
|
|
temp.put('length', Js(len(list(a.value))))
|
|
return temp
|
|
elif isinstance(a, PyJsArray) or isinstance(a,TypedArray) or isinstance(a,PyJsArrayBuffer): # object (Array, TypedArray)
|
|
array = a.to_list()
|
|
array = [(int(item.value) if item.value != None else 0) for item in array]
|
|
temp = Js(numpy.array(array, dtype=numpy.uint16))
|
|
temp.put('length', Js(len(array)))
|
|
return temp
|
|
elif isinstance(a,PyObjectWrapper): # object (ArrayBuffer, etc)
|
|
if len(a.obj) % 2 != 0:
|
|
raise MakeError('RangeError', 'Byte length of Uint16Array should be a multiple of 2')
|
|
if len(arguments) > 1:
|
|
offset = int(arguments[1].value)
|
|
if offset % 2 != 0:
|
|
raise MakeError('RangeError', 'Start offset of Uint16Array should be a multiple of 2')
|
|
else:
|
|
offset = 0
|
|
if len(arguments) > 2:
|
|
length = int(arguments[2].value)
|
|
else:
|
|
length = int((len(a.obj)-offset)/2)
|
|
array = numpy.frombuffer(a.obj, dtype=numpy.uint16, count=length, offset=offset)
|
|
temp = Js(array)
|
|
temp.put('length', Js(length))
|
|
temp.buff = array
|
|
return temp
|
|
temp = Js(numpy.full(0, 0, dtype=numpy.uint16))
|
|
temp.put('length', Js(0))
|
|
return temp
|
|
|
|
Uint16Array.create = Uint16Array
|
|
Uint16Array.own['length']['value'] = Js(3)
|
|
|
|
Uint16Array.define_own_property('prototype', {'value': Uint16ArrayPrototype,
|
|
'enumerable': False,
|
|
'writable': False,
|
|
'configurable': False})
|
|
|
|
Uint16ArrayPrototype.define_own_property('constructor', {'value': Uint16Array,
|
|
'enumerable': False,
|
|
'writable': True,
|
|
'configurable': True})
|
|
|
|
Uint16ArrayPrototype.define_own_property('BYTES_PER_ELEMENT', {'value': Js(2),
|
|
'enumerable': False,
|
|
'writable': False,
|
|
'configurable': False})
|