hohav / py-slippi

Python library for parsing SSBM replay files
MIT License
56 stars 25 forks source link

Can't parse files of games currently in-progress #13

Closed sheikchick closed 4 years ago

sheikchick commented 5 years ago

Unlike the NodeJS parser, the python parser is unable to handle games that are currently in-progress. The JSON parsing fails as shown below.

image

A link to the file I'm using as an example: https://drive.google.com/file/d/1tA-isWbk8f4nSV92PdLyrq3PUbgqlp6i/view?usp=sharing

Was hoping to pull live information from the game such as characters being played and stock counts.

IAmAbszol commented 4 years ago

I've actually forked and written a module for this exact reason, here's my fork: https://github.com/IAmAbszol/py-slippi. It runs by dumping through "buckets" where you can analyze. I'll be inquiring here in a month to have it merged into hohav's main release of py-slippi after I update it and have queue's rather than a bucket dumping method.

hohav commented 4 years ago

Thanks for the report @DWood46, and apologies for the delayed response. Yes, this is something I'd like to do but hadn't gotten around to.

I do have a local branch with some work towards parsing incomplete replays (by ditching the UBJSON parser in favor of scanning for specific byte sequences, like the official JS parser). I'll try to clean that up and push it soon, for reference if nothing else.

But I still haven't put much thought into incremental parsing, which would be necessary for live stats, etc. I'll look into @IAmAbszol's fork— I can't promise I'll end up taking the same approach, but I appreciate the work regardless.

hohav commented 4 years ago

@DWood46 try out the streaming branch. I added an event-driven parsing method that should be well-suited to live stats and incomplete replays.

hohav commented 4 years ago

The latest release of py-slippi supports this: just pass an input stream to the new event-based slippi.parse.parse method.