feat: 图片下载与数据目录本地化

- 新增 download_images.py: 批量下载消息图片到 downloads/images/
- 数据库移至 downloads/messages.db,SnifferStorage 默认使用项目目录
- 图片默认保存到 downloads/images/,支持 --out-dir 自定义
- .gitignore 排除 downloads/ 避免提交二进制文件
- 补充腾讯会议号过滤 prompt
- 补充 Obsidian 文档 is_read frontmatter
This commit is contained in:
Benature
2026-11-15 20:07:24 +08:00
parent cceeaf5c78
commit 81b6ff7a39
21 changed files with 2206 additions and 25 deletions

View File

@ -1,9 +1,48 @@
"""Small upstream client extension for visible, date-bounded history sync."""
import json
from larkx.client import LarkClient
from larkx.proto import decoders
def _json_text_fields(value, parts: list[str]) -> None:
"""Collect human-readable card labels, values and links without style metadata."""
if isinstance(value, dict):
for key, item in value.items():
if key in {"style", "styleKeys", "property", "childIds", "elementIds"}:
continue
if key in {"title", "text", "content", "label", "value", "description", "summary", "name", "url", "link"}:
if isinstance(item, str) and item.strip():
parts.append(item.strip())
else:
_json_text_fields(item, parts)
elif isinstance(value, list):
for item in value:
_json_text_fields(item, parts)
def extract_card_text(data: dict) -> str:
"""Extract readable text from JSON and rich-text cards ignored upstream."""
parts = []
json_card = data.get("jsonCard")
if json_card:
try:
_json_text_fields(json.loads(json_card), parts)
except (TypeError, ValueError):
pass
rich_text = decoders.extract_rich_text(data.get("richtext") or {})
if rich_text and set(rich_text) != {"@"}:
parts.append(rich_text)
seen = set()
unique_parts = []
for part in parts:
if part and part not in seen:
seen.add(part)
unique_parts.append(part)
return "\n".join(unique_parts)[:8000]
class SnifferLarkClient(LarkClient):
def pull_history(
self,
@ -34,6 +73,10 @@ class SnifferLarkClient(LarkClient):
summary, data = decoders.decode_message_content(
message_type, value.get("content", b"")
)
if message_type == 14 and data:
card_text = extract_card_text(data)
if card_text:
summary = f"{summary}\n{card_text}"
root_id = value.get("rootId") or ""
scope, anchor = decoders.resolve_scope(
value.get("id"),