Advertisement
sosyamba

Untitled

Apr 1st, 2025
897
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 5.89 KB | Gaming | 0 0
  1. import requests
  2. import json
  3.  
  4. # --- Credentials and Configuration (Fill these in) ---
  5. # Found in the /auth/login request body
  6. AUTH_USER_ID = "YOUR_USER_ID_HERE" # e.g., "9391359423245"
  7. AUTH_PHONE_NUMBER = "YOUR_PHONE_NUMBER_HERE" # e.g., "9807423145"
  8. AUTH_EPOCH = "YOUR_EPOCH_TIMESTAMP_HERE" # e.g., "1743435147"
  9. AUTH_HASH = "YOUR_HASH_HERE" # e.g., "ae25f..."
  10.  
  11. # Found in the headers of requests after login
  12. # Replace with the actual Bearer token needed for authorized requests
  13. BEARER_TOKEN = "YOUR_BEARER_TOKEN_HERE" # e.g., "eyJhbGciOiJIUz..."
  14.  
  15. # Found in the headers of the login request (and subsequent requests)
  16. LOGIN_COOKIE_HEADER = "YOUR_FULL_COOKIE_HEADER_STRING_HERE" # e.g., "qrator_jsr=...; qrator_jsid=...; _ym_uid=...; ..."
  17.  
  18. # Found in the body of the /game/finish request
  19. # Adjust this value as needed for the game logic
  20. RESULTS_COUNT_VALUE = 9999999
  21. # --- End of Credentials and Configuration ---
  22.  
  23.  
  24. # --- 1. Login Request ---
  25. url_login = "https://game.winelab.ru/api/v1/auth/login"
  26. headers_login = {
  27.     "Accept": "application/json, text/plain, */*",
  28.     "Accept-Language": "ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7",
  29.     "Content-Type": "application/json",
  30.     "Cookie": LOGIN_COOKIE_HEADER, # Use the configured cookie
  31.     "Origin": "https://game.winelab.ru",
  32.     "Referer": "https://game.winelab.ru/game/",
  33.     "sec-ch-ua": '"Chromium";v="134", "Not:A-Brand";v="24", "Android WebView";v="134"',
  34.     "sec-ch-ua-mobile": "?1",
  35.     "sec-ch-ua-platform": '"Android"',
  36.     "Sec-Fetch-Dest": "empty",
  37.     "Sec-Fetch-Mode": "cors",
  38.     "Sec-Fetch-Site": "same-origin",
  39.     "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",
  40.     "X-Requested-With": "ru.winelab"
  41. }
  42. payload_login = {
  43.   "type": "auth",
  44.   "user_id": AUTH_USER_ID,
  45.   "phone_number": AUTH_PHONE_NUMBER,
  46.   "epoch": AUTH_EPOCH,
  47.   "hash": AUTH_HASH
  48. }
  49.  
  50. session_id = None
  51. try:
  52.     response_login = requests.post(url_login, headers=headers_login, json=payload_login)
  53.     response_login.raise_for_status()
  54.     login_data = response_login.json()
  55.     session_id = login_data['session_id']
  56. except requests.exceptions.RequestException as e:
  57.     print(f"Login request failed: {e}")
  58.     exit()
  59. except (KeyError, json.JSONDecodeError) as e:
  60.     print(f"Failed to parse login response or get session_id: {e}")
  61.     if 'response_login' in locals():
  62.         print(f"Login Response Text: {response_login.text}")
  63.     exit()
  64.  
  65. # --- Common Headers for subsequent requests ---
  66. headers_common = {
  67.     "Accept": "application/json, text/plain, */*",
  68.     "Accept-Language": "ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7",
  69.     "authorization": f"Bearer {BEARER_TOKEN}",
  70.     "Cookie": LOGIN_COOKIE_HEADER,
  71.     "Referer": "https://game.winelab.ru/game/",
  72.     "Origin": "https://game.winelab.ru",
  73.     "sec-ch-ua": '"Chromium";v="134", "Not:A-Brand";v="24", "Android WebView";v="134"',
  74.     "sec-ch-ua-mobile": "?1",
  75.     "sec-ch-ua-platform": '"Android"',
  76.     "Sec-Fetch-Dest": "empty",
  77.     "Sec-Fetch-Mode": "cors",
  78.     "Sec-Fetch-Site": "same-origin",
  79.     "User-Agent": headers_login["User-Agent"],
  80.     "X-Requested-With": "ru.winelab"
  81. }
  82.  
  83. # --- 2. Get All Tasks Request ---
  84. url_alltasks = "https://game.winelab.ru/api/v1/alltasks"
  85. task_ids_list = []
  86. try:
  87.     response_alltasks = requests.get(url_alltasks, headers=headers_common)
  88.     response_alltasks.raise_for_status()
  89.     all_tasks_data = response_alltasks.json()
  90.     task_ids_list = [task['id'] for task in all_tasks_data if 'id' in task]
  91. except requests.exceptions.RequestException as e:
  92.     print(f"Get All Tasks request failed: {e}")
  93.     exit()
  94. except (json.JSONDecodeError, TypeError, KeyError) as e:
  95.     print(f"Failed to parse tasks response or extract IDs: {e}")
  96.     if 'response_alltasks' in locals():
  97.         print(f"Tasks Response Text: {response_alltasks.text}")
  98.     exit()
  99.  
  100. if not task_ids_list:
  101.     print("No task IDs found in the response. Exiting.")
  102.     exit()
  103.  
  104. # --- 3. Start Game Request ---
  105. url_start_game = f"https://game.winelab.ru/api/v1/game/start/{session_id}"
  106. headers_start_game = headers_common.copy()
  107. game_id = None
  108. try:
  109.     response_start_game = requests.post(url_start_game, headers=headers_start_game)
  110.     response_start_game.raise_for_status()
  111.     start_game_data = response_start_game.json()
  112.     game_id = start_game_data['game_id']
  113. except requests.exceptions.RequestException as e:
  114.     print(f"Start Game request failed: {e}")
  115.     exit()
  116. except (KeyError, json.JSONDecodeError) as e:
  117.     print(f"Failed to parse start game response or get game_id: {e}")
  118.     if 'response_start_game' in locals():
  119.       print(f"Start Game Response Text: {response_start_game.text}")
  120.     exit()
  121.  
  122. # --- 4. Finish Game Request ---
  123. url_finish_game = "https://game.winelab.ru/api/v1/game/finish"
  124. headers_finish_game = headers_common.copy()
  125. headers_finish_game["Content-Type"] = "application/json"
  126.  
  127. payload_finish_game = {
  128.   "game_id": str(game_id),
  129.   "session_id": session_id,
  130.   "results_count": RESULTS_COUNT_VALUE,
  131.   "task_ids": task_ids_list
  132. }
  133.  
  134. response_finish_game = None # Initialize variable
  135. try:
  136.     response_finish_game = requests.put(url_finish_game, headers=headers_finish_game, json=payload_finish_game)
  137.     response_finish_game.raise_for_status()
  138.     print(f"Finish Game Status Code: {response_finish_game.status_code}")
  139.     print("Finish Game Response JSON:")
  140.     print(response_finish_game.json())
  141. except requests.exceptions.RequestException as e:
  142.     print(f"Finish Game request failed: {e}")
  143.     if response_finish_game is not None:
  144.         print(f"Finish Game Response Text: {response_finish_game.text}")
  145. except json.JSONDecodeError:
  146.     print(f"Finish Game Status Code: {response_finish_game.status_code}")
  147.     print("Finish Game Response Text (not JSON):")
  148.     if response_finish_game is not None:
  149.         print(response_finish_game.text)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement