Compare commits
6
Commits
a315445f35
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6bb4c219bb | ||
|
|
fb32d17877 | ||
|
|
ad336074ef | ||
|
|
aba4583641 | ||
|
|
9103773fab | ||
|
|
09848dfaf4 |
+54
-3
@@ -143,7 +143,8 @@ def _skip_name(name):
|
||||
def list_accounts(prof=None):
|
||||
"""根目录下的账号列表(一个子目录 = 一个账号)+ 素材数/待发数/上次运行。"""
|
||||
from core import video_plan as vp
|
||||
from core.models import AeRun, VideoPlan
|
||||
from core.models import AeRun, VideoPlan, AccountStatusLog
|
||||
import datetime
|
||||
prof = merged(prof)
|
||||
root = account_root(prof)
|
||||
out = []
|
||||
@@ -174,6 +175,22 @@ def list_accounts(prof=None):
|
||||
comment_counts = _comment.pending_counts()
|
||||
except Exception:
|
||||
comment_counts = {"by_id": {}, "by_name": {}}
|
||||
# 近 7 天异常:一次查出所有异常检测记录,按 account_id/昵称取最近一条。
|
||||
now = datetime.datetime.now()
|
||||
cutoff = (now - datetime.timedelta(days=7)).strftime("%Y-%m-%d %H:%M:%S")
|
||||
try:
|
||||
logs = (AccountStatusLog.query
|
||||
.filter(AccountStatusLog.detected_at >= cutoff,
|
||||
AccountStatusLog.status.like("%异常%"))
|
||||
.order_by(AccountStatusLog.detected_at.desc()).all())
|
||||
except Exception:
|
||||
logs = []
|
||||
anomaly_by_id, anomaly_by_name = {}, {}
|
||||
for lg in logs:
|
||||
if lg.account_id and lg.account_id not in anomaly_by_id:
|
||||
anomaly_by_id[lg.account_id] = lg
|
||||
if lg.nickname and lg.nickname not in anomaly_by_name:
|
||||
anomaly_by_name[lg.nickname] = lg
|
||||
all_names = sorted(dirs | set(roster.keys()))
|
||||
for name in all_names:
|
||||
d = os.path.join(root, name)
|
||||
@@ -192,9 +209,39 @@ def list_accounts(prof=None):
|
||||
rr = roster.get(name) or {}
|
||||
cp = ((comment_counts.get("by_id") or {}).get(rr.get("id") or "")
|
||||
or (comment_counts.get("by_name") or {}).get(name) or 0)
|
||||
# 近 7 天异常:自动检测日志 + 当前人工标记取较近的一条
|
||||
lg = (anomaly_by_id.get(rr.get("id") or "")
|
||||
or anomaly_by_name.get(name))
|
||||
ab_at = (lg.detected_at or "") if lg else ""
|
||||
ab_src = (lg.source or "") if lg else ""
|
||||
manual_abn = "异常" in (rr.get("manual_status") or "")
|
||||
if manual_abn:
|
||||
mat = (rr.get("updated_at") or "").strip()
|
||||
if not ab_at or (mat and mat > ab_at):
|
||||
ab_at = mat or now.strftime("%Y-%m-%d %H:%M:%S")
|
||||
ab_src = "人工标记"
|
||||
ab_days = None
|
||||
if ab_at:
|
||||
try:
|
||||
_dt = datetime.datetime.strptime(ab_at[:19], "%Y-%m-%d %H:%M:%S")
|
||||
ab_days = max(0, (now - _dt).days)
|
||||
except Exception:
|
||||
ab_days = 0
|
||||
ab_text = "无异常"
|
||||
if ab_at:
|
||||
ab_text = ("今天异常" if ab_days == 0
|
||||
else ("%d天前异常" % ab_days))
|
||||
if manual_abn and (not lg or ab_src == "人工标记"):
|
||||
ab_text += "(人工)"
|
||||
out.append({"name": name, "media": media, "pending": pending, "done": done,
|
||||
"total": total, "need_text": need_text,
|
||||
"comment_pending": int(cp or 0),
|
||||
"douyin_id": rr.get("douyin_id") or "",
|
||||
"status_7d_abnormal": bool(ab_at),
|
||||
"status_7d_at": ab_at,
|
||||
"status_7d_days": ab_days,
|
||||
"status_7d_text": ab_text,
|
||||
"status_7d_source": ab_src,
|
||||
"unscanned": max(0, media - total),
|
||||
"has_dir": has_dir,
|
||||
"device_name": rr.get("device_name") or "",
|
||||
@@ -232,8 +279,9 @@ def export_accounts_csv(prof=None):
|
||||
out = io.StringIO()
|
||||
w = csv.writer(out)
|
||||
w.writerow(["设备号", "账号昵称", "抖音号", "手机号", "在线", "自动状态",
|
||||
"人工标记", "有效状态", "检测时间", "可发视频", "备注",
|
||||
"素材入库", "未发布", "已发布", "最近发布"])
|
||||
"人工标记", "有效状态", "检测时间", "近7天状态", "最近异常时间",
|
||||
"异常来源", "可发视频", "备注", "素材入库", "未发布", "已发布",
|
||||
"最近发布"])
|
||||
for a in rows:
|
||||
name = a.get("name") or ""
|
||||
rr = roster.get(name) or {}
|
||||
@@ -247,6 +295,9 @@ def export_accounts_csv(prof=None):
|
||||
a.get("manual_status") or "",
|
||||
a.get("effective_status") or a.get("account_status") or "",
|
||||
a.get("status_checked_at") or "",
|
||||
a.get("status_7d_text") or "",
|
||||
a.get("status_7d_at") or "",
|
||||
a.get("status_7d_source") or "",
|
||||
"是" if rr.get("can_post_video") else "否",
|
||||
rr.get("note") or "",
|
||||
a.get("total") or 0,
|
||||
|
||||
+17
-4
@@ -30,6 +30,16 @@ _DOUYIN_RE = re.compile(r"(^|\.)douyin\.com|iesdouyin\.com", re.I)
|
||||
_HEADER_WORDS = ("视频链接", "链接", "url", "账号", "昵称", "评论", "内容", "comment", "account")
|
||||
|
||||
|
||||
def has_emoji(text):
|
||||
"""是否含表情/符号(含 ZWJ 组合)。用于导入报告和输入校验。"""
|
||||
for ch in text or "":
|
||||
o = ord(ch)
|
||||
if (0x1F000 <= o <= 0x1FAFF or 0x2600 <= o <= 0x27BF
|
||||
or 0xFE00 <= o <= 0xFE0F or o == 0x200D):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def init_app(app):
|
||||
global _app
|
||||
_app = app
|
||||
@@ -136,7 +146,8 @@ def parse_rows(text):
|
||||
elif not comment:
|
||||
err = "评论内容为空"
|
||||
out.append({"line": i + 1, "url": url, "share_text": raw_url or url,
|
||||
"account": account, "comment": comment[:500], "error": err})
|
||||
"account": account, "comment": comment[:500],
|
||||
"emoji": has_emoji(comment[:500]), "error": err})
|
||||
return out
|
||||
|
||||
|
||||
@@ -196,6 +207,7 @@ def import_comments(text, dry_run=False):
|
||||
return {"ok": False, "error": "没有解析到有效行(需要三列:视频链接、账号、评论内容)",
|
||||
"added": 0, "updated": 0, "skipped": 0, "errors": 0, "rows": []}
|
||||
added = updated = skipped = 0
|
||||
emoji_rows = sum(1 for p in parsed if p.get("emoji") and not p.get("error"))
|
||||
rows_out = []
|
||||
with _ctx():
|
||||
by_name, by_id = _resolve_accounts()
|
||||
@@ -245,10 +257,11 @@ def import_comments(text, dry_run=False):
|
||||
if not dry_run:
|
||||
db.session.commit()
|
||||
errors = sum(1 for r in rows_out if r.get("action") == "error")
|
||||
_log.info("评论导入%s:新增 %d / 更新 %d / 跳过 %d / 错误 %d",
|
||||
"(预演)" if dry_run else "", added, updated, skipped, errors)
|
||||
_log.info("评论导入%s:新增 %d / 更新 %d / 跳过 %d / 错误 %d / 含表情 %d",
|
||||
"(预演)" if dry_run else "", added, updated, skipped, errors, emoji_rows)
|
||||
return {"ok": True, "dry_run": bool(dry_run), "added": added, "updated": updated,
|
||||
"skipped": skipped, "errors": errors, "rows": rows_out}
|
||||
"skipped": skipped, "errors": errors, "emoji_rows": emoji_rows,
|
||||
"rows": rows_out}
|
||||
|
||||
|
||||
# ================== 查询 / 统计 ==================
|
||||
|
||||
@@ -280,6 +280,8 @@ App 从每段的动作组/任务带出来(列表里显示"动作组 · App"或
|
||||
|
||||
- 导入表格每行三列:`视频链接 | 账号 | 评论内容`;账号写账号库昵称或抖音号。
|
||||
链接可以是整段抖音分享文本,平台会抠出抖音链接。
|
||||
- **CSV 必须存成「CSV UTF-8」**:Excel 默认的普通 CSV/GBK 会把表情变成 `?` 或丢掉;
|
||||
直接粘贴到文本框不受影响。导入报告里的 **「含表情 N 条」** 可以用来核对。
|
||||
- 「评论数据」看每条的状态:待评论 / 执行中 / 已评论 / 失败可重试 / 结果未知;
|
||||
支持重置为待评论、人工标已发/未知、删除。
|
||||
- 建计划时勾 **「评论计划」**(计划名旁会显示「评论」标签):账号列表改成显示
|
||||
@@ -320,17 +322,19 @@ App 从每段的动作组/任务带出来(列表里显示"动作组 · App"或
|
||||
|
||||
| 列 | 内容 | 可编辑 |
|
||||
|---|---|---|
|
||||
| 账号 | 昵称(+ 抖音号小字);不在账号库的会标「账号库没有」 | 编辑走账号库 |
|
||||
| 账号 | 昵称;不在账号库的会标「账号库没有」 | 编辑走账号库 |
|
||||
| **抖音号** | `device_account.douyin_id`(账号库里的抖音号) | 编辑走账号库 |
|
||||
| **所属手机** | `A01` / 未登记 / 未入池;下拉直接**改 `device_account.device_name`** | ✅ 换机就在这里改 |
|
||||
| **账号状态(自动)** | 任务自动检测到的 `账号正常` / `账号异常` / `作品异常` / `账号安全待提升`…(`device_account.account_status`)+ **最近检测时间**(`status_checked_at`) | ✅ 点「改」手填;点「记录」看历史(时间/状态/设备/来源);任务「读取文字」写变量 `account_status` 时自动回写(读到什么写什么,读不到不写) |
|
||||
| **人工标记** | 人工选择 `未标记` / `账号异常` / `作品异常` / `账号限流` / `账号正常`(`device_account.manual_status`) | ✅ 下拉直接选;**优先于自动状态**(筛选、通知、账号池 API 都按“有效状态”= 人工标记优先);任务后续自动检测**不会覆盖**人工判断;选「未标记」= 清除,回落自动状态 |
|
||||
| **近7天状态** | 计算列:近 7 天 `account_status_log` 里最近一条含「异常」的记录(或当前人工标记异常)。无异常显示「无异常」;有异常显示「N天前异常」/「今天异常(人工)」 | —(悬停看最近异常时间/来源) |
|
||||
| 素材库 | `入库 N · 未发布 N · 已发布 N`(+ 文件夹里还没入库的个数) | 点开进二级页 |
|
||||
| 最近发布 | 该账号最后一条的 `published_at` | — |
|
||||
| 操作 | 扫描 · 编辑账号 · **上传素材**(单个文件,见下)· **删除**(见下) | — |
|
||||
|
||||
**导出**:工具栏「⬇ 导出账号列表」下载 CSV(UTF-8 BOM,Excel 直接打开)。列:
|
||||
设备号 / 账号昵称 / 抖音号 / 手机号 / 在线 / 自动状态 / 人工标记 / 有效状态 / 检测时间 /
|
||||
可发视频 / 备注 / 素材入库 / 未发布 / 已发布 / 最近发布。
|
||||
**近7天状态 / 最近异常时间 / 异常来源** / 可发视频 / 备注 / 素材入库 / 未发布 / 已发布 / 最近发布。
|
||||
|
||||
**状态筛选与汇总通知**:表格上方可按「账号状态」筛选(全部 / 只看异常 / 具体状态 / 未设置),
|
||||
**按有效状态筛**(人工标记优先,所以人工标了异常的号也会进「只看异常」)。
|
||||
|
||||
+1
-1
@@ -1093,7 +1093,7 @@ multipart 上传 `.zip` 或 `.db`(字段 `file`)→ 校验并暂存:
|
||||
| POST | `/api/af/scan` | 扫账号目录入库(`dry_run` 只预览) |
|
||||
| POST | `/api/af/upload` | 上传素材到账号文件夹(form-data,传完自动扫描) |
|
||||
| GET | `/api/af/items` | 条目列表(`account`/`date`/`status`/`category`/`display_mode`/`q`) |
|
||||
| GET | `/api/af/accounts/export` | **导出账号列表 + 状态 CSV**(UTF-8 BOM;设备/昵称/抖音号/手机号/在线/自动状态/人工标记/有效状态/检测时间/可发视频/备注/素材计数) |
|
||||
| GET | `/api/af/accounts/export` | **导出账号列表 + 状态 CSV**(UTF-8 BOM;设备/昵称/抖音号/手机号/在线/自动状态/人工标记/有效状态/检测时间/**近7天状态/最近异常时间/异常来源**/可发视频/备注/素材计数) |
|
||||
| GET | `/api/af/assets/template` | **下载素材模板 CSV**(UTF-8 BOM) |
|
||||
| POST | `/api/af/assets/import` | **模板批量上传**(两项校验 → 分拣落盘 → 入库;`dry_run` 只报告不写盘) |
|
||||
| DELETE | `/api/af/account/<name>` | **删除账号**(`delete_roster` / `archive_dir` / `delete_records` 三项勾选;文件夹只归档不永久删) |
|
||||
|
||||
@@ -1108,3 +1108,49 @@ A02 一度被记成 20.65(实际是 A11 的手机),自动认领把 A11 迁
|
||||
`core/comment.pending_counts()` 按 `account_id`(改名也能对上)汇总。
|
||||
- 计划 `2f557c41` 已标记 `comment_mode=true`;账号列表会显示每个号真实的待评论数。
|
||||
- 注意:计划里勾的账号必须和导入评论的账号一致;不勾的账号不会跑。
|
||||
|
||||
## 42. 2026-10-31 修复:评论任务走到输入框但没输入内容
|
||||
|
||||
用户:"评论的任务现在能到输入评论这一步但是输入不了评论,我看都没有把评论复制过来。"
|
||||
|
||||
- 根因:`CommentItem.to_dict()` 的键是 **`comment_text`**,而 `input_text` 的
|
||||
`text_source="comment"` 分支读的是 `item["text"]` → 拿到空串;`input_text` 返回 None
|
||||
(步骤显示 ok),后面点发送/标记完成,评论内容一个字都没进去。
|
||||
- 修复:`_exec_input_text` 改读 `item["comment_text"] or item["text"]`;
|
||||
`foreach_comment` 同时补一个兼容的 `text` 键。`test_comment` 用真实键名回归。
|
||||
- 生产把 10:22 那次被误标 `done` 的 `锋哥苏州百业探访` 评论行**退回 `pending`**
|
||||
(没有真实评论内容,重新执行一次)。
|
||||
- 评论计划里 28 条待评论仍在;重新跑时输入步骤会真正填入账号对应的内容。
|
||||
|
||||
## 43. 2026-10-31 修复:评论表情在导入/输入时丢失
|
||||
|
||||
用户:"我的 CSV 里面有表情,貌似在手机上发不出来,你看一下我的评论数据。"
|
||||
|
||||
- **先查数据**:生产 28 条评论里 **0 条含表情** —— 表情在导入前就没了。
|
||||
最常见原因是 Excel 把表存成了**普通 CSV(GBK/ANSI)**:表情无法编码,被替换成 `?` 或直接丢弃。
|
||||
现在导入报告新增 **`emoji_rows` / 「含表情 N 条」**,导入弹窗也明确提示:
|
||||
CSV 必须存成 **「CSV UTF-8」**;直接粘贴表格不受影响。
|
||||
- **输入侧也做了加固**:`input_text` 的 `text_source="comment"` 改为**优先走设备端剪贴板**
|
||||
(Android 原生 Unicode,表情能保留),剪贴板失败才回落 `send_keys`。
|
||||
- **回读校验改严**:以前只比对 `text[:12]`(前缀),表情丢了也能通过;评论来源现在要求
|
||||
**整段文字都在输入框里**(strict),不对就重试/剪贴板兜底,最终不通过就判失败,
|
||||
不会再"悄悄发出没有表情/空内容"的评论。
|
||||
- 测试:`test_comment.py` 覆盖表情解析、入库、`emoji_rows` 计数。
|
||||
- 生产上 10:30 那次旧代码跑出的 `done/unknown` 评论行会在部署后统一退回 `pending`,
|
||||
重新导入带表情的 UTF-8 数据后再跑。
|
||||
|
||||
## 44. 2026-10-31 新增:资产表「抖音号」列 + 「近7天状态」计算列
|
||||
|
||||
用户:"资产管理加一列显示抖音号,然后再加一列计算列,计算 7 天内账号状态:
|
||||
没有异常显示无异常,有异常显示异常的时间几天前异常。"
|
||||
|
||||
- 账号总表新增 **抖音号** 列(`device_account.douyin_id`,账号库为空时显示—)。
|
||||
- 新增 **近7天状态** 计算列:
|
||||
- 数据源 = `account_status_log` 近 7 天内**状态含「异常」**的记录,取最近一条;
|
||||
- 当前 `manual_status` 含「异常」也算(按人工标记的 `updated_at`;没有则按今天),文案带「(人工)」;
|
||||
- 无异常 → **「无异常」**;有异常 → **「N天前异常」** / **「今天异常」**;
|
||||
- 悬停显示最近异常时间与来源(计划运行/任务运行/手动修改/人工标记)。
|
||||
- `list_accounts` 一次查出 7 天内异常日志(按 account_id/昵称索引),不做 N+1;
|
||||
导出 CSV 同步增加「近7天状态 / 最近异常时间 / 异常来源」。
|
||||
- 测试:`test_roster.py` ⑪(自动日志 3 天前、无异常、人工异常今天、抖音号)。
|
||||
- 无数据库迁移(全部是计算列)。
|
||||
|
||||
@@ -747,6 +747,8 @@ foreach_comment ← 按当前账号取一条待评论
|
||||
关闭评论区
|
||||
```
|
||||
|
||||
- **评论内容表情**:`input_text text_source=comment` 会**优先走设备端剪贴板**再粘贴
|
||||
(`send_keys` 常把 emoji 丢掉),并**严格回读整段文字**(不是只看前缀);剪贴板失败才回落。
|
||||
- **状态机**:`pending → running → done/failed/unknown`。`failed` 可重试(最多 3 次);
|
||||
`unknown` 不自动重试,需在「评论数据」里人工裁决。
|
||||
- **没执行 `mark_comment`**:按 `unknown` 处理(可能已经点了发送,宁可人工确认也不重复评论)。
|
||||
|
||||
@@ -73,6 +73,9 @@ rows = cm.parse_rows("https://v.douyin.com/a/,号甲,\"你好, 世界\"")
|
||||
check("逗号 CSV + 引号", rows[0]["comment"], "你好, 世界")
|
||||
rows = cm.parse_rows("https://v.douyin.com/a/\t号甲\t")
|
||||
check("空评论报错", bool(rows[0]["error"]), True)
|
||||
rows = cm.parse_rows("https://v.douyin.com/emoji/\t号甲\t你好😀👍")
|
||||
check("表情保留", rows[0]["comment"], "你好😀👍")
|
||||
check("表情标记", rows[0]["emoji"], True)
|
||||
|
||||
print("=== 2. 导入 / 去重 / 状态 ===")
|
||||
txt = "视频链接\t账号\t评论内容\nhttps://v.douyin.com/a/\t号甲\t第一条"
|
||||
@@ -97,6 +100,11 @@ r = cm.import_comments("https://v.douyin.com/dry/\t号乙\t预演", dry_run=True
|
||||
check("dry_run 计数", (r["added"], r["dry_run"]), (1, True))
|
||||
with app.app_context():
|
||||
check("dry_run 不写库", CommentItem.query.filter_by(account_name="号乙").count(), 0)
|
||||
r = cm.import_comments("https://v.douyin.com/emoji/\t号甲\t你好😀👍")
|
||||
check("导入报告含表情数", r.get("emoji_rows"), 1)
|
||||
with app.app_context():
|
||||
_er = CommentItem.query.filter_by(video_url="https://v.douyin.com/emoji").first()
|
||||
check("DB 保留表情", _er.comment_text if _er else None, "你好😀👍")
|
||||
|
||||
print("=== 3. 原子领取 / 标记 / 重试 / 僵尸 ===")
|
||||
reset_db()
|
||||
@@ -188,7 +196,7 @@ class _D:
|
||||
|
||||
w5 = gt.GenericStepsWorker("S1", {"steps": []})
|
||||
w5._vars["comment"] = {"comment_text": "输入框评论"}
|
||||
w5._verify_input = lambda d, text, clear: True
|
||||
w5._verify_input = lambda d, text, clear, strict=False: True
|
||||
w5._exec_input_text(_D(), {"text_source": "comment", "clear_first": True})
|
||||
check("input_text 取评论内容", sent.get("text"), "输入框评论")
|
||||
|
||||
|
||||
@@ -304,7 +304,32 @@ check("清除人工标记后回落到自动状态", row.effective_status, "账
|
||||
check("账号库里没有的号 → 不新建行",
|
||||
af.set_manual_status("没这个号", "账号异常"), False)
|
||||
|
||||
print("▶ ⑪ 导出账号列表 + 状态")
|
||||
print("▶ ⑪ 近7天异常计算(自动日志 + 人工标记)")
|
||||
import datetime # noqa: E402
|
||||
_now = datetime.datetime.now()
|
||||
with app.app_context():
|
||||
db.session.add(DeviceAccount(id="r7d", device_name="A01", nickname="七天测试号",
|
||||
douyin_id="9001"))
|
||||
db.session.add(DeviceAccount(id="rno", device_name="A02", nickname="无异常测试号",
|
||||
douyin_id="9002"))
|
||||
db.session.add(DeviceAccount(id="rman", device_name="A03", nickname="人工异常测试号",
|
||||
douyin_id="9003", manual_status="账号异常",
|
||||
updated_at=_now.strftime("%Y-%m-%d %H:%M:%S")))
|
||||
db.session.add(AccountStatusLog(
|
||||
id="log7d", account_id="r7d", nickname="七天测试号", status="账号异常",
|
||||
source="计划运行",
|
||||
detected_at=(_now - datetime.timedelta(days=3)).strftime("%Y-%m-%d %H:%M:%S"),
|
||||
created_at=(_now - datetime.timedelta(days=3)).strftime("%Y-%m-%d %H:%M:%S")))
|
||||
db.session.commit()
|
||||
_accts = {a["name"]: a for a in af.list_accounts()}
|
||||
check("7天内有异常标记", _accts["七天测试号"]["status_7d_abnormal"], True)
|
||||
check("7天异常天数", _accts["七天测试号"]["status_7d_days"], 3)
|
||||
check("7天异常文案", _accts["七天测试号"]["status_7d_text"], "3天前异常")
|
||||
check("无异常文案", _accts["无异常测试号"]["status_7d_text"], "无异常")
|
||||
check("人工异常按今天显示", _accts["人工异常测试号"]["status_7d_text"], "今天异常(人工)")
|
||||
check("抖音号列", _accts["七天测试号"]["douyin_id"], "9001")
|
||||
|
||||
print("▶ ⑫ 导出账号列表 + 状态")
|
||||
_csv = af.export_accounts_csv().decode("utf-8-sig")
|
||||
check("CSV 有表头", "账号昵称" in _csv and "有效状态" in _csv, True)
|
||||
check("CSV 带账号", "周周苏州吃喝玩乐" in _csv, True)
|
||||
|
||||
@@ -329,6 +329,8 @@ function afHtmlAsset() {
|
||||
'<td><b>' + esc(a.name) + '</b>' +
|
||||
(a.in_roster ? '' : ' <span class="label label-warning">账号库没有</span>') +
|
||||
(a.has_dir ? '' : '<div class="text-muted" style="font-size:11px">还没有素材文件夹</div>') + '</td>' +
|
||||
'<td class="text-muted" style="font-size:12px;font-family:var(--mono)">' +
|
||||
(a.douyin_id ? esc(a.douyin_id) : '—') + '</td>' +
|
||||
'<td>' + devSel + '</td>' +
|
||||
'<td style="white-space:nowrap">' +
|
||||
(a.account_status
|
||||
@@ -346,6 +348,13 @@ function afHtmlAsset() {
|
||||
esc(a.status_checked_at) + '</div>' : '') +
|
||||
'</td>' +
|
||||
'<td>' + afManualStatusHtml(a) + '</td>' +
|
||||
'<td style="white-space:nowrap">' +
|
||||
'<span class="label ' + (a.status_7d_abnormal ? 'label-warning' : 'label-success') + '" ' +
|
||||
'title="' + esc(a.status_7d_abnormal
|
||||
? ('最近异常 ' + (a.status_7d_at || '') +
|
||||
(a.status_7d_source ? '(' + a.status_7d_source + ')' : ''))
|
||||
: '近7天没有异常记录') + '">' +
|
||||
esc(a.status_7d_text || '无异常') + '</span></td>' +
|
||||
'<td><button class="btn btn-xs btn-primary" onclick="afAssetOpenAccount(\'' + esc(a.name) + '\')">' +
|
||||
'入库 <b>' + (a.total || 0) + '</b> · 未发布 <b style="color:#b45309">' + (a.pending || 0) + '</b>' +
|
||||
' · 已发布 <b style="color:#16a34a">' + (a.done || 0) + '</b>' +
|
||||
@@ -402,11 +411,13 @@ function afHtmlAsset() {
|
||||
? ',筛出 ' + shown.length + ' 个' : '') + '</span>' +
|
||||
'</div>' +
|
||||
'<table class="table"><thead><tr>' +
|
||||
'<th style="width:230px">账号</th><th style="width:210px">所属手机</th>' +
|
||||
'<th style="width:190px">账号状态(自动)</th><th style="width:140px">人工标记</th>' +
|
||||
'<th style="width:360px">素材库</th><th style="width:140px">最近发布</th><th style="width:190px">操作</th>' +
|
||||
'<th style="width:210px">账号</th><th style="width:120px">抖音号</th>' +
|
||||
'<th style="width:200px">所属手机</th>' +
|
||||
'<th style="width:180px">账号状态(自动)</th><th style="width:130px">人工标记</th>' +
|
||||
'<th style="width:130px">近7天状态</th>' +
|
||||
'<th style="width:320px">素材库</th><th style="width:130px">最近发布</th><th style="width:190px">操作</th>' +
|
||||
'</tr></thead><tbody>' +
|
||||
(rows || '<tr><td colspan="7" class="empty">' +
|
||||
(rows || '<tr><td colspan="9" class="empty">' +
|
||||
((F.device || F.q || F.status) ? '没有符合筛选条件的账号 —— 点「清除筛选」看全部'
|
||||
: '还没有账号 —— 先「导入/维护账号库」,再「批量上传素材」') +
|
||||
'</td></tr>') +
|
||||
@@ -2027,7 +2038,9 @@ function afOpenCommentImport() {
|
||||
'<div class="help" style="margin-bottom:8px">每行一条:<b>视频链接 账号 评论内容</b>(制表符/逗号都行)。' +
|
||||
'账号写账号库里的昵称或抖音号;同一个账号可以对多条视频各有一行。' +
|
||||
'重复导入按「视频链接 + 账号」去重:未执行的更新,已评论/结果未知的跳过。<br>' +
|
||||
'CSV 里评论内容带逗号/换行时要用引号包起来。</div>' +
|
||||
'CSV 里评论内容带逗号/换行时要用引号包起来。<b>CSV 必须存成「CSV UTF-8」</b>' +
|
||||
'(Excel 默认的普通 CSV/GBK 会把表情变成 ? 或直接丢掉);直接粘贴不受影响。' +
|
||||
'导入报告会显示「含表情 N 条」,可用来核对表情有没有保留。</div>' +
|
||||
'<div class="toolbar" style="margin-bottom:6px">' +
|
||||
'<a class="btn btn-xs" href="/api/af/comments/template" target="_blank">⬇ 下载模板(CSV)</a>' +
|
||||
'<span class="text-muted" style="font-size:12px">可以从 Excel 直接复制三列粘贴到下面</span></div>' +
|
||||
@@ -2081,7 +2094,8 @@ async function afDoCommentImport(dry) {
|
||||
const rows = res.rows || [];
|
||||
const head = (dry ? '试导' : '导入') + '完成:新增 ' + (res.added || 0) +
|
||||
' / 更新 ' + (res.updated || 0) + ' / 跳过 ' + (res.skipped || 0) +
|
||||
' / 错误 ' + (res.errors || 0) + (dry ? '(没有写库)' : '');
|
||||
' / 错误 ' + (res.errors || 0) + ' / 含表情 ' + (res.emoji_rows || 0) + ' 条' +
|
||||
(dry ? '(没有写库)' : '');
|
||||
log.innerHTML = '<div style="color:' + ((res.errors || 0) ? '#b45309' : '#16a34a') +
|
||||
';margin-bottom:4px"><b>' + esc(head) + '</b></div>' +
|
||||
'<table class="table" style="font-size:12px"><thead><tr>' +
|
||||
|
||||
+43
-5
@@ -2878,6 +2878,30 @@ class GenericStepsWorker(BaseWorker):
|
||||
if not text:
|
||||
return
|
||||
clear_first = params.get("clear_first", True)
|
||||
# 评论内容优先走**设备端剪贴板**:表情/特殊符号用 send_keys 常被丢掉,
|
||||
# 而剪贴板是 Android 原生 Unicode,抖音粘贴能保留。失败再落回 send_keys。
|
||||
if src == "comment":
|
||||
try:
|
||||
from core.clipboard_helper import inject_clipboard
|
||||
if clear_first:
|
||||
try:
|
||||
edit = d(className="android.widget.EditText")
|
||||
if edit.exists:
|
||||
edit.clear_text()
|
||||
except Exception:
|
||||
pass
|
||||
okc, msgc = inject_clipboard(self.serial, text, d=d)
|
||||
if okc:
|
||||
try:
|
||||
d.jsonrpc.pasteClipboard()
|
||||
except Exception as e:
|
||||
_log.warning(f"[{self.serial}] 评论粘贴失败(继续回读校验): {e}")
|
||||
if self._verify_input(d, text, clear_first, strict=True):
|
||||
return True
|
||||
else:
|
||||
_log.warning(f"[{self.serial}] 评论剪贴板注入失败(回落 send_keys): {msgc}")
|
||||
except Exception as e:
|
||||
_log.warning(f"[{self.serial}] 评论剪贴板注入异常(回落 send_keys): {e}")
|
||||
try:
|
||||
# 优先用 u2 的 send_keys(对当前焦点元素输入);clear=True 先清空再输入
|
||||
d.send_keys(text, clear=clear_first)
|
||||
@@ -2898,11 +2922,15 @@ class GenericStepsWorker(BaseWorker):
|
||||
# 取计划标题/评论内容时**必须回读校验**:抖音的 EditText 有时不吃 send_keys,
|
||||
# 不校验就可能发出一篇空文案而每一步都显示成功
|
||||
if src in RELEASE_TEXT_SOURCES or src == "comment":
|
||||
return self._verify_input(d, text, clear_first)
|
||||
return self._verify_input(d, text, clear_first, strict=(src == "comment"))
|
||||
return None
|
||||
|
||||
def _verify_input(self, d, text, clear_first):
|
||||
"""回读输入框,确认文字真的进去了;不行就改走剪贴板通道再验一次。"""
|
||||
def _verify_input(self, d, text, clear_first, strict=False):
|
||||
"""回读输入框,确认文字真的进去了;不行就改走剪贴板通道再验一次。
|
||||
|
||||
`strict=True`(评论):要求**整段文字都在**(含表情)。原来的 `text[:12] in got`
|
||||
只看前缀,表情被丢掉也能通过 —— 2026-10-31 用户实测踩过。
|
||||
"""
|
||||
def _read():
|
||||
try:
|
||||
el = d(className="android.widget.EditText")
|
||||
@@ -2912,9 +2940,19 @@ class GenericStepsWorker(BaseWorker):
|
||||
pass
|
||||
return ""
|
||||
|
||||
want = (text or "").strip()
|
||||
|
||||
def _ok(got):
|
||||
got = (got or "").strip()
|
||||
if not got or not want:
|
||||
return False
|
||||
if strict:
|
||||
return want in got
|
||||
return text[:12] in got
|
||||
|
||||
for attempt in (1, 2):
|
||||
got = _read()
|
||||
if got and text[:12] in got:
|
||||
if _ok(got):
|
||||
return True
|
||||
_log.warning(f"[{self.serial}] 文案回读不一致(第 {attempt} 次):"
|
||||
f"期望『{text[:20]}…』读到『{got[:20]}』")
|
||||
@@ -2932,7 +2970,7 @@ class GenericStepsWorker(BaseWorker):
|
||||
_log.warning(f"[{self.serial}] 剪贴板兜底异常: {e}")
|
||||
time.sleep(1)
|
||||
got = _read()
|
||||
if got and text[:12] in got:
|
||||
if _ok(got):
|
||||
return True
|
||||
_log.warning(f"[{self.serial}] ⚠ 文案没填进去(读回『{got[:30]}』)——"
|
||||
f"接着发布就会发出空文案,这一步判失败")
|
||||
|
||||
Reference in New Issue
Block a user