| import uuid | |
| import json | |
| from pathlib import Path | |
| DATA_FILE = Path("data/motion_ids.json") | |
| def load_ids(): | |
| if DATA_FILE.exists(): | |
| return json.load(open(DATA_FILE)) | |
| return {} | |
| def save_ids(ids): | |
| json.dump(ids, open(DATA_FILE, "w"), indent=2) | |
| def create_motion_id(user_name): | |
| motion_id = str(uuid.uuid4()) | |
| ids = load_ids() | |
| ids[motion_id] = { | |
| "name": user_name, | |
| "created_at": str(datetime.datetime.now()), | |
| "usage_count": 0 | |
| } | |
| save_ids(ids) | |
| return motion_id |