Skip to content

Instantly share code, notes, and snippets.

@MathewDominic
Created September 19, 2024 05:27
Show Gist options
  • Save MathewDominic/f24e6ca0fa6a7d68a0d9a04942446c21 to your computer and use it in GitHub Desktop.
Save MathewDominic/f24e6ca0fa6a7d68a0d9a04942446c21 to your computer and use it in GitHub Desktop.
Script to check for available gametime slots in playo app
# script to check for available gametime slots in playo app
import requests
import json
from datetime import datetime, timedelta
url = "https://api.playo.io/activity/playogames/list"
days_from_today = 0
# payload is currently set to check only for advanced and above level slots for badminton in HSR layout, Bangalore.
# You can change the payload to check for other skill levels, areas etc like how its being done for date below
payload = "{\n \"areaId\": \"29c5026a-9aa9-4ce9-b1e3-6cfcf7ad4277\",\n \"cityCode\": 1,\n \"date\": \"2024-09-19T05:30:00.000+0530\",\n \"lat\": 12.9121181,\n \"lng\": 77.6445548,\n \"skillLevel\": [\n 4,\n 5\n ],\n \"sportId\": [\n \"SP5\"\n ],\n \"userId\": \"ffdb384c-4026-47ba-8bbb-edf363773deb\"\n}"
payload = payload.replace('2024-09-19', (datetime.now() + timedelta(days=days_from_today) ).strftime('%Y-%m-%d'))
headers = {
"authorization": "", # get this by capturing the header of requests made from playo app using tools like HTTP Toolkit
"cache-control": "no-cache",
"userinfo": "{\"versionCode\":349,\"versionName\":\"7.0.69.349\",\"deviceModel\":\"Google | sdk_gphone64_arm64 | 34\",\"userId\":\"ffdb384c-4026-47ba-8bbb-edf363773deb\"}",
"content-type": "application/json; charset=UTF-8",
"host": "api.playo.io",
"connection": "Keep-Alive",
"accept-encoding": "gzip",
"user-agent": "okhttp/4.11.0"
}
response = requests.post(url, data=payload, headers=headers)
data = json.loads(response.text)['data']
for timing in data["playogames"]:
for activity in timing['activities']:
timestamp = datetime.strptime(activity['startTime'], '%Y-%m-%dT%H:%M:%S.%fZ')
timestamp = (timestamp + timedelta(hours=5, minutes=30)).strftime('%Y-%m-%dT%H:%M:%S.%fZ')
print("Checking slot for", timestamp)
if activity['joineeCount'] < activity['maxPlayers']:
print(f"{activity['maxPlayers'] - activity['joineeCount']} slots available for {timestamp}")
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment