This commit is contained in:
hkyc
2025-03-31 09:55:54 +08:00
parent 4ef08d7775
commit 4759813f6e
32 changed files with 3879 additions and 0 deletions

66
reupload_all.py Normal file
View File

@@ -0,0 +1,66 @@
import asyncio
from loguru import logger
from core.config import Config
from core.database import DatabaseManager
from core.logger import setup_logger
from upload_accounts import AccountUploader
class ReuploadAll:
def __init__(self):
self.config = Config.from_yaml()
self.logger = setup_logger(self.config)
self.db_manager = DatabaseManager(self.config)
self.uploader = AccountUploader()
async def initialize(self):
"""初始化数据库和上传器"""
await self.db_manager.initialize()
await self.uploader.initialize()
async def cleanup(self):
"""清理资源"""
await self.db_manager.cleanup()
await self.uploader.cleanup()
async def reset_all_extracted(self):
"""重置所有账号的提取状态"""
try:
async with self.db_manager.get_connection() as conn:
await conn.execute(
"""
UPDATE email_accounts
SET extracted = 0, updated_at = CURRENT_TIMESTAMP
WHERE status = 'success' AND sold = 1
"""
)
await conn.commit()
self.logger.success("已重置所有账号的提取状态")
except Exception as e:
self.logger.error(f"重置提取状态时出错: {e}")
async def process(self):
"""处理重新上传所有账号"""
try:
# 重置所有账号的提取状态
await self.reset_all_extracted()
# 使用上传器处理所有账号
processed = await self.uploader.process_accounts()
self.logger.success(f"重新上传完成,共处理 {processed} 个账号")
except Exception as e:
self.logger.error(f"重新上传过程中出错: {e}")
finally:
await self.cleanup()
async def main():
reuploader = ReuploadAll()
await reuploader.initialize()
await reuploader.process()
if __name__ == "__main__":
asyncio.run(main())