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