|
|
@@ -579,6 +579,24 @@ class HeadlessBrowserService {
|
|
|
async fetchAccountInfo(platform: PlatformType, cookies: CookieData[]): Promise<AccountInfo> {
|
|
|
logger.info(`[fetchAccountInfo] Starting for platform: ${platform}`);
|
|
|
|
|
|
+ // 百家号:优先走 Python 的 /account_info(包含粉丝数、作品数),避免 Node 直连分散认证问题
|
|
|
+ if (platform === 'baijiahao') {
|
|
|
+ const pythonAvailable = await this.checkPythonServiceAvailable();
|
|
|
+ if (pythonAvailable) {
|
|
|
+ logger.info(`[Python API] Service available, fetching account_info for baijiahao`);
|
|
|
+ try {
|
|
|
+ return await this.fetchAccountInfoViaPython(platform, cookies);
|
|
|
+ } catch (error) {
|
|
|
+ logger.warn(`[Python API] Failed to fetch account_info for baijiahao, falling back to direct API:`, error);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ logger.info(`[Python API] Service not available for baijiahao, falling back to direct API`);
|
|
|
+ }
|
|
|
+
|
|
|
+ // Python 不可用或失败时,回退到 Node 直连 API(可能仍会遇到分散认证问题)
|
|
|
+ return this.fetchBaijiahaoAccountInfoDirectApi(cookies);
|
|
|
+ }
|
|
|
+
|
|
|
// 对于支持的平台,尝试使用 Python API 获取作品列表和账号信息
|
|
|
// 包括百家号,通过 Python API 执行,逻辑与 Node 服务端保持一致
|
|
|
const supportedPlatforms: PlatformType[] = ['douyin', 'xiaohongshu', 'kuaishou', 'weixin_video', 'baijiahao'];
|