daily_3dos.py 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. # -*- coding: utf-8 -*-
  2. import sys
  3. import os
  4. import time
  5. from httpx import Client
  6. from concurrent.futures import ThreadPoolExecutor, as_completed
  7. sys.path.append(os.path.join(os.path.abspath(__file__).split('auto')[0] + 'auto'))
  8. from utils.utils_send_gotify import *
  9. from utils.utils_daily_task_scheduler import *
  10. DEBUG_MODE = 1
  11. def daily_claim_3dos(email, password):
  12. # client = Client(proxy="http://127.0.0.1:7890")
  13. client = Client()
  14. login_url = "https://api.dashboard.3dos.io/api/auth/login"
  15. login_headers = {
  16. "Accept": "application/json, text/plain, */*",
  17. "Accept-Encoding": "gzip, deflate, br, zstd",
  18. "Accept-Language": "zh-CN,zh;q=0.9",
  19. "Content-Type": "application/json",
  20. "Origin": "https://dashboard.3dos.io",
  21. "Priority": "u=1, i",
  22. "Referer": "https://dashboard.3dos.io/",
  23. "Sec-CH-UA": '"Chromium";v="130", "Google Chrome";v="130", "Not?A_Brand";v="99"',
  24. "Sec-CH-UA-Mobile": "?0",
  25. "Sec-CH-UA-Platform": '"Windows"',
  26. "Sec-Fetch-Dest": "empty",
  27. "Sec-Fetch-Mode": "cors",
  28. "Sec-Fetch-Site": "same-site",
  29. "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36"
  30. }
  31. login_payload = {
  32. "email": email,
  33. "password": password
  34. }
  35. try:
  36. login_response = client.post(login_url, json=login_payload, headers=login_headers)
  37. except Exception as e:
  38. print(f"登录请求失败:{e}")
  39. return False
  40. if login_response.status_code == 200:
  41. # print(f"{email}: 登录成功!")
  42. login_data = login_response.json()
  43. # print("登录响应内容:", login_data)
  44. data = login_data.get("data")
  45. token = data.get("access_token") or data.get("token")
  46. token_type = data.get("token_type")
  47. if not token or not token_type:
  48. print("登录响应中未找到 Token 或 Token 类型!")
  49. return False
  50. authorization_header = f"{token_type} {token}"
  51. else:
  52. print("登录失败!")
  53. print("登录响应状态码:", login_response.status_code)
  54. exit(1)
  55. options_url = "https://api.dashboard.3dos.io/api/claim-reward"
  56. options_headers = {
  57. "Accept": "*/*",
  58. "Accept-Encoding": "gzip, deflate, br, zstd",
  59. "Accept-Language": "zh-CN,zh;q=0.9",
  60. "Access-Control-Request-Headers": "authorization,cache-control,content-type,expires,pragma",
  61. "Access-Control-Request-Method": "POST",
  62. "Origin": "https://dashboard.3dos.io",
  63. "Priority": "u=1, i",
  64. "Referer": "https://dashboard.3dos.io/",
  65. "Sec-Fetch-Dest": "empty",
  66. "Sec-Fetch-Mode": "cors",
  67. "Sec-Fetch-Site": "same-site",
  68. "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36"
  69. }
  70. try:
  71. options_response = client.options(options_url, headers=options_headers)
  72. except Exception as e:
  73. print(f"OPTIONS 请求失败:{e}")
  74. exit(1)
  75. # print("OPTIONS 请求响应状态码:", options_response.status_code)
  76. claim_url = "https://api.dashboard.3dos.io/api/claim-reward"
  77. claim_headers = {
  78. "Accept": "application/json, text/plain, */*",
  79. "Authorization": authorization_header,
  80. "Cache-Control": "no-cache",
  81. "Content-Type": "application/json",
  82. "Expires": "0",
  83. "Origin": "https://dashboard.3dos.io",
  84. "Pragma": "no-cache",
  85. "Priority": "u=1, i",
  86. "Referer": "https://dashboard.3dos.io/",
  87. "Sec-CH-UA": '"Chromium";v="130", "Google Chrome";v="130", "Not?A_Brand";v="99"',
  88. "Sec-CH-UA-Mobile": "?0",
  89. "Sec-CH-UA-Platform": '"Windows"',
  90. "Sec-Fetch-Dest": "empty",
  91. "Sec-Fetch-Mode": "cors",
  92. "Sec-Fetch-Site": "same-site",
  93. "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36"
  94. }
  95. claim_payload = {
  96. "id": "daily-reward-api"
  97. }
  98. try:
  99. claim_response = client.post(claim_url, json=claim_payload, headers=claim_headers)
  100. except Exception as e:
  101. print(f"{email} claim-reward 请求失败:{e}")
  102. exit(1)
  103. json_response = claim_response.json()
  104. if json_response:
  105. message = json_response.get("message")
  106. if claim_response.status_code not in [200, 429]:
  107. print(f"{email} claim 报错: {message}, 状态码{claim_response.status_code}")
  108. exit(1)
  109. result = f"{email}: {message}"
  110. return result
  111. def main():
  112. print("开始执行...")
  113. account_list = [
  114. "jack0210_@hotmail.com|||aaaAAA111!!!",
  115. "yujieccyj01@hotmail.com|||aaaAAA111!!!",
  116. "yujieccyj02@hotmail.com|||aaaAAA111!!!",
  117. "yujieccyj03@hotmail.com|||aaaAAA111!!!",
  118. "yujieccyj04@hotmail.com|||aaaAAA111!!!",
  119. "yujieccyj05@hotmail.com|||aaaaAA111!!!",
  120. "yujieccyj06@hotmail.com|||aaaAAA111!!!",
  121. "yujieccyj07@hotmail.com|||aaaAAA111!!!",
  122. "yujieccyj08@hotmail.com|||aaaAAA111!!!",
  123. "yujieccyj09@hotmail.com|||aaaAAA111!!!",
  124. "yujieccyj10@hotmail.com|||aaaAAA111!!!",
  125. ]
  126. send_str = ''
  127. with ThreadPoolExecutor(max_workers=len(account_list)) as executor:
  128. futures = []
  129. for account in account_list:
  130. email, password = account.split("|||")
  131. futures.append(executor.submit(daily_claim_3dos, email, password))
  132. for future in as_completed(futures):
  133. result = future.result()
  134. if result:
  135. send_str += result + '\n'
  136. print(result)
  137. time.sleep(1)
  138. if send_str:
  139. gotify_notifier = GotifyNotifier(title='3dos daily', message=send_str, token_name='CheckAndRemind')
  140. gotify_notifier.send_message()
  141. print(result)
  142. else:
  143. print("No news found.")
  144. if __name__ == "__main__":
  145. print('开始 3dos 每日签到')
  146. if DEBUG_MODE:
  147. file_path = os.path.join(os.getcwd(), "daily_3dos.txt")
  148. else:
  149. file_path = os.path.join(os.getcwd(), "auto", "daily", "daily_3dos.txt")
  150. T = TaskScheduler(file_path)
  151. # 执行前读取执行时间, 判断是否到执行时间
  152. if not T.load_start_time():
  153. print('3dos 任务未到执行时间')
  154. exit(1)
  155. # 开始执行
  156. main()
  157. # 执行完成后, 将执行时间 + 24 小时写入文件
  158. T.save_start_time()