get_discord_emoji.py: decode python better
This commit is contained in:
parent
b2753bddf8
commit
2eea92f9e5
|
@ -27,17 +27,13 @@ def download_file(url, path):
|
|||
def get_data(filename):
|
||||
bindata = open(filename, "rb").read()
|
||||
decompress = zlib.decompressobj()
|
||||
jsondata = decompress.decompress(bindata)
|
||||
jsondata = decompress.decompress(bindata).decode("utf-8")
|
||||
decoder = json.JSONDecoder()
|
||||
while len(jsondata) > 0:
|
||||
try:
|
||||
obj = json.loads(jsondata)
|
||||
if obj.get("t", "") == "READY":
|
||||
return obj
|
||||
except json.JSONDecodeError as jde:
|
||||
obj = json.loads(jsondata[0 : jde.pos])
|
||||
if obj.get("t", "") == "READY":
|
||||
return obj
|
||||
jsondata = jsondata[jde.pos :]
|
||||
obj, end = decoder.raw_decode(jsondata)
|
||||
if obj.get("t", "") == "READY":
|
||||
return obj
|
||||
jsondata = jsondata[end:]
|
||||
|
||||
|
||||
def main(*args):
|
||||
|
|
Loading…
Reference in a new issue