i18n: translate all Chinese comments, docstrings, and logger messages to English

Comprehensive translation of Chinese text to English across the entire codebase:

- api/: FastAPI server documentation and logger messages
- cache/: Cache abstraction layer comments and docstrings
- database/: Database models and MongoDB store documentation
- media_platform/: All platform crawlers (Bilibili, Douyin, Kuaishou, Tieba, Weibo, Xiaohongshu, Zhihu)
- model/: Data model documentation
- proxy/: Proxy pool and provider documentation
- store/: Data storage layer comments
- tools/: Utility functions and browser automation
- test/: Test file documentation

Preserved: Chinese disclaimer header (lines 10-18) for legal compliance

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
程序员阿江(Relakkes)
2025-12-26 23:27:19 +08:00
parent 1544d13dd5
commit 157ddfb21b
93 changed files with 1971 additions and 1955 deletions

View File

@@ -38,14 +38,14 @@ class TestMongoDBRealConnection(unittest.TestCase):
conn = MongoDBConnection()
asyncio.run(conn._connect())
cls.mongodb_available = True
print("\n✓ MongoDB连接成功")
print("\n✓ MongoDB connection successful")
except Exception as e:
cls.mongodb_available = False
print(f"\n✗ MongoDB连接失败: {e}")
print(f"\n✗ MongoDB connection failed: {e}")
def setUp(self):
if not self.mongodb_available:
self.skipTest("MongoDB不可用")
self.skipTest("MongoDB not available")
MongoDBConnection._instance = None
MongoDBConnection._client = None
@@ -82,9 +82,9 @@ class TestMongoDBRealConnection(unittest.TestCase):
try:
asyncio.run(cleanup())
print("\n测试数据清理完成")
print("\nTest data cleanup completed")
except Exception as e:
print(f"\n清理测试数据时出错: {e}")
print(f"\nError cleaning up test data: {e}")
def test_real_connection(self):
async def test():
@@ -106,8 +106,8 @@ class TestMongoDBRealConnection(unittest.TestCase):
test_data = {
"note_id": "test_note_001",
"title": "测试笔记",
"content": "这是一条测试内容",
"title": "Test Note",
"content": "This is a test content",
"created_at": datetime.now().isoformat()
}
@@ -125,7 +125,7 @@ class TestMongoDBRealConnection(unittest.TestCase):
self.assertIsNotNone(found)
self.assertEqual(found["note_id"], "test_note_001")
self.assertEqual(found["title"], "测试笔记")
self.assertEqual(found["title"], "Test Note")
asyncio.run(test())
@@ -135,7 +135,7 @@ class TestMongoDBRealConnection(unittest.TestCase):
initial_data = {
"note_id": "test_note_002",
"title": "初始标题",
"title": "Initial Title",
"likes": 10
}
@@ -147,7 +147,7 @@ class TestMongoDBRealConnection(unittest.TestCase):
updated_data = {
"note_id": "test_note_002",
"title": "更新后的标题",
"title": "Updated Title",
"likes": 100
}
@@ -162,7 +162,7 @@ class TestMongoDBRealConnection(unittest.TestCase):
{"note_id": "test_note_002"}
)
self.assertEqual(found["title"], "更新后的标题")
self.assertEqual(found["title"], "Updated Title")
self.assertEqual(found["likes"], 100)
asyncio.run(test())
@@ -176,7 +176,7 @@ class TestMongoDBRealConnection(unittest.TestCase):
data = {
"note_id": f"test_note_{i:03d}",
"user_id": test_user_id,
"title": f"测试笔记{i}",
"title": f"Test Note {i}",
"likes": i * 10
}
await store.save_or_update(
@@ -226,9 +226,9 @@ class TestMongoDBRealConnection(unittest.TestCase):
note_data = {
"note_id": "xhs_test_001",
"user_id": "user_001",
"nickname": "测试用户",
"title": "小红书测试笔记",
"desc": "这是一条测试笔记",
"nickname": "Test User",
"title": "Xiaohongshu Test Note",
"desc": "This is a test note",
"type": "normal",
"liked_count": "100",
"collected_count": "50",
@@ -240,16 +240,16 @@ class TestMongoDBRealConnection(unittest.TestCase):
"comment_id": "comment_001",
"note_id": "xhs_test_001",
"user_id": "user_002",
"nickname": "评论用户",
"content": "这是一条测试评论",
"nickname": "Comment User",
"content": "This is a test comment",
"like_count": "10"
}
await store.store_comment(comment_data)
creator_data = {
"user_id": "user_001",
"nickname": "测试创作者",
"desc": "这是一个测试创作者",
"nickname": "Test Creator",
"desc": "This is a test creator",
"fans": "1000",
"follows": "100"
}
@@ -259,15 +259,15 @@ class TestMongoDBRealConnection(unittest.TestCase):
note = await mongo_store.find_one("contents", {"note_id": "xhs_test_001"})
self.assertIsNotNone(note)
self.assertEqual(note["title"], "小红书测试笔记")
self.assertEqual(note["title"], "Xiaohongshu Test Note")
comment = await mongo_store.find_one("comments", {"comment_id": "comment_001"})
self.assertIsNotNone(comment)
self.assertEqual(comment["content"], "这是一条测试评论")
self.assertEqual(comment["content"], "This is a test comment")
creator = await mongo_store.find_one("creators", {"user_id": "user_001"})
self.assertIsNotNone(creator)
self.assertEqual(creator["nickname"], "测试创作者")
self.assertEqual(creator["nickname"], "Test Creator")
asyncio.run(test())
@@ -278,9 +278,9 @@ class TestMongoDBRealConnection(unittest.TestCase):
video_data = {
"aweme_id": "dy_test_001",
"user_id": "user_001",
"nickname": "测试用户",
"title": "抖音测试视频",
"desc": "这是一条测试视频",
"nickname": "Test User",
"title": "Douyin Test Video",
"desc": "This is a test video",
"liked_count": "1000",
"comment_count": "100"
}
@@ -290,15 +290,15 @@ class TestMongoDBRealConnection(unittest.TestCase):
"comment_id": "dy_comment_001",
"aweme_id": "dy_test_001",
"user_id": "user_002",
"nickname": "评论用户",
"content": "这是一条测试评论"
"nickname": "Comment User",
"content": "This is a test comment"
}
await store.store_comment(comment_data)
creator_data = {
"user_id": "user_001",
"nickname": "测试创作者",
"desc": "这是一个测试创作者"
"nickname": "Test Creator",
"desc": "This is a test creator"
}
await store.store_creator(creator_data)
@@ -306,7 +306,7 @@ class TestMongoDBRealConnection(unittest.TestCase):
video = await mongo_store.find_one("contents", {"aweme_id": "dy_test_001"})
self.assertIsNotNone(video)
self.assertEqual(video["title"], "抖音测试视频")
self.assertEqual(video["title"], "Douyin Test Video")
comment = await mongo_store.find_one("comments", {"comment_id": "dy_comment_001"})
self.assertIsNotNone(comment)
@@ -324,8 +324,8 @@ class TestMongoDBRealConnection(unittest.TestCase):
for i in range(10):
data = {
"note_id": f"concurrent_note_{i:03d}",
"title": f"并发测试笔记{i}",
"content": f"内容{i}"
"title": f"Concurrent Test Note {i}",
"content": f"Content {i}"
}
task = store.save_or_update(
"contents",
@@ -362,9 +362,9 @@ def run_integration_tests():
if __name__ == "__main__":
print("="*70)
print("MongoDB存储集成测试")
print("MongoDB Storage Integration Test")
print("="*70)
print(f"MongoDB配置:")
print(f"MongoDB Configuration:")
print(f" Host: {db_config.MONGODB_HOST}")
print(f" Port: {db_config.MONGODB_PORT}")
print(f" Database: {db_config.MONGODB_DB_NAME}")
@@ -373,12 +373,12 @@ if __name__ == "__main__":
result = run_integration_tests()
print("\n" + "="*70)
print("测试统计:")
print(f"总测试数: {result.testsRun}")
print(f"成功: {result.testsRun - len(result.failures) - len(result.errors)}")
print(f"失败: {len(result.failures)}")
print(f"错误: {len(result.errors)}")
print(f"跳过: {len(result.skipped)}")
print("Test Statistics:")
print(f"Total tests: {result.testsRun}")
print(f"Passed: {result.testsRun - len(result.failures) - len(result.errors)}")
print(f"Failed: {len(result.failures)}")
print(f"Errors: {len(result.errors)}")
print(f"Skipped: {len(result.skipped)}")
print("="*70)
sys.exit(0 if result.wasSuccessful() else 1)