From a35f85b60051b3bd4a1fe056758d4df760ef7453 Mon Sep 17 00:00:00 2001 From: JJ Date: Fri, 21 Mar 2025 13:50:06 +0000 Subject: first commit --- .deploy-jezl.sh.swp | Bin 0 -> 12288 bytes .gitignore | 5 +++++ Constants.py | 2 ++ chess-stats.py | 40 ++++++++++++++++++++++++++++++++++++++++ deploy-jezl.sh | 4 ++++ 5 files changed, 51 insertions(+) create mode 100644 .deploy-jezl.sh.swp create mode 100644 .gitignore create mode 100644 Constants.py create mode 100755 chess-stats.py create mode 100755 deploy-jezl.sh diff --git a/.deploy-jezl.sh.swp b/.deploy-jezl.sh.swp new file mode 100644 index 0000000..aa1b257 Binary files /dev/null and b/.deploy-jezl.sh.swp differ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8dcc0cb --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +__pycache__ +Constants +chessdata.json +deploy-jez.sh + diff --git a/Constants.py b/Constants.py new file mode 100644 index 0000000..86c7081 --- /dev/null +++ b/Constants.py @@ -0,0 +1,2 @@ +KEY="lip_gyxlURgnCweO3xSt8MMB" +URL="https://lichess.org/api/user/naivespin/rating-history" diff --git a/chess-stats.py b/chess-stats.py new file mode 100755 index 0000000..19da4cd --- /dev/null +++ b/chess-stats.py @@ -0,0 +1,40 @@ +#!/usr/bin/env python3 + +import requests +import os +import json +import Constants + +key=Constants.KEY +url=Constants.URL +headers={"Authorization": f'Bearer {key}'} +outfile="chessdata.json" + +def main(): + new_arr=[] + res = requests.get(url, headers=headers) + text = res.text + json_data = json.loads(text) + + for d in json_data: + time_control = d.get("name") + scores = d.get("points") + + if time_control in ("Bullet","Blitz","Rapid"): + new_obj={} + new_obj["time_control"] = time_control + new_obj["data"] = [] + for score in scores: + month = score[1] = score[1] + 1 + score_obj = {'x': f'{score[0]}-{month}-{score[2]}', 'y': f'{score[3]}'} + new_obj["data"].append(score_obj) + new_arr.append(new_obj) + + + with open(outfile, "w") as f: + json.dump(new_arr, f) + + + +if __name__ == "__main__": + main() diff --git a/deploy-jezl.sh b/deploy-jezl.sh new file mode 100755 index 0000000..307c8ff --- /dev/null +++ b/deploy-jezl.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +python3 chess-stats.py && cp ./chessdata.json ~/websites/jezl/data/chess/ && cd ~/websites/jezl/ && hugo && rsync -avz public/ jezl-root:/var/www/jezl.xyz +exit 0 -- cgit v1.2.3