修改邮箱API使用逻辑,限制每次注册流程只获取一个邮箱账号
This commit is contained in:
@@ -2,6 +2,7 @@ from concurrent.futures import ThreadPoolExecutor
|
|||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import threading
|
import threading
|
||||||
|
import time
|
||||||
from ProxyPool import ProxyPool
|
from ProxyPool import ProxyPool
|
||||||
from SteamRegistrationWithPyno import SteamRegistrationWithPyno
|
from SteamRegistrationWithPyno import SteamRegistrationWithPyno
|
||||||
from EmailAPIClient import EmailAPIClient
|
from EmailAPIClient import EmailAPIClient
|
||||||
@@ -81,10 +82,12 @@ class ThreadManagerWithPyno:
|
|||||||
registration.main(email_data)
|
registration.main(email_data)
|
||||||
|
|
||||||
def get_email_from_api(self):
|
def get_email_from_api(self):
|
||||||
"""从API获取邮箱账号"""
|
"""从API获取邮箱账号 - 每次只获取一个"""
|
||||||
try:
|
try:
|
||||||
|
print("从API获取单个邮箱账号...")
|
||||||
email_data = self.email_api_client.get_email_credentials()
|
email_data = self.email_api_client.get_email_credentials()
|
||||||
if email_data:
|
if email_data:
|
||||||
|
print(f"获取到邮箱: {email_data['email']}")
|
||||||
return email_data
|
return email_data
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"从API获取邮箱失败: {e}")
|
print(f"从API获取邮箱失败: {e}")
|
||||||
@@ -117,13 +120,13 @@ class ThreadManagerWithPyno:
|
|||||||
self._running = True
|
self._running = True
|
||||||
try:
|
try:
|
||||||
if self.email_source == "api":
|
if self.email_source == "api":
|
||||||
# 使用API获取邮箱
|
# 使用API获取邮箱 - 只获取一个
|
||||||
while self._running and (self.reg_count == 0 or self.processed_count < self.reg_count):
|
email_data = self.get_email_from_api()
|
||||||
email_data = self.get_email_from_api()
|
if not email_data:
|
||||||
if not email_data:
|
print("无法从API获取邮箱,任务停止")
|
||||||
print("无法从API获取邮箱,任务停止")
|
return
|
||||||
break
|
# 处理单个邮箱
|
||||||
self.executor.submit(self.process_email, email_data)
|
self.process_email(email_data)
|
||||||
else:
|
else:
|
||||||
# 使用本地文件获取邮箱
|
# 使用本地文件获取邮箱
|
||||||
with open(self.email_file, "r", encoding="utf-8") as file:
|
with open(self.email_file, "r", encoding="utf-8") as file:
|
||||||
@@ -188,19 +191,18 @@ class GUIThreadManagerWithPyno(ThreadManagerWithPyno):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
if self.email_source == "api":
|
if self.email_source == "api":
|
||||||
# 使用API获取邮箱
|
# 使用API获取单个邮箱
|
||||||
with ThreadPoolExecutor(max_workers=self.config['executornum']) as self.executor:
|
self.gui.update_status("系统消息", "正在从API获取邮箱...")
|
||||||
while self._running and (self.reg_count == 0 or self.processed_count < self.reg_count):
|
email_data = self.get_email_from_api()
|
||||||
email_data = self.get_email_from_api()
|
if not email_data:
|
||||||
if not email_data:
|
self.gui.update_status("API错误", "无法从API获取邮箱", result="失败")
|
||||||
self.gui.update_status("API错误", "无法从API获取邮箱", result="失败")
|
return
|
||||||
break
|
|
||||||
|
|
||||||
# 跳过已完成的任务
|
# 处理单个邮箱,不使用线程池
|
||||||
if email_data['email'] not in self.completed_tasks:
|
if email_data['email'] not in self.completed_tasks:
|
||||||
self.executor.submit(self.process_email, email_data)
|
self.process_email(email_data)
|
||||||
else:
|
else:
|
||||||
print(f"跳过已完成的邮箱: {email_data['email']}")
|
self.gui.update_status(email_data['email'], "邮箱已处理过,跳过", result="跳过")
|
||||||
else:
|
else:
|
||||||
# 使用本地文件获取邮箱
|
# 使用本地文件获取邮箱
|
||||||
with open(self.email_file, 'r', encoding='utf-8') as file:
|
with open(self.email_file, 'r', encoding='utf-8') as file:
|
||||||
|
|||||||
Reference in New Issue
Block a user