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

@@ -21,7 +21,7 @@
# -*- coding: utf-8 -*-
# @Author : relakkes@gmail.com
# @Time : 2025/11/25
# @Desc : 代理自动刷新 Mixin 类,供各平台 client 使用
# @Desc : Auto-refresh proxy Mixin class for use by various platform clients
from typing import TYPE_CHECKING, Optional
@@ -33,31 +33,31 @@ if TYPE_CHECKING:
class ProxyRefreshMixin:
"""
代理自动刷新 Mixin
Auto-refresh proxy Mixin class
使用方法:
1. client 类继承此 Mixin
2. 在 client 的 __init__ 中调用 init_proxy_pool(proxy_ip_pool)
3. 在每次 request 方法调用前调用 await _refresh_proxy_if_expired()
Usage:
1. Let client class inherit this Mixin
2. Call init_proxy_pool(proxy_ip_pool) in client's __init__
3. Call await _refresh_proxy_if_expired() before each request method call
要求:
- client 类必须有 self.proxy 属性来存储当前代理URL
Requirements:
- client class must have self.proxy attribute to store current proxy URL
"""
_proxy_ip_pool: Optional["ProxyIpPool"] = None
def init_proxy_pool(self, proxy_ip_pool: Optional["ProxyIpPool"]) -> None:
"""
初始化代理池引用
Initialize proxy pool reference
Args:
proxy_ip_pool: 代理IP池实例
proxy_ip_pool: Proxy IP pool instance
"""
self._proxy_ip_pool = proxy_ip_pool
async def _refresh_proxy_if_expired(self) -> None:
"""
检测代理是否过期,如果过期则自动刷新
每次发起请求前调用此方法来确保代理有效
Check if proxy has expired, automatically refresh if so
Call this method before each request to ensure proxy is valid
"""
if self._proxy_ip_pool is None:
return
@@ -67,7 +67,7 @@ class ProxyRefreshMixin:
f"[{self.__class__.__name__}._refresh_proxy_if_expired] Proxy expired, refreshing..."
)
new_proxy = await self._proxy_ip_pool.get_or_refresh_proxy()
# 更新 httpx 代理URL
# Update httpx proxy URL
if new_proxy.user and new_proxy.password:
self.proxy = f"http://{new_proxy.user}:{new_proxy.password}@{new_proxy.ip}:{new_proxy.port}"
else: