The script requires the python-chess library which can be installed via:
pip install -r requirements.txt
The filter.py
script takes in a .pgn
file as an argument, and filters out
games that are faster than a pre-set time control (MIN_TIME_CONTROL
in the
script).
The time control is measured in seconds. If the game used a more complex time
setting than simple absolute time, it will try to calculate an estimated game
duration assuming an average of 40 moves per game. (For example, a 120+5
game
would count as 120 + 40 * 5 = 320
second game).
$ for g in $(curl -Ls https://api.chess.com/pub/player/Hikaru/games/archives | jq -rc ".archives[]") ; do curl -Ls "$g" | jq -rc ".games[].pgn" ; done >> games.pgn
$ python filter.py games.pgn > long_games.pgn