Skip to content

Instantly share code, notes, and snippets.

@tolgakurtuluss
Last active October 5, 2025 19:55
Show Gist options
  • Save tolgakurtuluss/25da6412de36d23ed29cfae1674e0dba to your computer and use it in GitHub Desktop.
Save tolgakurtuluss/25da6412de36d23ed29cfae1674e0dba to your computer and use it in GitHub Desktop.
This Python script automatically tracks OpenAI Sora2 model invite codes on a web page and submits usable codes to the backend API. It detects new codes, avoids duplicates, handles rate limits and errors, and allows you to quickly and automatically use invite codes. Libraries used: playwright, BeautifulSoup, requests, nest_asyncio.
import asyncio
from playwright.async_api import async_playwright
from bs4 import BeautifulSoup
import nest_asyncio
import requests
import time
# --- User Settings ---
# You should copy cookies and headers while you're trying any invite code on below link.
# https://sora.chatgpt.com/backend/project_y/invite/accept
# You can find these values by copying your curl request and paste it into https://curlconverter.com
cookies = {}
headers = {}
nest_asyncio.apply()
url = "https://sora2invites-production.up.railway.app/"
seen_codes = set()
max_attempts = 25
async def check_and_use_codes():
async with async_playwright() as p:
browser = await p.chromium.launch(headless=True)
page = await browser.new_page()
while True:
await page.goto(url, timeout=60000)
await asyncio.sleep(5)
html = await page.content()
soup = BeautifulSoup(html, "html.parser")
codes = [span.get_text(strip=True) for span in soup.select(".code-text")]
new_codes = [c for c in codes if c not in seen_codes]
if new_codes:
print(f"New invite code found: {new_codes}")
seen_codes.update(new_codes)
# Her yeni kodu dene
for code in new_codes:
attempt = 0
while attempt < max_attempts:
json_data = {"invite_code": code}
response = requests.post(
"https://sora.chatgpt.com/backend/project_y/invite/accept",
cookies=cookies,
headers=headers,
json=json_data
)
if response.status_code == 200 and response.json().get("error") is None:
print(f"Successful! Code used: {code}")
break
elif response.json().get("error", {}).get("message") == "Too many requests":
attempt += 1
print(f"Too many requests, waiting... ({attempt}/{max_attempts})")
time.sleep(1)
else:
print(f"Error: {response.json()}")
break
else:
print(f"For {code} invite code, {max_attempts} attempts made. Waiting again...")
else:
print("Nothing new here. Waiting for 10 sec...")
await asyncio.sleep(10)
# --- Run ---
asyncio.run(check_and_use_codes())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment