import json

with open('/tmp/workouts_json.txt') as f:
    raw = f.read()
start = raw.find('[')
if start >= 0:
    workouts = json.loads(raw[start:])
    for w in workouts:
        title = w.get('title', '')
        if 'D1' in title and 'Full Body' in title:
            print(f"ID: {w['id']}")
            print(f"Title: {title}")
            print(f"Date: {w.get('start_time', 'unknown')}")
            # Save ID
            with open('/tmp/d1_workout_id.txt', 'w') as out:
                out.write(w['id'])
            break
