feat: 验收任务周期采集与设备资源接口
- 新增 acceptance-tasks 周期采集、立即采集、断点续采与批次管理 - acceptance-resources 返回 xhs_device_accounts 真实设备清单 - 数据看板服务调整及测试更新
This commit is contained in:
@@ -306,6 +306,17 @@ def get_wen_resources() -> dict[str, Any]:
|
||||
return _get("/api/v1/xhs/wen/resources")
|
||||
|
||||
|
||||
def list_xhs_wen_xapi_devices() -> list[dict[str, Any]]:
|
||||
"""查询 Framework `xhs_device_accounts` 中启用的设备清单。
|
||||
|
||||
通过 Framework 的调度配置接口读取,返回每台设备的账号、设备编码与
|
||||
可用时间窗口等调度字段,供前端「截图设备列表」直接展示真实设备。
|
||||
"""
|
||||
data = _get("/api/v1/xhs/wen/xapi/devices/settings")
|
||||
items = data.get("items")
|
||||
return items if isinstance(items, list) else []
|
||||
|
||||
|
||||
def fetch_content_detail(note_url: str) -> dict[str, Any]:
|
||||
"""按小红书笔记链接读取完整笔记详情。"""
|
||||
return _post(
|
||||
@@ -315,21 +326,43 @@ def fetch_content_detail(note_url: str) -> dict[str, Any]:
|
||||
)
|
||||
|
||||
|
||||
def schedule_xapi_screenshots(search_queries: list[str], device_count: int) -> dict[str, Any]:
|
||||
"""向手机集群下发关键词搜索与截图任务。"""
|
||||
def schedule_xapi_screenshots(
|
||||
search_queries: list[str], device_count: int, *, trigger_source: str = "acceptance",
|
||||
) -> dict[str, Any]:
|
||||
"""向手机集群立即下发关键词搜索与截图任务。"""
|
||||
queries = normalize_collection_keywords(search_queries)
|
||||
return _post(
|
||||
"/api/v1/xhs/wen/xapi/schedule",
|
||||
{"keywords": queries, "device_count": device_count},
|
||||
{
|
||||
"keywords": queries,
|
||||
"device_count": device_count,
|
||||
"execute_now": True,
|
||||
"trigger_source": trigger_source,
|
||||
},
|
||||
retry_transient=False,
|
||||
)
|
||||
|
||||
|
||||
def collect_keyword_sources(keyword: str, credential_id: str | None = None) -> dict[str, Any]:
|
||||
def query_xapi_batch_runs(batch_id: str, *, refresh: bool = True) -> dict[str, Any]:
|
||||
"""读取某个 Framework 调度批次下的设备任务、截图与飞书结果。"""
|
||||
normalized = str(batch_id or "").strip()
|
||||
if not normalized:
|
||||
raise CrawlerError("batch_id 不能为空")
|
||||
return _get(
|
||||
"/api/v1/xhs/wen/xapi/runs"
|
||||
f"?batch_id={normalized}&refresh={'true' if refresh else 'false'}"
|
||||
)
|
||||
|
||||
|
||||
def collect_keyword_sources(
|
||||
keyword: str, credential_id: str | None = None, cookie: str | None = None,
|
||||
) -> dict[str, Any]:
|
||||
"""使用指定 Cookie 采集单个关键词。"""
|
||||
normalized = normalize_collection_keywords([keyword])[0]
|
||||
body: dict[str, Any] = {"keyword": normalized}
|
||||
if credential_id:
|
||||
if cookie:
|
||||
body["cookie"] = cookie
|
||||
elif credential_id:
|
||||
body["credential_id"] = credential_id
|
||||
return _post(
|
||||
"/api/v1/xhs/wen/sources",
|
||||
|
||||
Reference in New Issue
Block a user