From dcead6239936ef04df514e3cfe14115222289322 Mon Sep 17 00:00:00 2001 From: eric Date: Fri, 14 Aug 2026 11:56:13 -0500 Subject: [PATCH] =?UTF-8?q?fix:=20TikTok=202158=20=E9=99=90=E6=B5=81?= =?UTF-8?q?=E6=97=B6=E7=BB=99=E5=87=BA=E6=98=8E=E7=A1=AE=E6=8F=90=E7=A4=BA?= =?UTF-8?q?=EF=BC=8C=E9=81=BF=E5=85=8D=E8=BF=9E=E7=82=B9=E5=8A=A0=E9=87=8D?= =?UTF-8?q?=E5=B0=81=E7=A6=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 账号因短时间大量发布被 TikTok 拒绝,错误改为中文说明并要求等待。 Co-authored-by: Cursor --- backend/app/tiktok_upload.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/backend/app/tiktok_upload.py b/backend/app/tiktok_upload.py index d073126..561c950 100644 --- a/backend/app/tiktok_upload.py +++ b/backend/app/tiktok_upload.py @@ -22,6 +22,19 @@ def _privacy_to_visibility(privacy_level: str) -> int: return 0 +def _friendly_upload_error(log: str) -> str: + text = str(log or "") + low = text.lower() + if "2158" in text or "posting videos too fast" in low or "take a rest" in low: + return "TikTok 限流:发得太快(status 2158)。请至少等几小时后再手动传 1 条,不要连点" + if "login expired" in low or '"status_code": 8' in text: + return "TikTok Cookie 已过期,请重新粘贴 sessionid" + if "invalid parameters" in low: + return "TikTok 拒绝发布参数,请稍后重试 1 次" + tail = " ".join(line.strip() for line in text.strip().splitlines()[-4:] if line.strip())[:240] + return tail or "TikTok 上传失败" + + def _upload_sync( *, channel_pk: str, @@ -93,10 +106,7 @@ def _upload_sync( "privacy_level": privacy_level, "dc_id": working_dc, } - tail = " ".join(line.strip() for line in log.strip().splitlines()[-4:] if line.strip())[:240] - raise ValueError( - tail or "TikTok 上传失败,请检查 Cookie 是否过期或 Node.js 是否可用" - ) + raise ValueError(_friendly_upload_error(log)) async def upload_tiktok_mp4(