Files
yunke/yunke-server/scripts/full_sync_all.sh
T
浅念 02dd77a62f feat(scraper): WA群抓取(type=1真机验证,223群)+群成员派生(12840成员/750群)
- wa-groups 实体:businessFriendList type=1 真机验证返回群,行结构是好友字段名
  (friendUid=@g.us 群ID/nickName=群名),专用 _normalize_wa_group_row
- backfill_group_members.py:无独立成员API,从群消息派生(talker=成员,sender_name=昵称)
- full_sync_all.sh:+4步(5b WA群/语音后录音重链接/8b 群消息+成员/消息上限99999)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-20 09:21:20 +08:00

64 lines
3.0 KiB
Bash

#!/bin/bash
# FULL page-based re-sync: ALL channels, ALL entities — ZERO API calls, ZERO 风控
cd "$(dirname "$0")/.."
export DB_URL="sqlite+aiosqlite:///./smoke.db"
PY=".venv/Scripts/python.exe"
echo "=============================================="
echo "$(date) === FULL PAGE-BASED RE-SYNC (NO API) ==="
echo "=============================================="
echo "$(date) --- 1/10 WeChat accounts ---"
$PY scripts/scrape_via_page.py --entity accounts
echo "$(date) --- 2/10 WA accounts ---"
$PY scripts/scrape_via_page.py --entity wa-accounts
echo "$(date) --- 3/10 WeChat customers ---"
$PY scripts/scrape_via_page.py --entity friends --max-employees 100
echo "$(date) --- 4/10 WA customers ---"
$PY scripts/scrape_via_page.py --entity wa-friends
echo "$(date) --- 5/10 WeChat groups ---"
$PY scripts/scrape_via_page.py --entity groups --max-employees 100
echo "$(date) --- 5b/10 WA groups ---"
$PY scripts/scrape_via_page.py --entity wa-groups
echo "$(date) --- 6/10 Voice calls (WeChat + WA) ---"
$PY scripts/scrape_via_page.py --entity voice-calls
# 语音重扫会把 record_media_hash 覆盖回 None —— 必须紧跟录音重链接
$PY -m app.sync.cli sync --entity call_recordings
echo "$(date) --- 7/10 Voice clips ---"
$PY scripts/scrape_via_page.py --entity voice-clips
echo "$(date) --- 8/10 WeChat messages ---"
$PY scripts/scrape_via_page.py --entity messages --max-conversations 99999
echo "$(date) --- 8b/10 WeChat group messages + members ---"
$PY scripts/scrape_via_page.py --entity group-messages --max-conversations 99999
$PY -m scripts.backfill_group_members
echo "$(date) --- 9/10 WA messages ---"
$PY scripts/scrape_via_page.py --entity wa-messages --max-conversations 99999
echo "$(date) --- 10/10 Media download (audio+images) ---"
$PY scripts/scrape_via_page.py --entity media
echo "=============================================="
echo "$(date) === FULL RE-SYNC COMPLETE ==="
echo "=============================================="
$PY -c "
import sqlite3
con = sqlite3.connect('smoke.db')
c = con.cursor()
print()
print('=== FINAL DATA SUMMARY ===')
for label, sql in [
('wechat accounts', \"SELECT COUNT(*) FROM wechat_account\"),
('whatsapp accounts', \"SELECT COUNT(*) FROM whatsapp_account\"),
('wechat customers', \"SELECT COUNT(*) FROM customer WHERE channel='wechat'\"),
('whatsapp customers', \"SELECT COUNT(*) FROM customer WHERE channel='whatsapp'\"),
('wechat groups', \"SELECT COUNT(*) FROM chat_group WHERE channel='wechat'\"),
('whatsapp groups', \"SELECT COUNT(*) FROM chat_group WHERE channel='whatsapp'\"),
('wechat messages', \"SELECT COUNT(*) FROM message WHERE channel='wechat'\"),
('whatsapp messages', \"SELECT COUNT(*) FROM message WHERE channel='whatsapp'\"),
('voice calls', \"SELECT COUNT(*) FROM phone_call WHERE channel IN ('voice_call','wa_voice_call')\"),
('voice clips', 'SELECT COUNT(*) FROM voice_clip'),
('media files', 'SELECT COUNT(*) FROM media'),
]:
print(f' {label:22s} {c.execute(sql).fetchone()[0]:>6}')
"