Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- import json
- # --- Credentials and Configuration (Fill these in) ---
- # Found in the /auth/login request body
- AUTH_USER_ID = "YOUR_USER_ID_HERE" # e.g., "9391359423245"
- AUTH_PHONE_NUMBER = "YOUR_PHONE_NUMBER_HERE" # e.g., "9807423145"
- AUTH_EPOCH = "YOUR_EPOCH_TIMESTAMP_HERE" # e.g., "1743435147"
- AUTH_HASH = "YOUR_HASH_HERE" # e.g., "ae25f..."
- # Found in the headers of requests after login
- # Replace with the actual Bearer token needed for authorized requests
- BEARER_TOKEN = "YOUR_BEARER_TOKEN_HERE" # e.g., "eyJhbGciOiJIUz..."
- # Found in the headers of the login request (and subsequent requests)
- LOGIN_COOKIE_HEADER = "YOUR_FULL_COOKIE_HEADER_STRING_HERE" # e.g., "qrator_jsr=...; qrator_jsid=...; _ym_uid=...; ..."
- # Found in the body of the /game/finish request
- # Adjust this value as needed for the game logic
- RESULTS_COUNT_VALUE = 9999999
- # --- End of Credentials and Configuration ---
- # --- 1. Login Request ---
- url_login = "https://game.winelab.ru/api/v1/auth/login"
- headers_login = {
- "Accept": "application/json, text/plain, */*",
- "Accept-Language": "ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7",
- "Content-Type": "application/json",
- "Cookie": LOGIN_COOKIE_HEADER, # Use the configured cookie
- "Origin": "https://game.winelab.ru",
- "Referer": "https://game.winelab.ru/game/",
- "sec-ch-ua": '"Chromium";v="134", "Not:A-Brand";v="24", "Android WebView";v="134"',
- "sec-ch-ua-mobile": "?1",
- "sec-ch-ua-platform": '"Android"',
- "Sec-Fetch-Dest": "empty",
- "Sec-Fetch-Mode": "cors",
- "Sec-Fetch-Site": "same-origin",
- "User-Agent": "Mozilla/5.0 (Linux; Android 13; Infinix X6833B Build/TP1A.220624.014; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/134.0.6998.135 Mobile Safari/537.36",
- "X-Requested-With": "ru.winelab"
- }
- payload_login = {
- "type": "auth",
- "user_id": AUTH_USER_ID,
- "phone_number": AUTH_PHONE_NUMBER,
- "epoch": AUTH_EPOCH,
- "hash": AUTH_HASH
- }
- session_id = None
- try:
- response_login = requests.post(url_login, headers=headers_login, json=payload_login)
- response_login.raise_for_status()
- login_data = response_login.json()
- session_id = login_data['session_id']
- except requests.exceptions.RequestException as e:
- print(f"Login request failed: {e}")
- exit()
- except (KeyError, json.JSONDecodeError) as e:
- print(f"Failed to parse login response or get session_id: {e}")
- if 'response_login' in locals():
- print(f"Login Response Text: {response_login.text}")
- exit()
- # --- Common Headers for subsequent requests ---
- headers_common = {
- "Accept": "application/json, text/plain, */*",
- "Accept-Language": "ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7",
- "authorization": f"Bearer {BEARER_TOKEN}",
- "Cookie": LOGIN_COOKIE_HEADER,
- "Referer": "https://game.winelab.ru/game/",
- "Origin": "https://game.winelab.ru",
- "sec-ch-ua": '"Chromium";v="134", "Not:A-Brand";v="24", "Android WebView";v="134"',
- "sec-ch-ua-mobile": "?1",
- "sec-ch-ua-platform": '"Android"',
- "Sec-Fetch-Dest": "empty",
- "Sec-Fetch-Mode": "cors",
- "Sec-Fetch-Site": "same-origin",
- "User-Agent": headers_login["User-Agent"],
- "X-Requested-With": "ru.winelab"
- }
- # --- 2. Get All Tasks Request ---
- url_alltasks = "https://game.winelab.ru/api/v1/alltasks"
- task_ids_list = []
- try:
- response_alltasks = requests.get(url_alltasks, headers=headers_common)
- response_alltasks.raise_for_status()
- all_tasks_data = response_alltasks.json()
- task_ids_list = [task['id'] for task in all_tasks_data if 'id' in task]
- except requests.exceptions.RequestException as e:
- print(f"Get All Tasks request failed: {e}")
- exit()
- except (json.JSONDecodeError, TypeError, KeyError) as e:
- print(f"Failed to parse tasks response or extract IDs: {e}")
- if 'response_alltasks' in locals():
- print(f"Tasks Response Text: {response_alltasks.text}")
- exit()
- if not task_ids_list:
- print("No task IDs found in the response. Exiting.")
- exit()
- # --- 3. Start Game Request ---
- url_start_game = f"https://game.winelab.ru/api/v1/game/start/{session_id}"
- headers_start_game = headers_common.copy()
- game_id = None
- try:
- response_start_game = requests.post(url_start_game, headers=headers_start_game)
- response_start_game.raise_for_status()
- start_game_data = response_start_game.json()
- game_id = start_game_data['game_id']
- except requests.exceptions.RequestException as e:
- print(f"Start Game request failed: {e}")
- exit()
- except (KeyError, json.JSONDecodeError) as e:
- print(f"Failed to parse start game response or get game_id: {e}")
- if 'response_start_game' in locals():
- print(f"Start Game Response Text: {response_start_game.text}")
- exit()
- # --- 4. Finish Game Request ---
- url_finish_game = "https://game.winelab.ru/api/v1/game/finish"
- headers_finish_game = headers_common.copy()
- headers_finish_game["Content-Type"] = "application/json"
- payload_finish_game = {
- "game_id": str(game_id),
- "session_id": session_id,
- "results_count": RESULTS_COUNT_VALUE,
- "task_ids": task_ids_list
- }
- response_finish_game = None # Initialize variable
- try:
- response_finish_game = requests.put(url_finish_game, headers=headers_finish_game, json=payload_finish_game)
- response_finish_game.raise_for_status()
- print(f"Finish Game Status Code: {response_finish_game.status_code}")
- print("Finish Game Response JSON:")
- print(response_finish_game.json())
- except requests.exceptions.RequestException as e:
- print(f"Finish Game request failed: {e}")
- if response_finish_game is not None:
- print(f"Finish Game Response Text: {response_finish_game.text}")
- except json.JSONDecodeError:
- print(f"Finish Game Status Code: {response_finish_game.status_code}")
- print("Finish Game Response Text (not JSON):")
- if response_finish_game is not None:
- print(response_finish_game.text)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement